tsondb 0.8.5 → 0.9.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/dist/src/shared/utils/markdown.js +2 -2
- package/dist/src/web/utils/BlockMarkdown.d.ts +1 -0
- package/dist/src/web/utils/BlockMarkdown.js +8 -5
- package/dist/src/web/utils/InlineMarkdown.js +4 -2
- package/dist/src/web/utils/Markdown.d.ts +1 -0
- package/dist/src/web/utils/Markdown.js +2 -2
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ const boldWithItalicRule = {
|
|
|
24
24
|
}),
|
|
25
25
|
};
|
|
26
26
|
const italicWithBoldRule = {
|
|
27
|
-
pattern: /(?<![\\*]|[
|
|
27
|
+
pattern: /(?<![\\*]|[^\\]\*.*)\*(?=\*\*|[^*])([^*]*?\*\*[^*]*?\*\*[^*]*?)(?<=[^\\*]|[^\\]\*\*)\*(?!\*)/,
|
|
28
28
|
map: (result, parseInside) => ({
|
|
29
29
|
kind: "italic",
|
|
30
30
|
content: parseInside(result[1] ?? ""),
|
|
@@ -494,7 +494,7 @@ const addIndentationToSyntax = (nodes, nextUpperNode) => nodes.reduce((accNodes,
|
|
|
494
494
|
}
|
|
495
495
|
}, []);
|
|
496
496
|
const footnoteRule = {
|
|
497
|
-
pattern: /^\[\^([a-zA-Z0-9
|
|
497
|
+
pattern: /^\[\^([a-zA-Z0-9]+?)\]: (.+?(?:\n(?: {2}.+)?)*)(\n{2,}|\s*$)/,
|
|
498
498
|
map: ([_match, label = "", content = "", _trailingWhitespace]) => ({
|
|
499
499
|
kind: "footnote",
|
|
500
500
|
label: label,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { createElement as _createElement } from "preact";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
3
|
import { checkTableRowsAreSections, } from "../../shared/utils/markdown.js";
|
|
3
4
|
import { assertExhaustive } from "../../shared/utils/typeSafety.js";
|
|
4
5
|
import { InlineMarkdown } from "./InlineMarkdown.js";
|
|
5
|
-
export const BlockMarkdown = ({ node, outerHeadingLevel = 0, insertBefore, }) => {
|
|
6
|
+
export const BlockMarkdown = ({ node, outerHeadingLevel = 0, insertBefore, footnoteLabelSuffix = ")", }) => {
|
|
7
|
+
const inheritableProps = { outerHeadingLevel, footnoteLabelSuffix };
|
|
6
8
|
switch (node.kind) {
|
|
7
9
|
case "paragraph":
|
|
8
10
|
return (_jsxs("p", { children: [insertBefore, node.content.map((inline, ii) => (_jsx(InlineMarkdown, { node: inline }, ii)))] }));
|
|
@@ -19,13 +21,14 @@ export const BlockMarkdown = ({ node, outerHeadingLevel = 0, insertBefore, }) =>
|
|
|
19
21
|
case "table":
|
|
20
22
|
return (_jsxs(_Fragment, { children: [insertBefore, _jsxs("table", { children: [node.caption !== undefined && (_jsx("caption", { children: node.caption.map((inline, ci) => (_jsx(InlineMarkdown, { node: inline }, ci))) })), _jsx("thead", { children: _jsx(TableRow, { columns: node.columns, cells: node.header, cellType: "th" }) }), checkTableRowsAreSections(node.rows) ? (node.rows.map((section, si) => (_jsxs("tbody", { children: [section.header && (_jsx(TableRow, { columns: node.columns, cells: section.header, cellType: "th" })), section.rows.map((row, ri) => (_jsx(TableRow, { columns: node.columns, cells: row.cells }, ri)))] }, si)))) : (_jsx("tbody", { children: node.rows.map((row, ri) => (_jsx(TableRow, { columns: node.columns, cells: row.cells }, ri))) }))] })] }));
|
|
21
23
|
case "container":
|
|
22
|
-
return (_jsxs("div", { class: node.name, children: [insertBefore, node.content.map((childNode, i) => (
|
|
24
|
+
return (_jsxs("div", { class: node.name, children: [insertBefore, node.content.map((childNode, i) => (_createElement(BlockMarkdown, { ...inheritableProps, key: i, node: childNode })))] }));
|
|
23
25
|
case "footnote": {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
+
const isNumeric = /^\d+$/.test(node.label);
|
|
27
|
+
const label = (_jsxs(_Fragment, { children: [_jsxs("span", { class: "footnote-label" + (isNumeric ? " footnote-label--numeric" : ""), "data-reference": node.label, children: [node.label, footnoteLabelSuffix] }), " "] }));
|
|
28
|
+
return (_jsxs("div", { role: "note", children: [insertBefore, node.content.map((n, i) => (_createElement(BlockMarkdown, { ...inheritableProps, key: i, node: n, insertBefore: label })))] }));
|
|
26
29
|
}
|
|
27
30
|
case "definitionList":
|
|
28
|
-
return (_jsxs(_Fragment, { children: [insertBefore, _jsx("dl", { children: node.content.map((item, ii) => (_jsxs("div", { children: [item.terms.map((term, ti) => (_jsx("dt", { children: term.map((inline, iii) => (_jsx(InlineMarkdown, { node: inline }, iii))) }, ti))), item.definitions.map((definition, di) => (_jsx("dd", { children: definition.map((n, i) => (
|
|
31
|
+
return (_jsxs(_Fragment, { children: [insertBefore, _jsx("dl", { children: node.content.map((item, ii) => (_jsxs("div", { children: [item.terms.map((term, ti) => (_jsx("dt", { children: term.map((inline, iii) => (_jsx(InlineMarkdown, { node: inline }, iii))) }, ti))), item.definitions.map((definition, di) => (_jsx("dd", { children: definition.map((n, i) => (_createElement(BlockMarkdown, { ...inheritableProps, key: i, node: n }))) }, di)))] }, ii))) })] }));
|
|
29
32
|
default:
|
|
30
33
|
return assertExhaustive(node);
|
|
31
34
|
}
|
|
@@ -22,8 +22,10 @@ export const InlineMarkdown = ({ node }) => {
|
|
|
22
22
|
const trailingNodes = node.content.slice(attributesEnd);
|
|
23
23
|
return (_jsxs("span", { class: "attributed", ...Object.fromEntries(Object.entries(node.attributes).map(([k, v]) => [`data-${k}`, v.toString()])), children: [leadingNodes.map((inline, i) => (_jsx(InlineMarkdown, { node: inline }, i))), Array.from({ length: count }, (_, i) => (_jsxs(Fragment, { children: [_jsx("span", { class: "attributed__name", children: _jsx(InlineMarkdown, { node: attributes[i * 4] ?? emptyNode }) }), _jsx("span", { class: "attributed__separator", children: _jsx(InlineMarkdown, { node: attributes[i * 4 + 1] ?? emptyNode }) }), _jsx("span", { class: "attributed__value", children: _jsx(InlineMarkdown, { node: attributes[i * 4 + 2] ?? emptyNode }) }), i < count - 1 && (_jsx("span", { class: "attributed__separator", children: _jsx(InlineMarkdown, { node: attributes[i * 4 + 3] ?? emptyNode }) }))] }, `attr-${(i + 1).toString()}`))), trailingNodes.map((inline, i) => (_jsx(InlineMarkdown, { node: inline }, i)))] }));
|
|
24
24
|
}
|
|
25
|
-
case "footnoteRef":
|
|
26
|
-
|
|
25
|
+
case "footnoteRef": {
|
|
26
|
+
const isNumeric = /^\d+$/.test(node.label);
|
|
27
|
+
return (_jsx("sup", { class: "footnote-ref" + (isNumeric ? " footnote-ref--numeric" : ""), "data-reference": node.label, children: node.label }));
|
|
28
|
+
}
|
|
27
29
|
case "text":
|
|
28
30
|
return node.content;
|
|
29
31
|
default:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
2
|
import { parseBlockMarkdown } from "../../shared/utils/markdown.js";
|
|
3
3
|
import { BlockMarkdown } from "./BlockMarkdown.js";
|
|
4
|
-
export const Markdown = ({ class: className, string, outerHeadingLevel, }) => {
|
|
4
|
+
export const Markdown = ({ class: className, string, outerHeadingLevel, footnoteLabelSuffix, }) => {
|
|
5
5
|
const blocks = parseBlockMarkdown(string);
|
|
6
|
-
const blockElements = blocks.map((block, i) => (_jsx(BlockMarkdown, { node: block, outerHeadingLevel: outerHeadingLevel }, `md-block-${i.toString()}`)));
|
|
6
|
+
const blockElements = blocks.map((block, i) => (_jsx(BlockMarkdown, { node: block, outerHeadingLevel: outerHeadingLevel, footnoteLabelSuffix: footnoteLabelSuffix }, `md-block-${i.toString()}`)));
|
|
7
7
|
if (className) {
|
|
8
8
|
return _jsx("div", { class: className, children: blockElements });
|
|
9
9
|
}
|