pandoc-glance 0.1.0 → 0.2.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/README.md CHANGED
@@ -42,7 +42,13 @@ pandoc-glance <file> --watch
42
42
  | `-h, --help` | Show help |
43
43
  | `-v, --version` | Show the version |
44
44
 
45
- Automatic format detection recognizes common Markdown extensions (`.md`, `.markdown`, `.mdown`, `.mkd`, `.qmd`, and `.rmd`) and standalone LaTeX (`.tex` and `.latex`). Use `--format` for another extension.
45
+ Automatic format detection recognizes common Markdown extensions (`.md`, `.markdown`, `.mdown`, `.mkd`, `.qmd`, and `.rmd`) and standalone LaTeX (`.tex` and `.latex`). Use `--format` for another extension. A `.qmd` file is treated as Pandoc Markdown, with the limited document-local figure references described below; pandoc-glance does not run Quarto or reproduce project formats such as Reveal.js presentations, books, or websites. Use `quarto preview` when the Quarto build itself is the desired output.
46
+
47
+ ### Themes
48
+
49
+ `--theme auto` is the default and follows the browser's `prefers-color-scheme` setting. `--theme light` and `--theme dark` pin the corresponding built-in palette. The palette covers the document, code highlighting, MathJax fallback, Mermaid diagrams, and preview status UI; `--font-size` controls document text separately.
50
+
51
+ Themes are intentionally independent of Pi, editors, and Quarto. There is currently no custom-CSS or named-theme option.
46
52
 
47
53
  ### One-shot preview
48
54
 
@@ -71,7 +77,8 @@ pandoc-glance --watch --no-open --port 0 notes.md
71
77
  Watch mode:
72
78
 
73
79
  - Opens one browser tab and updates it after each saved change.
74
- - Handles ordinary writes and atomic saves.
80
+ - Handles ordinary writes and atomic saves, collapsing save bursts to the latest pending content.
81
+ - Skips redundant renders when the saved content has not changed.
75
82
  - Preserves reading position across reloads.
76
83
  - Keeps the last successful preview visible after a render error and recovers on the next valid save.
77
84
 
@@ -130,11 +137,38 @@ Relative paths resolve from the source document's directory:
130
137
 
131
138
  ```markdown
132
139
  ![Experiment result](figures/result.png)
140
+ ![Shared parent figure](../figures/result.png)
133
141
  ![Path containing spaces](<figures/run 01.png>)
134
142
  ![[figures/result.png|Obsidian-style caption]]
135
143
  ```
136
144
 
137
- Absolute local image paths are also supported. Watch mode uses revisioned, non-cached resource URLs so saved image changes appear immediately.
145
+ PNG/JPEG/SVG-style images and local PDF figures are supported. PDF figures render their first page through pdf.js and retain an **Open PDF** link as a fallback:
146
+
147
+ ```markdown
148
+ ![Model diagram](../figures/model.pdf){width=80% fig-align="center"}
149
+ ```
150
+
151
+ One-shot output inlines local PDF figures up to 16 MB each and 30 MB total, so the browser can render them without `file:` fetch access; larger PDFs retain the **Open PDF** fallback.
152
+
153
+ Absolute paths are also supported. In watch mode, an explicitly authored parent-relative or absolute supported-media reference outside the document directory is exposed only through an opaque per-render allowlist URL; arbitrary path traversal remains blocked. Resource responses are revisioned and not browser-cached.
154
+
155
+ ### Figure cross-references
156
+
157
+ Basic labelled-figure references support both Quarto-style identifiers and the `pandoc-crossref` convention:
158
+
159
+ ```markdown
160
+ See @fig-elephant and @fig:whale.
161
+
162
+ ![An Elephant](figures/elephant.png){#fig-elephant}
163
+
164
+ ![A Whale](figures/whale.png){#fig:whale}
165
+ ```
166
+
167
+ Both references become clickable **Figure N** links, and standalone captioned images receive numbered captions. Write `See @fig-elephant`, not `See Figure @fig-elephant`, because the generated link already includes “Figure”. Unlabelled standalone figures still consume a number, so later references remain consistent.
168
+
169
+ This is deliberately a lightweight, document-local subset. It resolves exact single references only. Missing, duplicate, inline-image, compound, and qualified references remain visibly unresolved and produce terminal warnings. It does not implement table/equation/section references, subfigures, chapter-aware numbering, Quarto project filters, or code execution.
170
+
171
+ HTML comments outside Markdown code contexts are removed before rendering, so private drafting notes do not become visible when raw HTML is disabled. Valid YAML mapping front matter and comment-like text in fenced, indented, or inline code are preserved.
138
172
 
