mmi-md 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/ast/nodes.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export interface DocumentNode {
|
|
|
2
2
|
type: 'document';
|
|
3
3
|
children: BlockNode[];
|
|
4
4
|
}
|
|
5
|
-
export type BlockNode = HeadingNode | ParagraphNode | ListNode | BlockquoteNode | CodeBlockNode | TableNode;
|
|
5
|
+
export type BlockNode = HeadingNode | ParagraphNode | ListNode | BlockquoteNode | SubtextNode | CodeBlockNode | TableNode;
|
|
6
6
|
export type InlineNode = TextNode | EmphasisNode | StrongNode | UnderlineNode | StrikethroughNode | CodeInlineNode | LinkNode | ImageNode | LineBreakNode;
|
|
7
7
|
export interface TextNode {
|
|
8
8
|
type: 'text';
|
|
@@ -57,6 +57,10 @@ export interface BlockquoteNode {
|
|
|
57
57
|
type: 'blockquote';
|
|
58
58
|
children: BlockNode[];
|
|
59
59
|
}
|
|
60
|
+
export interface SubtextNode {
|
|
61
|
+
type: 'subtext';
|
|
62
|
+
children: InlineNode[];
|
|
63
|
+
}
|
|
60
64
|
export interface ListNode {
|
|
61
65
|
type: 'list';
|
|
62
66
|
ordered: boolean;
|
|
@@ -65,6 +65,16 @@ export class BlockParser {
|
|
|
65
65
|
i++;
|
|
66
66
|
continue;
|
|
67
67
|
}
|
|
68
|
+
// Subtext
|
|
69
|
+
const s = line.match(/^([~:]?)(-#)\s+(.*)/);
|
|
70
|
+
if (s) {
|
|
71
|
+
blocks.push({
|
|
72
|
+
type: 'subtext',
|
|
73
|
+
children: InlineParser.parse(s[3])
|
|
74
|
+
});
|
|
75
|
+
i++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
68
78
|
// Code block
|
|
69
79
|
if (line.startsWith('```')) {
|
|
70
80
|
const content = [];
|
|
@@ -25,6 +25,8 @@ export class HTMLRenderer {
|
|
|
25
25
|
return `<p>${this.renderInline(b.children)}</p>`;
|
|
26
26
|
case 'blockquote':
|
|
27
27
|
return `<blockquote>${b.children.map((c) => this.renderBlock(c)).join('')}</blockquote>`;
|
|
28
|
+
case 'subtext':
|
|
29
|
+
return `<p class="subtext">${this.renderInline(b.children)}</p>`;
|
|
28
30
|
case 'list':
|
|
29
31
|
const tag = b.ordered ? 'ol' : 'ul';
|
|
30
32
|
return `<${tag}>${b.items.map((i) => `<li>${i.children.map((c) => this.renderBlock(c)).join('')}</li>`).join('')}</${tag}>`;
|