markdown-codec 1.3.31 → 1.4.1

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.
Files changed (71) hide show
  1. package/dist/ast/ast.cjs +2 -1
  2. package/dist/ast/ast.d.cts +2 -2
  3. package/dist/ast/ast.d.ts +2 -2
  4. package/dist/ast/ast.js +2 -1
  5. package/dist/{ast-BXYwy08e.d.cts → ast-DbjiuYr8.d.cts} +13 -3
  6. package/dist/{ast-BXYwy08e.d.ts → ast-DbjiuYr8.d.ts} +13 -3
  7. package/dist/block/block.cjs +44 -4
  8. package/dist/block/block.d.cts +3 -3
  9. package/dist/block/block.d.ts +3 -3
  10. package/dist/block/block.js +44 -4
  11. package/dist/block/definitions.d.cts +1 -1
  12. package/dist/block/definitions.d.ts +1 -1
  13. package/dist/block/node.cjs +1 -1
  14. package/dist/block/node.d.cts +2 -2
  15. package/dist/block/node.d.ts +2 -2
  16. package/dist/block/node.js +1 -1
  17. package/dist/block/table.d.cts +1 -1
  18. package/dist/block/table.d.ts +1 -1
  19. package/dist/codec.d.cts +68 -5
  20. package/dist/codec.d.ts +68 -5
  21. package/dist/diagnostics/diagnostics.cjs +3 -0
  22. package/dist/diagnostics/diagnostics.d.cts +1 -1
  23. package/dist/diagnostics/diagnostics.d.ts +1 -1
  24. package/dist/diagnostics/diagnostics.js +3 -0
  25. package/dist/{diagnostics-DmuWc7d8.d.cts → diagnostics-B72W0P_E.d.cts} +3 -0
  26. package/dist/{diagnostics-DmuWc7d8.d.ts → diagnostics-B72W0P_E.d.ts} +3 -0
  27. package/dist/emit/emit.cjs +3 -1
  28. package/dist/emit/emit.js +4 -2
  29. package/dist/emit/inline.cjs +2 -3
  30. package/dist/emit/inline.d.cts +1 -1
  31. package/dist/emit/inline.d.ts +1 -1
  32. package/dist/emit/inline.js +2 -3
  33. package/dist/emit/table.d.cts +1 -1
  34. package/dist/emit/table.d.ts +1 -1
  35. package/dist/html/render.cjs +6 -0
  36. package/dist/html/render.d.cts +1 -1
  37. package/dist/html/render.d.ts +1 -1
  38. package/dist/html/render.js +6 -0
  39. package/dist/index.d.cts +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/inline/inline.cjs +16 -0
  42. package/dist/inline/inline.d.cts +1 -1
  43. package/dist/inline/inline.d.ts +1 -1
  44. package/dist/inline/inline.js +16 -0
  45. package/dist/inline/math.cjs +10 -0
  46. package/dist/inline/math.d.cts +4 -0
  47. package/dist/inline/math.d.ts +4 -0
  48. package/dist/inline/math.js +9 -0
  49. package/dist/inline/node.d.cts +1 -1
  50. package/dist/inline/node.d.ts +1 -1
  51. package/dist/{inline-B50cM6cn.d.ts → inline-TuBQ2TUr.d.ts} +1 -1
  52. package/dist/{inline-C9YEGDV5.d.cts → inline-uVHJ5xzT.d.cts} +1 -1
  53. package/dist/lower/front-matter.d.cts +1 -1
  54. package/dist/lower/front-matter.d.ts +1 -1
  55. package/dist/lower/inline.cjs +7 -0
  56. package/dist/lower/inline.d.cts +2 -2
  57. package/dist/lower/inline.d.ts +2 -2
  58. package/dist/lower/inline.js +8 -1
  59. package/dist/lower/lower.cjs +14 -0
  60. package/dist/lower/lower.js +15 -1
  61. package/dist/lower/table.d.cts +1 -1
  62. package/dist/lower/table.d.ts +1 -1
  63. package/dist/options/options.d.cts +1 -1
  64. package/dist/options/options.d.ts +1 -1
  65. package/dist/read.d.cts +1 -1
  66. package/dist/read.d.ts +1 -1
  67. package/dist/shared/style-constants.cjs +4 -0
  68. package/dist/shared/style-constants.d.cts +3 -1
  69. package/dist/shared/style-constants.d.ts +3 -1
  70. package/dist/shared/style-constants.js +3 -1
  71. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