139
173
  ### Standalone LaTeX
140
174
 
@@ -199,18 +233,22 @@ Pandoc conversion, styling, native MathML, syntax highlighting, local resources,
199
233
  - Mermaid 11.16 from jsDelivr when the document contains a Mermaid block.
200
234
  - Lucide or Logos icon data from unpkg when a diagram uses that pack.
201
235
  - MathJax 3 from jsDelivr when Pandoc leaves an equation as TeX.
236
+ - pdf.js 4.10 from jsDelivr when the document contains a local PDF figure.
202
237
 
203
- Without network access, the core preview still works. Mermaid remains visible as source with an error, and unsupported equations remain as TeX with a warning.
238
+ Without network access, the core preview still works. Mermaid remains visible as source with an error, unsupported equations remain as TeX with a warning, and PDF figures retain a direct **Open PDF** link.
204
239
 
205
240
  ## Security model
206
241
 
207
- Watch mode:
242
+ One-shot pages carry a nonce-based Content Security Policy in the generated HTML. Watch mode:
208
243
 
209
244
  - Binds only to `127.0.0.1`.
210
245
  - Uses a random 192-bit token in every preview route.
246
+ - Uses a fresh script nonce for every page response with `strict-dynamic`; inline/eval JavaScript and `javascript:` links cannot execute.
211
247
  - Sets `no-store`, `nosniff`, no-referrer, same-origin, and content-security headers.
212
- - Rejects path traversal, including encoded `..` and symlinks outside the source directory.
213
- - Serves an outside absolute file only when the current document explicitly references it, through an opaque ID.
248
+ - Disables Pandoc raw HTML and raw attributed blocks; authored HTML is rendered inert.
249
+ - Rejects arbitrary resource-route traversal, including encoded `..`, and rejects symlinks that escape the source directory.
250
+ - Serves only browser-preview media types: common images, audio/video, and PDF. Source, script, HTML, and unknown file types receive `415 Unsupported Media Type`.
251
+ - Serves a supported parent-relative or absolute media file outside the document directory only when the current document explicitly references it, through an opaque ID.
214
252
 
215
253
  A failed render keeps the previous HTML and resource allowlist.
216
254
 
