@owomark/view 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Rendering engine and interactive view layer for OwoMark. Provides the Gold Processor Factory for Markdown → HTML rendering, an incremental preview engine, and a DOM-backed editor view.
4
4
 
5
- Official package: `@owomark/view`. The flat name `owomark-view` is reserved only as a compatibility redirect and should not be used for new installs.
5
+ Install the official package: `@owomark/view`.
6
6
 
7
7
  ## Install
8
8
 
@@ -1100,6 +1100,51 @@ import rehypePrettyCode from "rehype-pretty-code";
1100
1100
  import rehypeStringify from "rehype-stringify";
1101
1101
  import remarkDirective from "remark-directive";
1102
1102
 
1103
+ // src/processor/remark-normalize-standalone-math.ts
1104
+ function getOffset(node, edge) {
1105
+ const value = node?.position?.[edge]?.offset;
1106
+ return typeof value === "number" ? value : null;
1107
+ }
1108
+ function isStandaloneDisplayMathParagraph(node, source) {
1109
+ if (node.type !== "paragraph" || !Array.isArray(node.children) || node.children.length !== 1) {
1110
+ return false;
1111
+ }
1112
+ const onlyChild = node.children[0];
1113
+ if (onlyChild?.type !== "inlineMath") return false;
1114
+ const start = getOffset(node, "start");
1115
+ const end = getOffset(node, "end");
1116
+ if (start == null || end == null) return false;
1117
+ const raw = source.slice(start, end).trim();
1118
+ return /^\$\$(?!\s*$)[\s\S]*?(?<!\\)\$\$$/.test(raw);
1119
+ }
1120
+ function remarkNormalizeStandaloneMath() {
1121
+ return (tree, file) => {
1122
+ const source = typeof file.value === "string" ? file.value : "";
1123
+ if (!source) return;
1124
+ walk2(tree, source);
1125
+ };
1126
+ }
1127
+ function walk2(node, source) {
1128
+ if (!Array.isArray(node.children)) return;
1129
+ node.children = node.children.map((child) => {
1130
+ if (isStandaloneDisplayMathParagraph(child, source)) {
1131
+ const mathChild = child.children[0];
1132
+ return {
1133
+ type: "math",
1134
+ value: mathChild.value ?? "",
1135
+ data: {
1136
+ hName: "code",
1137
+ hProperties: { className: ["language-math", "math-display"] },
1138
+ hChildren: [{ type: "text", value: mathChild.value ?? "" }]
1139
+ },
1140
+ position: child.position
1141
+ };
1142
+ }
1143
+ walk2(child, source);
1144
+ return child;
1145
+ });
1146
+ }
1147
+
1103
1148
  // src/processor/micromark-side-annotation.ts
1104
1149
  var CODE_OPEN_PAREN = 40;
1105
1150
  var CODE_CLOSE_PAREN = 41;
@@ -1475,6 +1520,7 @@ function buildRemarkPlugins(options) {
1475
1520
  ];
1476
1521
  if (enableMath) {
1477
1522
  plugins.push(remarkMath);
1523
+ plugins.push(remarkNormalizeStandaloneMath);
1478
1524
  }
1479
1525
  plugins.push(remarkDirective);
1480
1526
  if (options.mode !== "preview") {
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  rehypeSideAnnotation,
18
18
  remarkConvertSoftBreaksToHardBreaks,
19
19
  remarkSideAnnotation
20
- } from "./chunk-4V3WQMGV.js";
20
+ } from "./chunk-DHRAXGIK.js";
21
21
  import {
22
22
  BlockLayoutMap
23
23
  } from "./chunk-3CKPBCIP.js";
package/dist/static.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  rehypeSideAnnotation,
18
18
  remarkConvertSoftBreaksToHardBreaks,
19
19
  remarkSideAnnotation
20
- } from "./chunk-4V3WQMGV.js";
20
+ } from "./chunk-DHRAXGIK.js";
21
21
  export {
22
22
  Callout,
23
23
  CodeDemo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owomark/view",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Rendering engine, preview engine, DOM view layer, and official base theme for OwoMark.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -97,10 +97,21 @@
97
97
  border: none;
98
98
  border-radius: 0;
99
99
  color: inherit;
100
- font-size: 1em;
100
+ font-size: 1.12em;
101
101
  vertical-align: baseline;
102
102
  }
103
103
 
104
+ .owomark-prose code.language-math.math-display {
105
+ display: block;
106
+ font-family: inherit;
107
+ background-color: transparent;
108
+ padding: 0;
109
+ border: none;
110
+ border-radius: 0;
111
+ color: inherit;
112
+ font-size: 1em;
113
+ }
114
+
104
115
  .owomark-prose pre {
105
116
  background-color: var(--owo-preview-code-block-bg, var(--owo-surface-raised, #f8fafc));
106
117
  padding: var(--owo-preview-code-block-padding, 1rem);