@podlite/markdown 0.0.72 → 0.0.74
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/CHANGELOG.podlite +6 -0
- package/lib/index.cjs +32 -31
- package/lib/index.cjs.map +4 -4
- package/lib/index.esm.js +36 -9
- package/lib/index.esm.js.map +2 -2
- package/package.json +2 -2
package/lib/index.esm.js
CHANGED
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
import { mkRootBlock } from "@podlite/schema";
|
|
22
22
|
import { assignHeadingKeys } from "@podlite/schema";
|
|
23
23
|
import { mkImage } from "@podlite/schema";
|
|
24
|
-
import { mkCaption } from "@podlite/schema";
|
|
25
24
|
import { mkFomattingCodeO } from "@podlite/schema";
|
|
26
25
|
var md2ast = (src, { lineOffset } = { lineOffset: 0 }) => {
|
|
27
26
|
var _a;
|
|
@@ -50,6 +49,13 @@ var md2ast = (src, { lineOffset } = { lineOffset: 0 }) => {
|
|
|
50
49
|
definitionMap[node.identifier] = node;
|
|
51
50
|
}
|
|
52
51
|
}).run(md_tree);
|
|
52
|
+
const htmlParents = /* @__PURE__ */ new WeakMap();
|
|
53
|
+
const recordParents = (node) => (node.children || []).forEach((child) => {
|
|
54
|
+
if ((child == null ? void 0 : child.type) === "html")
|
|
55
|
+
htmlParents.set(child, node.type || "");
|
|
56
|
+
recordParents(child);
|
|
57
|
+
});
|
|
58
|
+
recordParents(md_tree);
|
|
53
59
|
const uast = [];
|
|
54
60
|
const res = toAny({ processor: 1 }).use({
|
|
55
61
|
"*:*": (writer, processor) => (node, ctx, interator) => {
|
|
@@ -141,7 +147,10 @@ var md2ast = (src, { lineOffset } = { lineOffset: 0 }) => {
|
|
|
141
147
|
},
|
|
142
148
|
":html": (writer, processor) => (node, ctx, interator) => {
|
|
143
149
|
const { children, position, ...attr } = node;
|
|
144
|
-
|
|
150
|
+
const markdownHtml = inlineParents.includes(htmlParents.get(node)) ? "inline" : "block";
|
|
151
|
+
return mkBlock({ type: "block", name: "Html", markdownHtml, location: applyLineOffset(position) }, [
|
|
152
|
+
mkVerbatim(node.value)
|
|
153
|
+
]);
|
|
145
154
|
},
|
|
146
155
|
":code": (writer, processor) => (node, ctx, interator) => {
|
|
147
156
|
const { children, position, lang, meta, ...attr } = node;
|
|
@@ -164,13 +173,14 @@ var md2ast = (src, { lineOffset } = { lineOffset: 0 }) => {
|
|
|
164
173
|
":image": (writer, processor) => (node, ctx, interator) => {
|
|
165
174
|
const { title, alt, url, position, ...attr } = node;
|
|
166
175
|
let config = [];
|
|
167
|
-
const
|
|
168
|
-
if (title)
|
|
169
|
-
|
|
170
|
-
return mkBlock({ type: "block", name: "Image", config, location: applyLineOffset(position) },
|
|
176
|
+
const image = mkImage(url, alt);
|
|
177
|
+
if (typeof title === "string")
|
|
178
|
+
image.title = title;
|
|
179
|
+
return mkBlock({ type: "block", name: "Image", config, location: applyLineOffset(position) }, [image]);
|
|
171
180
|
},
|
|
172
181
|
":thematicBreak": (writer, processor) => (node, ctx, interator) => {
|
|
173
|
-
|
|
182
|
+
const { position } = node;
|
|
183
|
+
return mkBlock({ type: "block", name: "boundary", config: [], location: applyLineOffset(position) }, []);
|
|
174
184
|
},
|
|
175
185
|
":blockquote": (writer, processor) => (node, ctx, interator) => {
|
|
176
186
|
const { children, position, ...attr } = node;
|
|
@@ -204,10 +214,27 @@ var md2ast = (src, { lineOffset } = { lineOffset: 0 }) => {
|
|
|
204
214
|
return mkFomattingCodeO(interator(children, { ...ctx }));
|
|
205
215
|
},
|
|
206
216
|
":break": (writer, processor) => (node, ctx, interator) => {
|
|
207
|
-
return
|
|
217
|
+
return mkFomattingCode({ name: "S" }, ["\n"]);
|
|
208
218
|
}
|
|
209
219
|
}).run(md_tree);
|
|
210
|
-
|
|
220
|
+
const tree = assignHeadingKeys(
|
|
221
|
+
res.interator,
|
|
222
|
+
typeof src === "string" ? src : (_a = src == null ? void 0 : src.value) != null ? _a : ""
|
|
223
|
+
);
|
|
224
|
+
markSource(tree);
|
|
225
|
+
return tree;
|
|
226
|
+
};
|
|
227
|
+
var inlineParents = ["paragraph", "heading", "tableCell", "strong", "emphasis", "delete", "link", "linkReference"];
|
|
228
|
+
var markSource = (node) => {
|
|
229
|
+
if (Array.isArray(node))
|
|
230
|
+
return node.forEach(markSource);
|
|
231
|
+
if (!node || typeof node !== "object")
|
|
232
|
+
return;
|
|
233
|
+
const item = node;
|
|
234
|
+
if (item.type === "block")
|
|
235
|
+
item.sourceFormat = "markdown";
|
|
236
|
+
if (item.content)
|
|
237
|
+
markSource(item.content);
|
|
211
238
|
};
|
|
212
239
|
|
|
213
240
|
// src/index.tsx
|
package/lib/index.esm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx", "../src/tools.ts"],
|
|
4
|
-
"sourcesContent": ["import { content as nodeContent, Plugins } from '@podlite/schema'\nimport { Plugin } from '@podlite/schema'\nimport { md2ast } from './tools'\n\nexport const plugin: Plugin = {\n toAst: (_, processor) => (node, ctx) => {\n if (typeof node !== 'string' && 'type' in node && 'content' in node && node.type === 'block') {\n const content = node.content[0]\n if (content && typeof content !== 'string' && 'location' in node && 'value' in content) {\n const lineOffset = node.location.start.line\n return { ...node, content: md2ast(content, { lineOffset }) }\n }\n return node\n }\n },\n toJSX: helper => {\n return nodeContent\n },\n}\nexport const PluginRegister: Plugins = {\n Markdown: plugin, //TODO: deprecate it\n markdown: plugin,\n}\n\nexport { md2ast as parseMd } from './tools'\nexport default plugin\n", "import { unified } from 'unified'\nimport markdown from 'remark-parse'\nimport remarkGfm from 'remark-gfm'\nimport remarkMath from 'remark-math'\n\nimport {\n toAny,\n AstTree,\n BlockImage,\n mkBlock,\n mkFomattingCode,\n mkFomattingCodeL,\n mkVerbatim,\n Location,\n mkMarkupCodeF,\n mkFormulaBlock,\n parseAttributes,\n headingId,\n getTextContentFromNode,\n} from '@podlite/schema'\nimport { mkRootBlock } from '@podlite/schema'\nimport { assignHeadingKeys } from '@podlite/schema'\nimport { mkImage } from '@podlite/schema'\nimport { mkCaption } from '@podlite/schema'\nimport { mkFomattingCodeO } from '@podlite/schema'\n\ntype Md2astArgs = { lineOffset?: number }\nexport const md2ast = (src: string, { lineOffset }: Md2astArgs = { lineOffset: 0 }): AstTree => {\n // first convert mardown to ast\n const md_tree = unified().use(markdown).use(remarkGfm).use(remarkMath).parse(src)\n\n // first pass : collect linkRefs\n let definitionMap = {}\n const applyLineOffset = (\n (offset: number) =>\n (location: Location): Location => {\n const { start, end } = location\n return {\n start: {\n ...start,\n line: start.line + offset,\n },\n end: {\n ...end,\n line: end.line + offset,\n },\n }\n }\n )(lineOffset)\n toAny({ processor: 1 })\n .use({\n '*:*': (writer, processor) => (node, ctx, interator) => {\n if (node.children) interator(node.children, { ...ctx })\n },\n })\n .use({\n ':definition': (writer, processor) => (node, ctx, interator) => {\n definitionMap[node.identifier] = node\n },\n })\n .run(md_tree)\n\n // second stage - make Universal AST nodes\n const uast = []\n const res = toAny({ processor: 1 })\n .use({\n '*:*': (writer, processor) => (node, ctx, interator) => {\n console.warn('[Podlite:md2ast]- unhandled MD node')\n console.warn(JSON.stringify(node, null, 2))\n if (node.children) interator(node.children, { ...ctx })\n },\n })\n .use({\n ':root': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkRootBlock({}, interator(children, ctx))\n },\n ':math': (writer, processor) => (node, ctx, interator) => {\n const { value, children, position, ...attr } = node\n return mkFormulaBlock({ value, location: applyLineOffset(position) })\n },\n ':inlineMath': (writer, processor) => (node, ctx, interator) => {\n const { value, children, position, ...attr } = node\n return mkMarkupCodeF(value)\n },\n\n ':heading': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n const block = mkBlock(\n { type: 'block', level: node.depth, name: 'head', location: applyLineOffset(position) },\n interator(children, ctx),\n )\n // a link to a heading is written against its text, so a generated id points at nothing\n const id = headingId(getTextContentFromNode(block))\n // a heading holding only an image has no text to be named by, and an empty id would\n // repeat across every such heading\n return id ? { ...block, id } : block\n },\n ':text': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return node.value\n // return mkNode({type:\"text\", value: node.value})\n },\n ':list': (writer, processor) => (node, ctx, interator) => {\n const savedListLevel = ctx['listLevel'] || 0\n const { children, position, ...attr } = node\n return mkBlock(\n { type: 'list', level: savedListLevel + 1, list: node.ordered ? 'ordered' : 'itemized' },\n interator(children, { ...ctx, listLevel: savedListLevel + 1, ordered: node.ordered }),\n )\n },\n ':listItem': (writer, processor) => (node, ctx, interator) => {\n const savedListLevel = ctx['listLevel'] || 0\n const { children, position, checked, ...attr } = node\n const blockAttrs: any = {\n name: 'item',\n type: 'block',\n level: ctx['listLevel'],\n location: applyLineOffset(position),\n }\n\n if (checked !== null && checked !== undefined) {\n blockAttrs.checked = checked\n blockAttrs.config = [{ name: 'checked', value: checked, type: 'boolean' }]\n }\n\n return mkBlock(blockAttrs, interator(children, { ...ctx, listLevel: savedListLevel, ordered: node.ordered }))\n },\n ':paragraph': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkBlock(\n { type: 'para', location: applyLineOffset(position), text: 'text', margin: '' },\n interator(children, { ...ctx }),\n )\n },\n ':linkReference': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n const definition = definitionMap[attr.identifier]\n const meta = definition?.url || ''\n return mkFomattingCodeL({ meta }, interator(children, { ...ctx }))\n },\n ':definition': (writer, processor) => (node, ctx, interator) => {\n return null\n },\n ':inlineCode': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCode({ name: 'C' }, [node.value])\n },\n ':strong': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCode({ name: 'B' }, interator(children, { ...ctx }))\n },\n ':emphasis': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCode({ name: 'I' }, interator(children, { ...ctx }))\n },\n ':link': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCodeL({ meta: node.url }, interator(children, { ...ctx }))\n },\n ':html': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkBlock({ type: 'block', name: 'Html', location: applyLineOffset(position) }, [mkVerbatim(node.value)])\n },\n ':code': (writer, processor) => (node, ctx, interator) => {\n const { children, position, lang, meta, ...attr } = node\n if (lang === 'mermaid' || lang === 'diagram') {\n return mkBlock({ type: 'block', name: 'Mermaid', config: [], location: applyLineOffset(position) }, [\n mkVerbatim(node.value),\n ])\n }\n let config = []\n if (lang) {\n config.push({ name: 'lang', value: lang, type: 'string' })\n }\n if (meta) {\n config.push(...parseAttributes(meta))\n }\n return mkBlock({ type: 'block', name: 'code', config, location: applyLineOffset(position) }, [\n mkVerbatim(node.value),\n ])\n },\n ':image':\n (writer, processor) =>\n (node, ctx, interator): BlockImage => {\n const { title, alt, url, position, ...attr } = node\n let config = []\n const content: any[] = [mkImage(url, alt)]\n if (title) content.push(mkCaption([title]))\n return mkBlock({ type: 'block', name: 'Image', config, location: applyLineOffset(position) }, content)\n },\n ':thematicBreak': (writer, processor) => (node, ctx, interator) => {\n return null // TODO: add support for \"thematic break\"\n },\n ':blockquote': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkBlock({ name: 'nested', location: applyLineOffset(position) }, interator(children, { ...ctx }))\n },\n //table section\n ':table': (writer, processor) => (node, ctx, interator) => {\n const { children, position, align, ...attr } = node\n return mkBlock(\n { name: 'table', location: applyLineOffset(position), align },\n interator(children, { ...ctx, isHeaderUsed: 0 }),\n )\n },\n ':tableRow': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n const isHeaderUsed = ctx.isHeaderUsed++\n const blockAttrs: Record<string, unknown> = {\n name: 'row',\n location: applyLineOffset(position),\n }\n if (!isHeaderUsed) {\n blockAttrs.config = [{ name: 'header', value: true, type: 'boolean' }]\n }\n return mkBlock(blockAttrs, interator(children, { ...ctx }))\n },\n ':tableCell': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkBlock({ name: 'cell', location: applyLineOffset(position) }, interator(children, { ...ctx }))\n },\n ':delete': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCodeO(interator(children, { ...ctx }))\n },\n ':break': (writer, processor) => (node, ctx, interator) => {\n return null\n },\n })\n .run(md_tree)\n // a =markdown block hands over its verbatim node: the keys are fingerprinted from the\n // text the reader parsed\n return assignHeadingKeys(res.interator, typeof src === 'string' ? src : (src as { value?: string })?.value ?? '')\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,WAAW,mBAA4B;;;ACAhD,SAAS,eAAe;AACxB,OAAO,cAAc;AACrB,OAAO,eAAe;AACtB,OAAO,gBAAgB;AAEvB;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,
|
|
4
|
+
"sourcesContent": ["import { content as nodeContent, Plugins } from '@podlite/schema'\nimport { Plugin } from '@podlite/schema'\nimport { md2ast } from './tools'\n\nexport const plugin: Plugin = {\n toAst: (_, processor) => (node, ctx) => {\n if (typeof node !== 'string' && 'type' in node && 'content' in node && node.type === 'block') {\n const content = node.content[0]\n if (content && typeof content !== 'string' && 'location' in node && 'value' in content) {\n const lineOffset = node.location.start.line\n return { ...node, content: md2ast(content, { lineOffset }) }\n }\n return node\n }\n },\n toJSX: helper => {\n return nodeContent\n },\n}\nexport const PluginRegister: Plugins = {\n Markdown: plugin, //TODO: deprecate it\n markdown: plugin,\n}\n\nexport { md2ast as parseMd } from './tools'\nexport default plugin\n", "import { unified } from 'unified'\nimport markdown from 'remark-parse'\nimport remarkGfm from 'remark-gfm'\nimport remarkMath from 'remark-math'\n\nimport {\n toAny,\n AstTree,\n BlockImage,\n mkBlock,\n mkFomattingCode,\n mkFomattingCodeL,\n mkVerbatim,\n Location,\n mkMarkupCodeF,\n mkFormulaBlock,\n parseAttributes,\n headingId,\n getTextContentFromNode,\n} from '@podlite/schema'\nimport { mkRootBlock } from '@podlite/schema'\nimport { assignHeadingKeys } from '@podlite/schema'\nimport { mkImage } from '@podlite/schema'\nimport { mkFomattingCodeO } from '@podlite/schema'\n\ntype Md2astArgs = { lineOffset?: number }\nexport const md2ast = (src: string, { lineOffset }: Md2astArgs = { lineOffset: 0 }): AstTree => {\n // first convert mardown to ast\n const md_tree = unified().use(markdown).use(remarkGfm).use(remarkMath).parse(src)\n\n // first pass : collect linkRefs\n let definitionMap = {}\n const applyLineOffset = (\n (offset: number) =>\n (location: Location): Location => {\n const { start, end } = location\n return {\n start: {\n ...start,\n line: start.line + offset,\n },\n end: {\n ...end,\n line: end.line + offset,\n },\n }\n }\n )(lineOffset)\n toAny({ processor: 1 })\n .use({\n '*:*': (writer, processor) => (node, ctx, interator) => {\n if (node.children) interator(node.children, { ...ctx })\n },\n })\n .use({\n ':definition': (writer, processor) => (node, ctx, interator) => {\n definitionMap[node.identifier] = node\n },\n })\n .run(md_tree)\n\n // HTML stands for a part of a line inside a paragraph, a heading, a cell or a span,\n // and for a block anywhere else: the parent each piece of HTML has here is kept\n const htmlParents = new WeakMap<object, string>()\n const recordParents = (node: { type?: string; children?: any[] }): void =>\n (node.children || []).forEach(child => {\n if (child?.type === 'html') htmlParents.set(child, node.type || '')\n recordParents(child)\n })\n recordParents(md_tree)\n\n // second stage - make Universal AST nodes\n const uast = []\n const res = toAny({ processor: 1 })\n .use({\n '*:*': (writer, processor) => (node, ctx, interator) => {\n console.warn('[Podlite:md2ast]- unhandled MD node')\n console.warn(JSON.stringify(node, null, 2))\n if (node.children) interator(node.children, { ...ctx })\n },\n })\n .use({\n ':root': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkRootBlock({}, interator(children, ctx))\n },\n ':math': (writer, processor) => (node, ctx, interator) => {\n const { value, children, position, ...attr } = node\n return mkFormulaBlock({ value, location: applyLineOffset(position) })\n },\n ':inlineMath': (writer, processor) => (node, ctx, interator) => {\n const { value, children, position, ...attr } = node\n return mkMarkupCodeF(value)\n },\n\n ':heading': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n const block = mkBlock(\n { type: 'block', level: node.depth, name: 'head', location: applyLineOffset(position) },\n interator(children, ctx),\n )\n // a link to a heading is written against its text, so a generated id points at nothing\n const id = headingId(getTextContentFromNode(block))\n // a heading holding only an image has no text to be named by, and an empty id would\n // repeat across every such heading\n return id ? { ...block, id } : block\n },\n ':text': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return node.value\n // return mkNode({type:\"text\", value: node.value})\n },\n ':list': (writer, processor) => (node, ctx, interator) => {\n const savedListLevel = ctx['listLevel'] || 0\n const { children, position, ...attr } = node\n return mkBlock(\n { type: 'list', level: savedListLevel + 1, list: node.ordered ? 'ordered' : 'itemized' },\n interator(children, { ...ctx, listLevel: savedListLevel + 1, ordered: node.ordered }),\n )\n },\n ':listItem': (writer, processor) => (node, ctx, interator) => {\n const savedListLevel = ctx['listLevel'] || 0\n const { children, position, checked, ...attr } = node\n const blockAttrs: any = {\n name: 'item',\n type: 'block',\n level: ctx['listLevel'],\n location: applyLineOffset(position),\n }\n\n if (checked !== null && checked !== undefined) {\n blockAttrs.checked = checked\n blockAttrs.config = [{ name: 'checked', value: checked, type: 'boolean' }]\n }\n\n return mkBlock(blockAttrs, interator(children, { ...ctx, listLevel: savedListLevel, ordered: node.ordered }))\n },\n ':paragraph': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkBlock(\n { type: 'para', location: applyLineOffset(position), text: 'text', margin: '' },\n interator(children, { ...ctx }),\n )\n },\n ':linkReference': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n const definition = definitionMap[attr.identifier]\n const meta = definition?.url || ''\n return mkFomattingCodeL({ meta }, interator(children, { ...ctx }))\n },\n ':definition': (writer, processor) => (node, ctx, interator) => {\n return null\n },\n ':inlineCode': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCode({ name: 'C' }, [node.value])\n },\n ':strong': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCode({ name: 'B' }, interator(children, { ...ctx }))\n },\n ':emphasis': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCode({ name: 'I' }, interator(children, { ...ctx }))\n },\n ':link': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCodeL({ meta: node.url }, interator(children, { ...ctx }))\n },\n ':html': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n const markdownHtml = inlineParents.includes(htmlParents.get(node)) ? 'inline' : 'block'\n return mkBlock({ type: 'block', name: 'Html', markdownHtml, location: applyLineOffset(position) }, [\n mkVerbatim(node.value),\n ])\n },\n ':code': (writer, processor) => (node, ctx, interator) => {\n const { children, position, lang, meta, ...attr } = node\n if (lang === 'mermaid' || lang === 'diagram') {\n return mkBlock({ type: 'block', name: 'Mermaid', config: [], location: applyLineOffset(position) }, [\n mkVerbatim(node.value),\n ])\n }\n let config = []\n if (lang) {\n config.push({ name: 'lang', value: lang, type: 'string' })\n }\n if (meta) {\n config.push(...parseAttributes(meta))\n }\n return mkBlock({ type: 'block', name: 'code', config, location: applyLineOffset(position) }, [\n mkVerbatim(node.value),\n ])\n },\n ':image':\n (writer, processor) =>\n (node, ctx, interator): BlockImage => {\n const { title, alt, url, position, ...attr } = node\n let config = []\n // the title of a picture is the hint a reader shows over it, not a caption\n const image = mkImage(url, alt)\n if (typeof title === 'string') image.title = title\n return mkBlock({ type: 'block', name: 'Image', config, location: applyLineOffset(position) }, [image])\n },\n // a rule between blocks is the boundary of Podlite\n ':thematicBreak': (writer, processor) => (node, ctx, interator) => {\n const { position } = node\n return mkBlock({ type: 'block', name: 'boundary', config: [], location: applyLineOffset(position) }, [])\n },\n ':blockquote': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkBlock({ name: 'nested', location: applyLineOffset(position) }, interator(children, { ...ctx }))\n },\n //table section\n ':table': (writer, processor) => (node, ctx, interator) => {\n const { children, position, align, ...attr } = node\n return mkBlock(\n { name: 'table', location: applyLineOffset(position), align },\n interator(children, { ...ctx, isHeaderUsed: 0 }),\n )\n },\n ':tableRow': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n const isHeaderUsed = ctx.isHeaderUsed++\n const blockAttrs: Record<string, unknown> = {\n name: 'row',\n location: applyLineOffset(position),\n }\n if (!isHeaderUsed) {\n blockAttrs.config = [{ name: 'header', value: true, type: 'boolean' }]\n }\n return mkBlock(blockAttrs, interator(children, { ...ctx }))\n },\n ':tableCell': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkBlock({ name: 'cell', location: applyLineOffset(position) }, interator(children, { ...ctx }))\n },\n ':delete': (writer, processor) => (node, ctx, interator) => {\n const { children, position, ...attr } = node\n return mkFomattingCodeO(interator(children, { ...ctx }))\n },\n // a hard line break is a line break S<> keeps\n ':break': (writer, processor) => (node, ctx, interator) => {\n return mkFomattingCode({ name: 'S' }, ['\\n'])\n },\n })\n .run(md_tree)\n // a =markdown block hands over its verbatim node: the keys are fingerprinted from the\n // text the reader parsed\n const tree = assignHeadingKeys(\n res.interator,\n typeof src === 'string' ? src : (src as { value?: string })?.value ?? '',\n )\n markSource(tree)\n return tree\n}\n\nconst inlineParents = ['paragraph', 'heading', 'tableCell', 'strong', 'emphasis', 'delete', 'link', 'linkReference']\n\n// Every block made here is marked as coming from Markdown: HTML of Markdown is a block\n// named Html as an author's =Html is, and a writer must keep the first raw.\n// The walk goes into every node, since HTML stands in paragraphs, lists and codes too.\nconst markSource = (node: unknown): void => {\n if (Array.isArray(node)) return node.forEach(markSource)\n if (!node || typeof node !== 'object') return\n const item = node as { type?: string; content?: unknown; sourceFormat?: string }\n if (item.type === 'block') item.sourceFormat = 'markdown'\n if (item.content) markSource(item.content)\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAW,mBAA4B;;;ACAhD,SAAS,eAAe;AACxB,OAAO,cAAc;AACrB,OAAO,eAAe;AACtB,OAAO,gBAAgB;AAEvB;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAG1B,IAAM,SAAS,CAAC,KAAa,EAAE,WAAW,IAAgB,EAAE,YAAY,EAAE,MAAe;AA1BhG;AA4BE,QAAM,UAAU,QAAQ,EAAE,IAAI,QAAQ,EAAE,IAAI,SAAS,EAAE,IAAI,UAAU,EAAE,MAAM,GAAG;AAGhF,MAAI,gBAAgB,CAAC;AACrB,QAAM,mBACJ,CAAC,WACD,CAAC,aAAiC;AAChC,UAAM,EAAE,OAAO,IAAI,IAAI;AACvB,WAAO;AAAA,MACL,OAAO;AAAA,QACL,GAAG;AAAA,QACH,MAAM,MAAM,OAAO;AAAA,MACrB;AAAA,MACA,KAAK;AAAA,QACH,GAAG;AAAA,QACH,MAAM,IAAI,OAAO;AAAA,MACnB;AAAA,IACF;AAAA,EACF,GACA,UAAU;AACZ,QAAM,EAAE,WAAW,EAAE,CAAC,EACnB,IAAI;AAAA,IACH,OAAO,CAAC,QAAQ,cAAc,CAAC,MAAM,KAAK,cAAc;AACtD,UAAI,KAAK;AAAU,kBAAU,KAAK,UAAU,EAAE,GAAG,IAAI,CAAC;AAAA,IACxD;AAAA,EACF,CAAC,EACA,IAAI;AAAA,IACH,eAAe,CAAC,QAAQ,cAAc,CAAC,MAAM,KAAK,cAAc;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O,IAAM,SAAiB;AAAA,EAC5B,OAAO,CAAC,GAAG,cAAc,CAAC,MAAM,QAAQ;AACtC,QAAI,OAAO,SAAS,YAAY,UAAU,QAAQ,aAAa,QAAQ,KAAK,SAAS,SAAS;AAC5F,YAAM,UAAU,KAAK,QAAQ;AAC7B,UAAI,WAAW,OAAO,YAAY,YAAY,cAAc,QAAQ,WAAW,SAAS;AACtF,cAAM,aAAa,KAAK,SAAS,MAAM;AACvC,eAAO,EAAE,GAAG,MAAM,SAAS,OAAO,SAAS,EAAE,WAAW,CAAC,EAAE;AAAA,MAC7D;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,OAAO,YAAU;AACf,WAAO;AAAA,EACT;AACF;AACO,IAAM,iBAA0B;AAAA,EACrC,UAAU;AAAA,EACV,UAAU;AACZ;AAGA,IAAO,cAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podlite/markdown",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.74",
|
|
4
4
|
"description": "Bidirectional Markdown support for Podlite — parse .md files, embed Markdown blocks",
|
|
5
5
|
"main": "./lib/index.cjs",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"compatibility"
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@podlite/schema": "0.0.
|
|
64
|
+
"@podlite/schema": "0.0.81",
|
|
65
65
|
"react": "^16.0.0 || ^17.0.0 || ^18",
|
|
66
66
|
"react-dom": "^16.0.0 || ^17.0.0 || ^18",
|
|
67
67
|
"react-is": "^18.0.0",
|