@@ -247,7 +285,7 @@ The CLI uses the operating system default-browser command (`open`, `xdg-open`, o
247
285
 
248
286
  - Check the path relative to the source file, not the shell's current directory.
249
287
  - Put paths containing spaces or parentheses in Markdown angle brackets.
250
- - In watch mode, a relative symlink whose target is outside the document directory is deliberately blocked; use an explicit absolute path if that file should be allowlisted.
288
+ - In watch mode, a relative symlink whose target is outside the document directory is deliberately blocked; use an explicit absolute path for a supported media file that should be allowlisted.
251
289
  - Save the image and source file. Resource responses are not browser-cached.
252
290
 
253
291
  ### The selected port is busy
@@ -277,4 +315,4 @@ Fetch the printed loopback URL, save an edit to the fixture or a temporary copy,
277
315
 
278
316
  ## License
279
317
 
280
- MIT. The rendering palettes and selected normalization/browser-preview patterns were adapted from the MIT-licensed [`pi-markdown-preview`](https://github.com/omaclaren/pi-markdown-preview) implementation; see [`LICENSE`](LICENSE).
318
+ MIT. The figure-reference filter, Markdown comment scanner, rendering palettes, and selected normalization/browser-preview patterns were adapted from the MIT-licensed [`pi-markdown-preview`](https://github.com/omaclaren/pi-markdown-preview) and [`pi-studio`](https://github.com/omaclaren/pi-studio) implementations; see [`LICENSE`](LICENSE).
package/dist/cli.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { type PreviewFormatOption } from "./render.js";
3
3
  import type { PreviewTheme } from "./styles.js";
4
- export declare const VERSION = "0.1.0";
4
+ export declare const VERSION = "0.2.0";
5
5
  export declare const DEFAULT_FONT_SIZE_PX = 15;
6
6
  export declare const MIN_FONT_SIZE_PX = 10;
7
7
  export declare const MAX_FONT_SIZE_PX = 24;
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
8
8
  import { openInDefaultBrowser } from "./browser.js";
9
9
  import { assertPandocAvailable, detectFormat, renderDocument, } from "./render.js";
10
10
  import { startWatchPreview } from "./watch-preview.js";
11
- export const VERSION = "0.1.0";
11
+ export const VERSION = "0.2.0";
12
12
  export const DEFAULT_FONT_SIZE_PX = 15;
13
13
  export const MIN_FONT_SIZE_PX = 10;
14
14
  export const MAX_FONT_SIZE_PX = 24;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { DEFAULT_FONT_SIZE_PX, MAX_FONT_SIZE_PX, MIN_FONT_SIZE_PX, VERSION, CliArgumentError, helpText, parseCliArgs, runCli, type CliOptions, } from "./cli.js";
2
2
  export { openInDefaultBrowser } from "./browser.js";
3
- export { PandocError, assertPandocAvailable, buildInitialErrorHtml, buildPreviewHtml, detectFormat, normalizeMarkdownFencedBlocks, normalizeMathDelimiters, normalizeObsidianImages, prepareMarkdownForPandoc, renderDocument, renderPandocFragment, type BuildHtmlOptions, type LiveReloadConfig, type PreviewFormat, type PreviewFormatOption, type RenderDocumentOptions, type RenderDocumentResult, type ServerResourceConfig, } from "./render.js";
3
+ export { PandocError, assertPandocAvailable, buildInitialErrorHtml, buildPreviewHtml, detectFormat, normalizeMarkdownFencedBlocks, normalizeMathDelimiters, normalizeObsidianImages, prepareMarkdownForPandoc, renderDocument, renderPandocFragment, stripMarkdownHtmlComments, type BuildHtmlOptions, type LiveReloadConfig, type PreviewFormat, type PreviewFormatOption, type RenderDocumentOptions, type RenderDocumentResult, type ServerResourceConfig, } from "./render.js";
4
4
  export { PreviewServer, ResourceAccessError, resolveSafeResourcePath, type PreviewServerOptions, type PreviewServerPaths, type PreviewServerState, } from "./server.js";
5
5
  export { DARK_PALETTE, LIGHT_PALETTE, buildPreviewCss, type PreviewPalette, type PreviewTheme, } from "./styles.js";
6
6
  export { WatchPreviewSession, startWatchPreview, type StartWatchPreviewOptions, type WatchPreviewStatus, type WatchRenderContext, type WatchRenderer, type WatchRenderResult, } from "./watch-preview.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { DEFAULT_FONT_SIZE_PX, MAX_FONT_SIZE_PX, MIN_FONT_SIZE_PX, VERSION, CliArgumentError, helpText, parseCliArgs, runCli, } from "./cli.js";
2
2
  export { openInDefaultBrowser } from "./browser.js";
3
- export { PandocError, assertPandocAvailable, buildInitialErrorHtml, buildPreviewHtml, detectFormat, normalizeMarkdownFencedBlocks, normalizeMathDelimiters, normalizeObsidianImages, prepareMarkdownForPandoc, renderDocument, renderPandocFragment, } from "./render.js";
3
+ export { PandocError, assertPandocAvailable, buildInitialErrorHtml, buildPreviewHtml, detectFormat, normalizeMarkdownFencedBlocks, normalizeMathDelimiters, normalizeObsidianImages, prepareMarkdownForPandoc, renderDocument, renderPandocFragment, stripMarkdownHtmlComments, } from "./render.js";
4
4
  export { PreviewServer, ResourceAccessError, resolveSafeResourcePath, } from "./server.js";
5
5
  export { DARK_PALETTE, LIGHT_PALETTE, buildPreviewCss, } from "./styles.js";
6
6
  export { WatchPreviewSession, startWatchPreview, } from "./watch-preview.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,MAAM,GAEP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,GAQrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,uBAAuB,GAIxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,GAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAMlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAoC,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,MAAM,GAEP,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,GAQ1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,uBAAuB,GAIxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,GAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAMlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAoC,MAAM,cAAc,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Remove Markdown HTML comments while preserving comment-like text in fenced,
3
+ * indented, and inline code. Micromark supplies code/escape ranges; a second
4
+ * tag-masked pass handles Pandoc's Markdown-inside-native-HTML behavior.
5
+ */
6
+ export declare function stripMarkdownHtmlComments(markdown: string): string;
7
+ /** Preserve valid YAML mapping front matter byte-for-byte while removing body comments. */
8
+ export declare function stripMarkdownHtmlCommentsPreservingYamlFrontMatter(markdown: string): string;
9
+ //# sourceMappingURL=markdown-comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-comments.d.ts","sourceRoot":"","sources":["../src/markdown-comments.ts"],"names":[],"mappings":"AAmPA;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAalE;AAcD,2FAA2F;AAC3F,wBAAgB,kDAAkD,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK3F"}
@@ -0,0 +1,277 @@
1
+ // Adapted from pi-markdown-preview's MIT-licensed comment scanner (commit 146c022).
2
+ import { parse, postprocess, preprocess } from "micromark";
3
+ import { isMap, parseDocument } from "yaml";
4
+ const PROTECTED_MARKDOWN_TOKEN_TYPES = new Set([
5
+ "characterEscape",
6
+ "codeFenced",
7
+ "codeIndented",
8
+ "codeText",
9
+ "definitionDestinationString",
10
+ "definitionTitleString",
11
+ "resourceDestinationString",
12
+ "resourceTitleString",
13
+ ]);
14
+ function mergeRanges(ranges) {
15
+ const sorted = ranges
16
+ .filter((range) => range.end > range.start)
17
+ .sort((left, right) => left.start - right.start || left.end - right.end);
18
+ const merged = [];
19
+ for (const range of sorted) {
20
+ const previous = merged.at(-1);
21
+ if (!previous || range.start > previous.end) {
22
+ merged.push({ ...range });
23
+ }
24
+ else {
25
+ previous.end = Math.max(previous.end, range.end);
26
+ }
27
+ }
28
+ return merged;
29
+ }
30
+ function collectProtectedMarkdownRanges(source) {
31
+ const hasByteOrderMark = source.startsWith("\uFEFF");
32
+ const tokenizerSource = hasByteOrderMark ? source.slice(1) : source;
33
+ const offsetAdjustment = hasByteOrderMark ? 1 : 0;
34
+ const events = postprocess(parse().document().write(preprocess()(tokenizerSource, "utf8", true)));
35
+ const ranges = [];
36
+ for (const [eventType, token] of events) {
37
+ if (eventType !== "enter" || !PROTECTED_MARKDOWN_TOKEN_TYPES.has(token.type))
38
+ continue;
39
+ ranges.push({
40
+ start: token.start.offset + offsetAdjustment,
41
+ end: token.end.offset + offsetAdjustment,
42
+ });
43
+ }
44
+ return ranges;
45
+ }
46
+ function hasEscapedOpeningAngleBracket(source, start) {
47
+ let precedingBackslashes = 0;
48
+ for (let index = start - 1; index >= 0 && source[index] === "\\"; index -= 1)
49
+ precedingBackslashes += 1;
50
+ return precedingBackslashes % 2 === 1;
51
+ }
52
+ function isHtmlWhitespace(character) {
53
+ return character === " " || character === "\t" || character === "\r" || character === "\n" || character === "\f";
54
+ }
55
+ function isHtmlAttributeNameCharacter(character) {
56
+ return Boolean(character) && !isHtmlWhitespace(character) && !/["'=<>`/]/.test(character);
57
+ }
58
+ function isHtmlUnquotedAttributeValueCharacter(character) {
59
+ return Boolean(character) && !isHtmlWhitespace(character) && !/["'`=<>]/.test(character);
60
+ }
61
+ function readHtmlTag(source, start) {
62
+ if (source.startsWith("<!--", start) || hasEscapedOpeningAngleBracket(source, start))
63
+ return undefined;
64
+ let index = start + 1;
65
+ let closing = false;
66
+ if (source[index] === "/") {
67
+ closing = true;
68
+ index += 1;
69
+ }
70
+ if (!/[a-zA-Z]/.test(source[index] ?? ""))
71
+ return undefined;
72
+ const nameStart = index;
73
+ index += 1;
74
+ while (/[a-zA-Z0-9:-]/.test(source[index] ?? ""))
75
+ index += 1;
76
+ const tagName = source.slice(nameStart, index).toLowerCase();
77
+ if (closing) {
78
+ while (isHtmlWhitespace(source[index]))
79
+ index += 1;
80
+ return source[index] === ">" ? { end: index + 1, tagName } : undefined;
81
+ }
82
+ for (;;) {
83
+ while (isHtmlWhitespace(source[index]))
84
+ index += 1;
85
+ if (source[index] === ">")
86
+ return { end: index + 1, tagName };
87
+ if (source[index] === "/" && source[index + 1] === ">")
88
+ return { end: index + 2, tagName };
89
+ if (!isHtmlAttributeNameCharacter(source[index]))
90
+ return undefined;
91
+ while (isHtmlAttributeNameCharacter(source[index]))
92
+ index += 1;
93
+ while (isHtmlWhitespace(source[index]))
94
+ index += 1;
95
+ if (source[index] !== "=")
96
+ continue;
97
+ index += 1;
98
+ while (isHtmlWhitespace(source[index]))
99
+ index += 1;
100
+ const quote = source[index] === "\"" || source[index] === "'" ? source[index] : undefined;
101
+ if (quote) {
102
+ index += 1;
103
+ while (index < source.length && source[index] !== quote)
104
+ index += 1;
105
+ if (source[index] !== quote)
106
+ return undefined;
107
+ index += 1;
108
+ continue;
109
+ }
110
+ if (!isHtmlUnquotedAttributeValueCharacter(source[index]))
111
+ return undefined;
112
+ while (isHtmlUnquotedAttributeValueCharacter(source[index]))
113
+ index += 1;
114
+ }
115
+ }
116
+ function collectHtmlTags(source) {
117
+ const tags = [];
118
+ let index = 0;
119
+ while (index < source.length) {
120
+ const start = source.indexOf("<", index);
121
+ if (start < 0)
122
+ break;
123
+ const tag = readHtmlTag(source, start);
124
+ if (!tag) {
125
+ index = start + 1;
126
+ continue;
127
+ }
128
+ tags.push({ ...tag, start });
129
+ index = tag.end;
130
+ }
131
+ return tags;
132
+ }
133
+ function isMarkdownContainerPrefixOnly(value) {
134
+ let remainder = value;
135
+ for (;;) {
136
+ const blockQuote = remainder.match(/^[ \t]{0,3}>[ \t]?/);
137
+ if (blockQuote) {
138
+ remainder = remainder.slice(blockQuote[0].length);
139
+ continue;
140
+ }
141
+ const listItem = remainder.match(/^[ \t]{0,3}(?:[-+*]|\d{1,9}[.)])[ \t]+/);
142
+ if (listItem) {
143
+ remainder = remainder.slice(listItem[0].length);
144
+ continue;
145
+ }
146
+ return remainder.trim().length === 0;
147
+ }
148
+ }
149
+ function collectBlankDivTagStarts(source, tags) {
150
+ const blankTagStarts = new Set();
151
+ let tagIndex = 0;
152
+ let lineStart = 0;
153
+ while (lineStart <= source.length && tagIndex < tags.length) {
154
+ const newlineIndex = source.indexOf("\n", lineStart);
155
+ const lineEnd = newlineIndex < 0 ? source.length : newlineIndex;
156
+ while (tagIndex < tags.length && tags[tagIndex].end <= lineStart)
157
+ tagIndex += 1;
158
+ let lineTagEnd = tagIndex;
159
+ while (lineTagEnd < tags.length && tags[lineTagEnd].start < lineEnd)
160
+ lineTagEnd += 1;
161
+ const lineTags = tags.slice(tagIndex, lineTagEnd);
162
+ if (lineTags.length > 0
163
+ && lineTags.every((tag) => tag.tagName === "div" && tag.start >= lineStart && tag.end <= lineEnd)) {
164
+ let residual = "";
165
+ let cursor = lineStart;
166
+ for (const tag of lineTags) {
167
+ residual += source.slice(cursor, tag.start);
168
+ cursor = tag.end;
169
+ }
170
+ residual += source.slice(cursor, lineEnd);
171
+ if (isMarkdownContainerPrefixOnly(residual)) {
172
+ for (const tag of lineTags)
173
+ blankTagStarts.add(tag.start);
174
+ }
175
+ }
176
+ if (newlineIndex < 0)
177
+ break;
178
+ lineStart = newlineIndex + 1;
179
+ }
180
+ return blankTagStarts;
181
+ }
182
+ function maskHtmlTags(source) {
183
+ const tags = collectHtmlTags(source);
184
+ if (tags.length === 0)
185
+ return source;
186
+ const blankDivTagStarts = collectBlankDivTagStarts(source, tags);
187
+ const pieces = [];
188
+ let cursor = 0;
189
+ for (const tag of tags) {
190
+ pieces.push(source.slice(cursor, tag.start));
191
+ const maskCharacter = blankDivTagStarts.has(tag.start) ? " " : "x";
192
+ pieces.push(source.slice(tag.start, tag.end).replace(/[^\r\n]/g, maskCharacter));
193
+ cursor = tag.end;
194
+ }
195
+ pieces.push(source.slice(cursor));
196
+ return pieces.join("");
197
+ }
198
+ function findContainingRange(ranges, offset, startIndex = 0) {
199
+ for (let index = startIndex; index < ranges.length; index += 1) {
200
+ const range = ranges[index];
201
+ if (offset < range.start)
202
+ return { range: undefined, nextIndex: index };
203
+ if (offset < range.end)
204
+ return { range, nextIndex: index };
205
+ }
206
+ return { range: undefined, nextIndex: ranges.length };
207
+ }
208
+ function collectMarkdownHtmlCommentRanges(source) {
209
+ const maskedSource = maskHtmlTags(source);
210
+ const protectedRanges = mergeRanges([
211
+ ...collectProtectedMarkdownRanges(source),
212
+ ...collectProtectedMarkdownRanges(maskedSource),
213
+ ]);
214
+ const commentRanges = [];
215
+ let protectedRangeIndex = 0;
216
+ let index = 0;
217
+ while (index < source.length) {
218
+ const start = source.indexOf("<!--", index);
219
+ if (start < 0)
220
+ break;
221
+ const protectedContaining = findContainingRange(protectedRanges, start, protectedRangeIndex);
222
+ protectedRangeIndex = protectedContaining.nextIndex;
223
+ if (protectedContaining.range) {
224
+ index = Math.max(start + 4, protectedContaining.range.end);
225
+ continue;
226
+ }
227
+ const closingIndex = source.indexOf("-->", start + 4);
228
+ if (closingIndex < 0)
229
+ break;
230
+ const end = closingIndex + 3;
231
+ commentRanges.push({ start, end });
232
+ index = end;
233
+ }
234
+ return commentRanges;
235
+ }
236
+ function blankCommentTextPreservingLineEndings(comment) {
237
+ return comment.replace(/[^\r\n]/g, "");
238
+ }
239
+ /**
240
+ * Remove Markdown HTML comments while preserving comment-like text in fenced,
241
+ * indented, and inline code. Micromark supplies code/escape ranges; a second
242
+ * tag-masked pass handles Pandoc's Markdown-inside-native-HTML behavior.
243
+ */
244
+ export function stripMarkdownHtmlComments(markdown) {
245
+ const source = String(markdown ?? "");
246
+ const ranges = collectMarkdownHtmlCommentRanges(source);
247
+ if (ranges.length === 0)
248
+ return source;
249
+ let output = "";
250
+ let cursor = 0;
251
+ for (const { start, end } of ranges) {
252
+ output += source.slice(cursor, start);
253
+ output += blankCommentTextPreservingLineEndings(source.slice(start, end));
254
+ cursor = end;
255
+ }
256
+ return output + source.slice(cursor);
257
+ }
258
+ function splitValidYamlFrontMatter(source) {
259
+ const match = source.match(/^(\uFEFF?---[ \t]*\r?\n)([\s\S]*?)^((?:---|\.\.\.)[ \t]*(?:\r?\n|$))/m);
260
+ if (!match || match.index !== 0)
261
+ return undefined;
262
+ const yamlSource = match[2] ?? "";
263
+ const document = parseDocument(yamlSource, { prettyErrors: false, uniqueKeys: false });
264
+ if (document.errors.length > 0 || !isMap(document.contents))
265
+ return undefined;
266
+ const frontMatter = match[0];
267
+ return { frontMatter, body: source.slice(frontMatter.length) };
268
+ }
269
+ /** Preserve valid YAML mapping front matter byte-for-byte while removing body comments. */
270
+ export function stripMarkdownHtmlCommentsPreservingYamlFrontMatter(markdown) {
271
+ const source = String(markdown ?? "");
272
+ const split = splitValidYamlFrontMatter(source);
273
+ if (!split)
274
+ return stripMarkdownHtmlComments(source);
275
+ return `${split.frontMatter}${stripMarkdownHtmlComments(split.body)}`;
276
+ }
277
+ //# sourceMappingURL=markdown-comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-comments.js","sourceRoot":"","sources":["../src/markdown-comments.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAW5C,MAAM,8BAA8B,GAAG,IAAI,GAAG,CAAC;IAC7C,iBAAiB;IACjB,YAAY;IACZ,cAAc;IACd,UAAU;IACV,6BAA6B;IAC7B,uBAAuB;IACvB,2BAA2B;IAC3B,qBAAqB;CACtB,CAAC,CAAC;AAEH,SAAS,WAAW,CAAC,MAAqB;IACxC,MAAM,MAAM,GAAG,MAAM;SAClB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC;SAC1C,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAA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44
  export declare function assertPandocAvailable(): Promise<void>;
45
45
  export declare function normalizeMathDelimiters(markdown: string): string;
46
46
  export declare function normalizeObsidianImages(markdown: string): string;
47
+ /** Remove authored HTML comments without exposing their Markdown contents through Pandoc's raw-HTML boundary. */
48
+ export declare function stripMarkdownHtmlComments(markdown: string): string;
47
49
  export declare function normalizeMarkdownFencedBlocks(markdown: string): string;
48
50
  export declare function prepareMarkdownForPandoc(markdown: string): string;
49
51
  export declare function renderPandocFragment(source: string, format: PreviewFormat, resourceRoot: string): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsC,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEpF,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;AACjD,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,aAAa,CAAC;AAEzD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MA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