- import { g as MarkdownInlineNode } from "../ast-BXYwy08e.cjs";
2
- import { i as MarkdownDiagnosticSink } from "../diagnostics-DmuWc7d8.cjs";
1
+ import { g as MarkdownInlineNode } from "../ast-DbjiuYr8.cjs";
2
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-B72W0P_E.cjs";
3
3
  import { ContentRun } from "document-schema.js";
4
4
  //#region src/lower/inline.d.ts
5
5
  interface InlineLowerContext {
@@ -1,5 +1,5 @@
1
- import { g as MarkdownInlineNode } from "../ast-BXYwy08e.js";
2
- import { i as MarkdownDiagnosticSink } from "../diagnostics-DmuWc7d8.js";
1
+ import { g as MarkdownInlineNode } from "../ast-DbjiuYr8.js";
2
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-B72W0P_E.js";
3
3
  import { ContentRun } from "document-schema.js";
4
4
  //#region src/lower/inline.d.ts
5
5
  interface InlineLowerContext {
@@ -1,5 +1,5 @@
1
1
  import { MarkdownDiagnosticCodes } from "../diagnostics/diagnostics.js";
2
- import { MONOSPACE_FONT_FAMILY } from "../shared/style-constants.js";
2
+ import { MATH_INLINE_FONT_MARKER, MONOSPACE_FONT_FAMILY } from "../shared/style-constants.js";
3
3
  //#region src/lower/inline.ts
4
4
  function buildRun(text, style, fontFamily) {
5
5
  return {
@@ -45,6 +45,13 @@ function lowerInlineNode(node, style, context) {
45
45
  message: "inline raw HTML was preserved as literal text; it will not be rendered as HTML by any consumer of the resulting ContentDocument"
46
46
  });
47
47
  return node.literal.length === 0 ? [] : [buildRun(node.literal, style)];
48
+ case "mathInline":
49
+ context.sink({
50
+ code: MarkdownDiagnosticCodes.MATH_INLINE_PRESERVED_AS_TEXT,
51
+ severity: "info",
52
+ message: "inline math (\\( \\)) was preserved as literal raw LaTeX text; it is not parsed as LaTeX or converted to MathML by this package"
53
+ });
54
+ return [buildRun(node.literal, style, MATH_INLINE_FONT_MARKER)];
48
55
  case "autolink": {
49
56
  const destination = node.email ? `mailto:${node.destination}` : node.destination;
50
57
  return [buildRun(node.destination, {
@@ -132,6 +132,19 @@ function lowerHtmlBlock(node, context) {
132
132
  styleId: require_shared_style_constants.HTML_PREFORMATTED_STYLE_ID
133
133
  }, context)];
134
134
  }
135
+ function lowerMathBlock(node, context) {
136
+ context.sink({
137
+ code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.MATH_BLOCK_PRESERVED_AS_TEXT,
138
+ severity: "info",
139
+ message: "block math ($$...$$) was preserved as literal raw LaTeX text (styleId \"MathBlock\"); it is not parsed as LaTeX or converted to MathML by this package"
140
+ });
141
+ const literal = node.literal.replace(/\n$/, "");
142
+ return [decorateParagraph({
143
+ kind: "paragraph",
144
+ runs: literal.length === 0 ? [] : [{ text: literal }],
145
+ styleId: require_shared_style_constants.MATH_BLOCK_STYLE_ID
146
+ }, context)];
147
+ }
135
148
  function lowerBlockquote(node, context, contentWidthPt) {
136
149
  if (context.quoteDepth >= 1) context.sink({
137
150
  code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.BLOCKQUOTE_NESTED_DEPTH,
@@ -225,6 +238,7 @@ function lowerBlock(node, context, contentWidthPt) {
225
238
  case "codeBlock": return lowerCodeBlock(node, context);
226
239
  case "thematicBreak": return lowerThematicBreak(context);
227
240
  case "htmlBlock": return lowerHtmlBlock(node, context);
241
+ case "mathBlock": return lowerMathBlock(node, context);
228
242
  case "table":
229
243
  if (context.list !== void 0) context.sink({
230
244
  code: require_diagnostics_diagnostics.MarkdownDiagnosticCodes.LIST_ITEM_BLOCK_UNLISTED,
@@ -2,7 +2,7 @@ import { DEFAULT_MARGINS } from "../defaults/defaults.js";
2
2
  import { MarkdownDiagnosticCodes, MarkdownInputTooLargeError, NOOP_MARKDOWN_DIAGNOSTIC_SINK } from "../diagnostics/diagnostics.js";
3
3
  import { parseMarkdown } from "../block/block.js";
4
4
  import { createNumIdMintState, mintListNumId, mintedListType } from "../shared/list-id.js";
5
- import { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, QUOTE_STYLE_ID, headingStyleId } from "../shared/style-constants.js";
5
+ import { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MATH_BLOCK_STYLE_ID, QUOTE_STYLE_ID, headingStyleId } from "../shared/style-constants.js";
6
6
  import { extractFrontMatter } from "./front-matter.js";
7
7
  import { resolveMarkdownImage } from "./image.js";
8
8
  import { lowerCodeBlockRun, lowerInlineNodes } from "./inline.js";
@@ -131,6 +131,19 @@ function lowerHtmlBlock(node, context) {
131
131
  styleId: HTML_PREFORMATTED_STYLE_ID
132
132
  }, context)];
133
133
  }
134
+ function lowerMathBlock(node, context) {
135
+ context.sink({
136
+ code: MarkdownDiagnosticCodes.MATH_BLOCK_PRESERVED_AS_TEXT,
137
+ severity: "info",
138
+ message: "block math ($$...$$) was preserved as literal raw LaTeX text (styleId \"MathBlock\"); it is not parsed as LaTeX or converted to MathML by this package"
139
+ });
140
+ const literal = node.literal.replace(/\n$/, "");
141
+ return [decorateParagraph({
142
+ kind: "paragraph",
143
+ runs: literal.length === 0 ? [] : [{ text: literal }],
144
+ styleId: MATH_BLOCK_STYLE_ID
145
+ }, context)];
146
+ }
134
147
  function lowerBlockquote(node, context, contentWidthPt) {
135
148
  if (context.quoteDepth >= 1) context.sink({
136
149
  code: MarkdownDiagnosticCodes.BLOCKQUOTE_NESTED_DEPTH,
@@ -224,6 +237,7 @@ function lowerBlock(node, context, contentWidthPt) {
224
237
  case "codeBlock": return lowerCodeBlock(node, context);
225
238
  case "thematicBreak": return lowerThematicBreak(context);
226
239
  case "htmlBlock": return lowerHtmlBlock(node, context);
240
+ case "mathBlock": return lowerMathBlock(node, context);
227
241
  case "table":
228
242
  if (context.list !== void 0) context.sink({
229
243
  code: MarkdownDiagnosticCodes.LIST_ITEM_BLOCK_UNLISTED,
@@ -1,4 +1,4 @@
1
- import { j as MarkdownTableNode } from "../ast-BXYwy08e.cjs";
1
+ import { N as MarkdownTableNode } from "../ast-DbjiuYr8.cjs";
2
2
  import { InlineLowerContext } from "./inline.cjs";
3
3
  import { ContentTable } from "document-schema.js";
4
4
  //#region src/lower/table.d.ts
@@ -1,4 +1,4 @@
1
- import { j as MarkdownTableNode } from "../ast-BXYwy08e.js";
1
+ import { N as MarkdownTableNode } from "../ast-DbjiuYr8.js";
2
2
  import { InlineLowerContext } from "./inline.js";
3
3
  import { ContentTable } from "document-schema.js";
4
4
  //#region src/lower/table.d.ts
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-DmuWc7d8.cjs";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-B72W0P_E.cjs";
2
2
  import { n as MarkdownImageResolver } from "../image-C4KYmz_L.cjs";
3
3
  import { Margins, PageSize } from "document-schema.js";
4
4
  //#region src/options/options.d.ts
@@ -1,4 +1,4 @@
1
- import { i as MarkdownDiagnosticSink } from "../diagnostics-DmuWc7d8.js";
1
+ import { i as MarkdownDiagnosticSink } from "../diagnostics-B72W0P_E.js";
2
2
  import { n as MarkdownImageResolver } from "../image-Cm3hT5PS.js";
3
3
  import { Margins, PageSize } from "document-schema.js";
4
4
  //#region src/options/options.d.ts
package/dist/read.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as MarkdownDiagnostic } from "./diagnostics-DmuWc7d8.cjs";
1
+ import { t as MarkdownDiagnostic } from "./diagnostics-B72W0P_E.cjs";
2
2
  import { ReadMarkdownOptions } from "./options/options.cjs";
3
3
  import { ContentDocument } from "document-schema.js";
4
4
  //#region src/read.d.ts
package/dist/read.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as MarkdownDiagnostic } from "./diagnostics-DmuWc7d8.js";
1
+ import { t as MarkdownDiagnostic } from "./diagnostics-B72W0P_E.js";
2
2
  import { ReadMarkdownOptions } from "./options/options.js";
3
3
  import { ContentDocument } from "document-schema.js";
4
4
  //#region src/read.d.ts
@@ -16,7 +16,9 @@ const QUOTE_STYLE_ID = "Quote";
16
16
  const CODE_BLOCK_STYLE_ID = "CodeBlock";
17
17
  const HORIZONTAL_RULE_STYLE_ID = "HorizontalRule";
18
18
  const HTML_PREFORMATTED_STYLE_ID = "HTMLPreformatted";
19
+ const MATH_BLOCK_STYLE_ID = "MathBlock";
19
20
  const MONOSPACE_FONT_FAMILY = "Courier New";
21
+ const MATH_INLINE_FONT_MARKER = "Cambria Math";
20
22
  const QUOTE_INDENT_PT = 36;
21
23
  const TASK_CHECKBOX_UNCHECKED = "☐";
22
24
  const TASK_CHECKBOX_CHECKED = "☒";
@@ -24,6 +26,8 @@ const TASK_CHECKBOX_CHECKED = "☒";
24
26
  exports.CODE_BLOCK_STYLE_ID = CODE_BLOCK_STYLE_ID;
25
27
  exports.HORIZONTAL_RULE_STYLE_ID = HORIZONTAL_RULE_STYLE_ID;
26
28
  exports.HTML_PREFORMATTED_STYLE_ID = HTML_PREFORMATTED_STYLE_ID;
29
+ exports.MATH_BLOCK_STYLE_ID = MATH_BLOCK_STYLE_ID;
30
+ exports.MATH_INLINE_FONT_MARKER = MATH_INLINE_FONT_MARKER;
27
31
  exports.MAX_HEADING_STYLE_LEVEL = MAX_HEADING_STYLE_LEVEL;
28
32
  exports.MONOSPACE_FONT_FAMILY = MONOSPACE_FONT_FAMILY;
29
33
  exports.QUOTE_INDENT_PT = QUOTE_INDENT_PT;
@@ -6,9 +6,11 @@ declare const QUOTE_STYLE_ID = "Quote";
6
6
  declare const CODE_BLOCK_STYLE_ID = "CodeBlock";
7
7
  declare const HORIZONTAL_RULE_STYLE_ID = "HorizontalRule";
8
8
  declare const HTML_PREFORMATTED_STYLE_ID = "HTMLPreformatted";
9
+ declare const MATH_BLOCK_STYLE_ID = "MathBlock";
9
10
  declare const MONOSPACE_FONT_FAMILY = "Courier New";
11
+ declare const MATH_INLINE_FONT_MARKER = "Cambria Math";
10
12
  declare const QUOTE_INDENT_PT = 36;
11
13
  declare const TASK_CHECKBOX_UNCHECKED = "☐";
12
14
  declare const TASK_CHECKBOX_CHECKED = "☒";
13
15
  //#endregion
14
- export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, TASK_CHECKBOX_CHECKED, TASK_CHECKBOX_UNCHECKED, headingStyleId, parseHeadingStyleId };
16
+ export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MATH_BLOCK_STYLE_ID, MATH_INLINE_FONT_MARKER, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, TASK_CHECKBOX_CHECKED, TASK_CHECKBOX_UNCHECKED, headingStyleId, parseHeadingStyleId };
@@ -6,9 +6,11 @@ declare const QUOTE_STYLE_ID = "Quote";
6
6
  declare const CODE_BLOCK_STYLE_ID = "CodeBlock";
7
7
  declare const HORIZONTAL_RULE_STYLE_ID = "HorizontalRule";
8
8
  declare const HTML_PREFORMATTED_STYLE_ID = "HTMLPreformatted";
9
+ declare const MATH_BLOCK_STYLE_ID = "MathBlock";
9
10
  declare const MONOSPACE_FONT_FAMILY = "Courier New";
11
+ declare const MATH_INLINE_FONT_MARKER = "Cambria Math";
10
12
  declare const QUOTE_INDENT_PT = 36;
11
13
  declare const TASK_CHECKBOX_UNCHECKED = "☐";
12
14
  declare const TASK_CHECKBOX_CHECKED = "☒";
13
15
  //#endregion
14
- export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, TASK_CHECKBOX_CHECKED, TASK_CHECKBOX_UNCHECKED, headingStyleId, parseHeadingStyleId };
16
+ export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MATH_BLOCK_STYLE_ID, MATH_INLINE_FONT_MARKER, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, TASK_CHECKBOX_CHECKED, TASK_CHECKBOX_UNCHECKED, headingStyleId, parseHeadingStyleId };
@@ -15,9 +15,11 @@ const QUOTE_STYLE_ID = "Quote";
15
15
  const CODE_BLOCK_STYLE_ID = "CodeBlock";
16
16
  const HORIZONTAL_RULE_STYLE_ID = "HorizontalRule";
17
17
  const HTML_PREFORMATTED_STYLE_ID = "HTMLPreformatted";
18
+ const MATH_BLOCK_STYLE_ID = "MathBlock";
18
19
  const MONOSPACE_FONT_FAMILY = "Courier New";
20
+ const MATH_INLINE_FONT_MARKER = "Cambria Math";
19
21
  const QUOTE_INDENT_PT = 36;
20
22
  const TASK_CHECKBOX_UNCHECKED = "☐";
21
23
  const TASK_CHECKBOX_CHECKED = "☒";
22
24
  //#endregion
23
- export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, TASK_CHECKBOX_CHECKED, TASK_CHECKBOX_UNCHECKED, headingStyleId, parseHeadingStyleId };
25
+ export { CODE_BLOCK_STYLE_ID, HORIZONTAL_RULE_STYLE_ID, HTML_PREFORMATTED_STYLE_ID, MATH_BLOCK_STYLE_ID, MATH_INLINE_FONT_MARKER, MAX_HEADING_STYLE_LEVEL, MONOSPACE_FONT_FAMILY, QUOTE_INDENT_PT, QUOTE_STYLE_ID, TASK_CHECKBOX_CHECKED, TASK_CHECKBOX_UNCHECKED, headingStyleId, parseHeadingStyleId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-codec",
3
- "version": "1.3.31",
3
+ "version": "1.4.1",
4
4
  "description": "Hand-written CommonMark+GFM <-> ContentDocument codec, built on document-schema.js",
5
5
  "type": "module",
6
6
  "repository": {
@@ -79,7 +79,7 @@
79
79
  "license": "MIT",
80
80
  "packageManager": "pnpm@11.6.0",
81
81
  "dependencies": {
82
- "document-schema.js": "^2.7.16",
82
+ "document-schema.js": "^3.0.0",
83
83
  "zod": "^4.4.3"
84
84
  },
85
85
  "devDependencies": {