@vectojs/markdown 0.22.0 → 0.23.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/dist/Markdown.d.ts +91 -60
- package/dist/MarkdownWorkerSource.d.ts +1 -1
- package/dist/index.js +177 -89
- package/dist/index.mjs +177 -89
- package/dist/markdown-abbr.d.ts +0 -8
- package/dist/markdown-image.d.ts +22 -22
- package/package.json +2 -2
- package/dist/markdown-typography.d.ts +0 -72
package/dist/markdown-abbr.d.ts
CHANGED
|
@@ -54,14 +54,6 @@ export interface AbbrDefToken {
|
|
|
54
54
|
* paragraph rather than recognised.
|
|
55
55
|
*/
|
|
56
56
|
export declare const ABBR_EXTENSIONS: TokenizerAndRendererExtension[];
|
|
57
|
-
/**
|
|
58
|
-
* Whether `text` contains an abbreviation-definition line at all.
|
|
59
|
-
*
|
|
60
|
-
* Cheap reject first (`*[` is rare outside this construct), matching every
|
|
61
|
-
* other opener-detector in this package (`hasContainerOpener`,
|
|
62
|
-
* `hasFootnoteDefOpener`).
|
|
63
|
-
*/
|
|
64
|
-
export declare function hasAbbrDef(text: string): boolean;
|
|
65
57
|
/**
|
|
66
58
|
* Scan top-level tokens for `abbrDef` entries and build the term dictionary.
|
|
67
59
|
*
|
package/dist/markdown-image.d.ts
CHANGED
|
@@ -36,19 +36,6 @@ export declare function paragraphHasImage(token: Tokens.Paragraph): boolean;
|
|
|
36
36
|
* tier check and the flattening the render arms do cannot drift apart.
|
|
37
37
|
*/
|
|
38
38
|
export declare function containsImage(tokens: Token[] | undefined): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* An inline run with nested images lifted to the top level, in source order.
|
|
41
|
-
*
|
|
42
|
-
* The paragraph arm splits a run into one `Stack` child per image plus one per
|
|
43
|
-
* maximal run of non-image tokens, which requires every image to be a direct
|
|
44
|
-
* member of the array it iterates. An image inside a link or an emphasis is not,
|
|
45
|
-
* so the run is flattened first.
|
|
46
|
-
*
|
|
47
|
-
* A wrapper is replaced by its children rather than dropped, so the text inside a
|
|
48
|
-
* link that also holds an image survives. Only wrappers **containing** an image
|
|
49
|
-
* are opened: a plain link keeps its own token, and therefore keeps the styling
|
|
50
|
-
* and click handling `renderInlineToRichText` gives it.
|
|
51
|
-
*/
|
|
52
39
|
/**
|
|
53
40
|
* Every image in an inline run, at any depth, in source order.
|
|
54
41
|
*
|
|
@@ -64,18 +51,22 @@ export declare function imagesOf(tokens: Token[] | undefined): Tokens.Image[];
|
|
|
64
51
|
* while its images render as blocks beneath.
|
|
65
52
|
*/
|
|
66
53
|
export declare function stripImages<T extends Token>(token: T): T;
|
|
67
|
-
export declare function liftNestedImages(tokens: Token[]): Token[];
|
|
68
|
-
/** Index of the last `image` token in an inline run, or -1 if there is none. */
|
|
69
|
-
export declare function lastIndexOfImage(tokens: Token[]): number;
|
|
70
54
|
/**
|
|
71
|
-
*
|
|
55
|
+
* An inline run with nested images lifted to the top level, in source order.
|
|
72
56
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
57
|
+
* The paragraph arm splits a run into one `Stack` child per image plus one per
|
|
58
|
+
* maximal run of non-image tokens, which requires every image to be a direct
|
|
59
|
+
* member of the array it iterates. An image inside a link or an emphasis is not,
|
|
60
|
+
* so the run is flattened first.
|
|
61
|
+
*
|
|
62
|
+
* A wrapper is replaced by its children rather than dropped, so the text inside a
|
|
63
|
+
* link that also holds an image survives. Only wrappers **containing** an image
|
|
64
|
+
* are opened: a plain link keeps its own token, and therefore keeps the styling
|
|
65
|
+
* and click handling `renderInlineToRichText` gives it.
|
|
78
66
|
*/
|
|
67
|
+
export declare function liftNestedImages(tokens: Token[]): Token[];
|
|
68
|
+
/** Index of the last `image` token in an inline run, or -1 if there is none. */
|
|
69
|
+
export declare function lastIndexOfImage(tokens: Token[]): number;
|
|
79
70
|
/**
|
|
80
71
|
* A decoding raster for one inline image, keyed by URL.
|
|
81
72
|
*
|
|
@@ -123,4 +114,13 @@ export declare function ensureInlineImageRaster(src: string): InlineImageRaster;
|
|
|
123
114
|
export declare function paintInlineImage(src: string, surface: InlineObjectSurface, box: InlineObjectBox): void;
|
|
124
115
|
/** Drop every cached raster. Tests only — a decode is process-wide state. */
|
|
125
116
|
export declare function clearInlineImageRasters(): void;
|
|
117
|
+
/**
|
|
118
|
+
* How many `Stack` children the paragraph render arm builds for an inline run.
|
|
119
|
+
*
|
|
120
|
+
* One child per image, plus one per *maximal run* of consecutive non-image
|
|
121
|
+
* tokens — the arm merges those into a single `RichText` via `flushText`, so this
|
|
122
|
+
* is not `tokens.length`. Kept in lockstep with that arm; it is what
|
|
123
|
+
* `updateImageParagraph` checks to confirm the entity it was handed is the one
|
|
124
|
+
* built for the old tokens.
|
|
125
|
+
*/
|
|
126
126
|
export declare function expectedImageParagraphChildren(tokens: Token[]): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectojs/markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"test:e2e": "bun e2e/blockquote-layout.e2e.ts && bun e2e/stream-controller.e2e.ts && bun e2e/lazy-math.e2e.ts && bun e2e/paragraph-image-repaint.e2e.ts && bun e2e/inline-image.e2e.ts && bun e2e/selection-fidelity.e2e.ts && bun e2e/code-atlas-dpr.e2e.ts && bun e2e/set-max-width.e2e.ts && bun e2e/block-affordances.e2e.ts && bun e2e/single-tilde-ink.e2e.ts && bun e2e/superscript-ink.e2e.ts && bun e2e/ins-mark-ink.e2e.ts && bun e2e/container-ink.e2e.ts && bun e2e/abbr-ink.e2e.ts"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@vectojs/tex": "^0.1.
|
|
47
|
+
"@vectojs/tex": "^0.1.2",
|
|
48
48
|
"marked": "^18.0.7"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typographic replacements: `--`/`---` to en/em dash, `...` to `…`, `(c)`/`(r)`/
|
|
3
|
-
* `(tm)` to `©`/`®`/`™`, `+-` to `±`, and repeated `!`/`,` collapsing —
|
|
4
|
-
* `markdown-it`'s `typographer: true` set, minus smart quotes (see below).
|
|
5
|
-
*
|
|
6
|
-
* Ported as a **pure text transform** rather than a new tokenizer or `marked`
|
|
7
|
-
* extension, because that is what it is upstream too: `markdown-it`'s own
|
|
8
|
-
* `replacements` rule runs as a `core` pass over already-tokenized `text`
|
|
9
|
-
* content, not a grammar rule, and every substitution here is describable the
|
|
10
|
-
* same way — a regex over a string that changes no token boundaries. Applying
|
|
11
|
-
* it as the last step before a `text`-bearing span is pushed keeps this
|
|
12
|
-
* completely orthogonal to every other inline arm: a bold/italic/code run's
|
|
13
|
-
* content transforms identically to a plain paragraph's, because it is the same
|
|
14
|
-
* function call, not a special case duplicated per arm.
|
|
15
|
-
*
|
|
16
|
-
* ## Off by default, unlike every other construct in this package
|
|
17
|
-
*
|
|
18
|
-
* `markdown-it` itself defaults `typographer` to `false`, and this mirrors
|
|
19
|
-
* that rather than picking a different default for parity's own sake: the
|
|
20
|
-
* transform is lossy (a real `--` a caller wanted to keep literal, e.g. a CLI
|
|
21
|
-
* flag or a code-adjacent range, becomes an en dash with no way back short of
|
|
22
|
-
* disabling the whole feature) and every other construct in this package
|
|
23
|
-
* (subscript, superscript, ins/mark, emoji, footnotes) is instead
|
|
24
|
-
* unconditionally-on syntax recognition with no lossy default to weigh.
|
|
25
|
-
* `theme.typographer` (default `false`) is the gate, checked once per paragraph
|
|
26
|
-
* of text collection rather than per span, so a caller who never opts in pays
|
|
27
|
-
* nothing beyond the one boolean check `collectSpans` already does today for
|
|
28
|
-
* `inherited`.
|
|
29
|
-
*
|
|
30
|
-
* ## Smart quotes are deliberately NOT ported
|
|
31
|
-
*
|
|
32
|
-
* `markdown-it`'s `smartquotes` rule curls straight quotes into `‘’“”` by
|
|
33
|
-
* walking the FULL inline-token sequence of one block with a stack that
|
|
34
|
-
* matches an opening quote to its closing partner, consulting the previous and
|
|
35
|
-
* next token's own trailing/leading character across token boundaries (see
|
|
36
|
-
* `references/markdown-it/lib/rules_core/smartquotes.mjs`'s `process_inlines`).
|
|
37
|
-
* That is not a per-span text transform — it is a second pass over
|
|
38
|
-
* `collectSpans`' entire OUTPUT array, with cross-span state (the open-quote
|
|
39
|
-
* stack) and lookback/lookahead into neighboring spans' text. Porting it here
|
|
40
|
-
* would mean walking `out` after the fact, which every call site of
|
|
41
|
-
* `collectSpans`/`applyTypography` would have to remember to do, and getting it
|
|
42
|
-
* wrong reads as a rendering defect (mismatched curly quotes) rather than a
|
|
43
|
-
* missing feature. Left unimplemented; a caller wanting curled quotes still
|
|
44
|
-
* gets straight ones, the same honest fallback every unsupported construct in
|
|
45
|
-
* this package gets.
|
|
46
|
-
*/
|
|
47
|
-
/**
|
|
48
|
-
* Apply typographic substitutions to one run of plain text.
|
|
49
|
-
*
|
|
50
|
-
* Order matters and mirrors `markdown-it`'s own rule (`replace_scoped` before
|
|
51
|
-
* `replace_rare`, and within the latter: `+-`, then `...`, then the
|
|
52
|
-
* `?`/`!`-adjacent ellipsis correction, then `!!!!`/`,,`, then em-dash, then
|
|
53
|
-
* en-dash):
|
|
54
|
-
*
|
|
55
|
-
* - `+-` before `...`: neither can produce the other's trigger character, so
|
|
56
|
-
* order between them is actually inert, but matching upstream's order keeps
|
|
57
|
-
* this auditable against it rather than needing its own independent proof.
|
|
58
|
-
* - The em-dash pass runs before the en-dash pass. `---` is three hyphens; the
|
|
59
|
-
* en-dash patterns below both require a NON-hyphen on the dash-adjacent side
|
|
60
|
-
* (`(?=[^-]|$)` / preceded by whitespace or a non-hyphen-non-space), so `---`
|
|
61
|
-
* itself never matches either en-dash pattern regardless of order — but a
|
|
62
|
-
* FOUR-hyphen run (`----`) would: the em-dash regex only consumes exactly
|
|
63
|
-
* three of the four hyphens (`(^|[^-])---(?=[^-]|$)` requires its OWN
|
|
64
|
-
* boundary hyphens to be non-hyphen), leaving a leftover single hyphens on
|
|
65
|
-
* either side that the leftover isn't itself `--`. Verified empirically
|
|
66
|
-
* against `markdown-it`'s reference implementation that `----` and `---`
|
|
67
|
-
* both resolve to one em dash: `----` is not decomposed into em+en, and
|
|
68
|
-
* running en-dash first would have changed that (the outer pair of the four
|
|
69
|
-
* hyphens would each independently look like the START of a `--` run before
|
|
70
|
-
* the em-dash pass ever saw the middle two as a `---`).
|
|
71
|
-
*/
|
|
72
|
-
export declare function applyTypography(text: string): string;
|