@owomark/view 0.1.2 → 0.1.4
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 +1 -1
- package/dist/{chunk-4V3WQMGV.js → chunk-DHRAXGIK.js} +46 -0
- package/dist/index.js +1 -1
- package/dist/static.js +1 -1
- package/package.json +2 -2
- package/src/theme/preview.css +18 -1
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
|
-
|
|
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
package/dist/static.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owomark/view",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@owomark/core": "^0.1.
|
|
72
|
+
"@owomark/core": "^0.1.4",
|
|
73
73
|
"rehype-katex": "^6.0.3",
|
|
74
74
|
"rehype-pretty-code": "^0.14.1",
|
|
75
75
|
"rehype-slug": "^6.0.0",
|
package/src/theme/preview.css
CHANGED
|
@@ -80,6 +80,12 @@
|
|
|
80
80
|
color: var(--owo-preview-blockquote-text, var(--owo-text-muted, #64748b));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
.owomark-prose hr {
|
|
84
|
+
border: 0;
|
|
85
|
+
border-top: 1px solid var(--owo-preview-divider, var(--owo-border, #e2e8f0));
|
|
86
|
+
margin: var(--owo-preview-hr-margin, 2rem 0);
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
.owomark-prose code {
|
|
84
90
|
font-family: var(--owo-preview-font-mono, var(--owo-font-mono, system-ui, monospace));
|
|
85
91
|
background-color: var(--owo-preview-inline-code-bg, rgba(148, 163, 184, 0.16));
|
|
@@ -97,10 +103,21 @@
|
|
|
97
103
|
border: none;
|
|
98
104
|
border-radius: 0;
|
|
99
105
|
color: inherit;
|
|
100
|
-
font-size:
|
|
106
|
+
font-size: 1.12em;
|
|
101
107
|
vertical-align: baseline;
|
|
102
108
|
}
|
|
103
109
|
|
|
110
|
+
.owomark-prose code.language-math.math-display {
|
|
111
|
+
display: block;
|
|
112
|
+
font-family: inherit;
|
|
113
|
+
background-color: transparent;
|
|
114
|
+
padding: 0;
|
|
115
|
+
border: none;
|
|
116
|
+
border-radius: 0;
|
|
117
|
+
color: inherit;
|
|
118
|
+
font-size: 1em;
|
|
119
|
+
}
|
|
120
|
+
|
|
104
121
|
.owomark-prose pre {
|
|
105
122
|
background-color: var(--owo-preview-code-block-bg, var(--owo-surface-raised, #f8fafc));
|
|
106
123
|
padding: var(--owo-preview-code-block-padding, 1rem);
|