mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-05-25 18:04:01 +00:00
Add font tag to DeadDocument
https://github.com/Gnuxie/Draupnir/pull/85
This commit is contained in:
@@ -66,6 +66,7 @@ export enum NodeTag {
|
||||
Fragment = 'fragment',
|
||||
Details = 'details',
|
||||
Summary = 'summary',
|
||||
Font = 'font',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,9 +4,26 @@
|
||||
*/
|
||||
|
||||
import { htmlEscape } from "../../utils";
|
||||
import { FringeLeafRenderFunction, FringeType, LeafNode, NodeTag, SimpleFringeRenderer } from "./DeadDocument";
|
||||
import { DocumentNode, FringeLeafRenderFunction, FringeType, LeafNode, NodeTag, SimpleFringeRenderer, TagDynamicEnvironment } from "./DeadDocument";
|
||||
import { blank, staticString, TransactionalOutputContext } from "./DeadDocumentMarkdown";
|
||||
|
||||
function writeAttributableNode(tagName: string, _fringe: FringeType, node: DocumentNode, context: TransactionalOutputContext, _environment: TagDynamicEnvironment) {
|
||||
context.output.writeString(`<${tagName}`);
|
||||
if (node.attributeMap.size > 0) {
|
||||
for (const [key, value] of node.attributeMap.entries()) {
|
||||
context.output.writeString(` ${htmlEscape(key)}="${htmlEscape(value)}"`);
|
||||
}
|
||||
}
|
||||
context.output.writeString('>')
|
||||
}
|
||||
|
||||
function attributableNode(tagName: string) {
|
||||
return function(fringe: FringeType, node: DocumentNode, context: TransactionalOutputContext, environment: TagDynamicEnvironment) {
|
||||
writeAttributableNode(tagName, fringe, node, context, environment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const HTML_RENDERER = new SimpleFringeRenderer<TransactionalOutputContext>();
|
||||
|
||||
HTML_RENDERER.registerRenderer<FringeLeafRenderFunction<TransactionalOutputContext>>(
|
||||
@@ -52,16 +69,11 @@ HTML_RENDERER.registerRenderer<FringeLeafRenderFunction<TransactionalOutputConte
|
||||
staticString('<i>'),
|
||||
staticString('</i>')
|
||||
).registerInnerNode(NodeTag.Anchor,
|
||||
function(_fringe, node, context, _environment) {
|
||||
context.output.writeString('<a');
|
||||
if (node.attributeMap.size > 0) {
|
||||
for (const [key, value] of node.attributeMap.entries()) {
|
||||
context.output.writeString(` ${htmlEscape(key)}="${htmlEscape(value)}"`);
|
||||
}
|
||||
}
|
||||
context.output.writeString('>')
|
||||
},
|
||||
attributableNode('a'),
|
||||
staticString('</a>')
|
||||
).registerInnerNode(NodeTag.Font,
|
||||
attributableNode('font'),
|
||||
staticString('</font>')
|
||||
).registerInnerNode(NodeTag.Root,
|
||||
blank,
|
||||
blank
|
||||
|
||||
@@ -142,4 +142,7 @@ MARKDOWN_RENDERER.registerRenderer<FringeLeafRenderFunction<TransactionalOutputC
|
||||
).registerInnerNode(NodeTag.Summary,
|
||||
staticString('<summary>'),
|
||||
staticString('</summary>')
|
||||
).registerInnerNode(NodeTag.Font,
|
||||
blank,
|
||||
blank
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user