tsondb 0.8.5 → 0.10.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.
@@ -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*]+?)\]: (.+?(?:\n(?: {2}.+)?)*)(\n{2,}|\s*$)/,
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,
@@ -4,6 +4,7 @@ type Props = {
4
4
  node: BlockMarkdownNode;
5
5
  outerHeadingLevel?: number;
6
6
  insertBefore?: preact.ComponentChildren;
7
+ footnoteLabelSuffix?: string;
7
8
  };
8
9
  export declare const BlockMarkdown: FunctionalComponent<Props>;
9
10
  export {};
@@ -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) => (_jsx(BlockMarkdown, { node: childNode, outerHeadingLevel: outerHeadingLevel }, 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 label = (_jsxs(_Fragment, { children: [_jsxs("span", { class: "footnote-label", children: [node.label, /^\*+$/.test(node.label) ? ")" : ":"] }), " "] }));
25
- return (_jsxs("div", { role: "note", children: [insertBefore, node.content.map((n, i) => (_jsx(BlockMarkdown, { node: n, outerHeadingLevel: outerHeadingLevel, insertBefore: label }, i)))] }));
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, style: { "--label": isNumeric ? Number.parseInt(node.label) : node.label }, children: [_jsx("span", { class: "footnote-label", children: node.label }), footnoteLabelSuffix] }), " "] }));
28
+ return (_jsxs("div", { role: "note", class: "footnote", 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) => (_jsx(BlockMarkdown, { node: n, outerHeadingLevel: outerHeadingLevel }, i))) }, di)))] }, ii))) })] }));
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
- return /^\*+$/.test(node.label) ? (_jsx("span", { class: "footnote-ref", children: node.label })) : (_jsx("sup", { class: "footnote-ref", children: node.label }));
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, style: { "--label": isNumeric ? Number.parseInt(node.label) : node.label }, children: _jsx("span", { class: "footnote-label", children: node.label }) }));
28
+ }
27
29
  case "text":
28
30
  return node.content;
29
31
  default:
@@ -3,6 +3,7 @@ type Props = {
3
3
  class?: string;
4
4
  string: string;
5
5
  outerHeadingLevel?: number;
6
+ footnoteLabelSuffix?: string;
6
7
  };
7
8
  export declare const Markdown: FunctionalComponent<Props>;
8
9
  export {};
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsondb",
3
- "version": "0.8.5",
3
+ "version": "0.10.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Lukas Obermann",