@mirrordown/remd-spoiler 0.1.0 → 0.1.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.
- package/CHANGELOG.md +11 -0
- package/README.md +21 -37
- package/dist/index.d.mts +7 -16
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +23 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
## 0.1.1
|
|
5
|
+
<sub>2026-10-28</sub>
|
|
6
|
+
|
|
7
|
+
- *(patch)*
|
|
8
|
+
Backslash-escaped delimiters are now literal in `remd-mark`, `remd-ins`, `remd-del`, `remd-kbd`, `remd-spoiler`, `remd-sub` and `remd-sup`, as they already were in the `mdit-*` plugins: `\==not marked==` renders as `==not marked==` instead of a `<mark>`, while an escaped backslash (`\==marked==`) still allows the markup. These plugins now depend on the new `@mirrordown/core` package, which holds logic shared across Mirrordown's engines.
|
|
9
|
+
- *(patch)*
|
|
10
|
+
`||spoiler||` now pairs delimiters with markdown-it's rules in every engine: `remd-spoiler` runs on `@mirrordown/core`'s delimiter scan (which gains the `|` marker), so a closer pairs with the nearest opener, spoilers nest, and an odd-length run's extra `|` stays outside; it drops its `unist-util-find-*` and `unist-builder` dependencies.
|
|
11
|
+
|
|
12
|
+
New `@mirrordown/sat-spoiler` renders the same JavaScript-free click-to-reveal markup, ships the same stylesheet, and is included in `@mirrordown/preset-satteri`.
|
|
13
|
+
|
|
3
14
|
## 0.1.0
|
|
4
15
|
<sub>2026-07-01</sub>
|
|
5
16
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mirrordown/remd-spoiler
|
|
2
2
|
|
|
3
|
-
> Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified
|
|
3
|
+
> Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified, markdown-it and Sätteri ecosystems.
|
|
4
4
|
|
|
5
5
|
A remark/rehype (unified) plugin for the `spoiler` syntax extension.
|
|
6
6
|
|
|
@@ -23,9 +23,9 @@ The checkbox is the only interactive control, so it stays keyboard-operable and
|
|
|
23
23
|
|
|
24
24
|
Wrap any inline content in `||…||`. Click a bar below to reveal it; click again to hide it.
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
````markdown
|
|
27
27
|
The killer was ||the butler|| all along, hidden in ||the conservatory||.
|
|
28
|
-
|
|
28
|
+
````
|
|
29
29
|
|
|
30
30
|
In renderers without the plugin, `||…||` renders as plain text.
|
|
31
31
|
|
|
@@ -33,34 +33,34 @@ In renderers without the plugin, `||…||` renders as plain text.
|
|
|
33
33
|
|
|
34
34
|
A spoiler can wrap any inline markup — emphasis, code, links — and it stays obscured until revealed. A long spoiler wraps across lines with each line getting its own bar, just like Discord.
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
````markdown
|
|
37
37
|
The recipe needs ||**two** cups of `flour` and a
|
|
38
38
|
[secret ingredient](https://example.com) that nobody expects||.
|
|
39
|
-
|
|
39
|
+
````
|
|
40
40
|
|
|
41
41
|
### Image spoilers
|
|
42
42
|
|
|
43
43
|
Wrap an image to hide it behind a blur and a **SPOILER** label — Discord's treatment for spoilered image embeds. Clicking reveals the sharp image.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
````markdown
|
|
46
46
|
Careful, dinner photo incoming: ||||
|
|
47
|
-
|
|
47
|
+
````
|
|
48
48
|
|
|
49
49
|
### Spoilered, zoomable images
|
|
50
50
|
|
|
51
51
|
Combine with the [`lightbox`](/guide/plugins/lightbox) plugin (`||!![…]()||`) for a spoilered image that is also click-to-zoom once revealed.
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
````markdown
|
|
54
54
|
The reveal: ||!||
|
|
55
|
-
|
|
55
|
+
````
|
|
56
56
|
|
|
57
57
|
### Inside links
|
|
58
58
|
|
|
59
59
|
A spoiler works inside a link — the whole revealed content remains the link target.
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
````markdown
|
|
62
62
|
Read [the ||shocking twist||](https://example.com) at your own risk.
|
|
63
|
-
|
|
63
|
+
````
|
|
64
64
|
|
|
65
65
|
## Accessibility
|
|
66
66
|
|
|
@@ -70,14 +70,14 @@ The spoiler is a real checkbox with `aria-label="spoiler"`, so assistive technol
|
|
|
70
70
|
|
|
71
71
|
The stylesheet keeps its rules in `@layer markdown-spoiler`, so any unlayered CSS you write overrides them without `!important`. The common knobs are exposed as custom properties — set them on `:root` or any ancestor:
|
|
72
72
|
|
|
73
|
-
| Property
|
|
74
|
-
|
|
|
75
|
-
| `--markdown-spoiler-bar`
|
|
76
|
-
| `--markdown-spoiler-radius`
|
|
77
|
-
| `--markdown-spoiler-duration`
|
|
78
|
-
| `--markdown-spoiler-revealed`
|
|
79
|
-
| `--markdown-spoiler-media-blur`
|
|
80
|
-
| `--markdown-spoiler-label`
|
|
73
|
+
| Property | Default | Description |
|
|
74
|
+
| ----------------------------------- | ------------------------------------------- | --------------------------------------- |
|
|
75
|
+
| `--markdown-spoiler-bar` | `#202225` | Obscured bar color (text spoilers). |
|
|
76
|
+
| `--markdown-spoiler-radius` | `0.25rem` | Bar corner radius. |
|
|
77
|
+
| `--markdown-spoiler-duration` | `0.15s` | Reveal transition duration. |
|
|
78
|
+
| `--markdown-spoiler-revealed` | `color-mix(in srgb, currentColor 8%, …)` | Background behind revealed text. |
|
|
79
|
+
| `--markdown-spoiler-media-blur` | `2.5rem` | Blur radius for image spoilers. |
|
|
80
|
+
| `--markdown-spoiler-label` | `"SPOILER"` | Text of the image-spoiler pill. |
|
|
81
81
|
|
|
82
82
|
```css
|
|
83
83
|
:root {
|
|
@@ -127,24 +127,8 @@ import "@mirrordown/remd-spoiler/spoiler.css";
|
|
|
127
127
|
export default defineConfig({
|
|
128
128
|
markdown: {
|
|
129
129
|
remarkPlugins: [remarkSpoiler],
|
|
130
|
-
remarkRehype: { handlers: spoilerHastHandlers }
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### VitePress
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
// .vitepress/config.ts
|
|
139
|
-
import { defineConfig } from "vitepress";
|
|
140
|
-
import { remarkSpoiler, spoilerHastHandlers } from "@mirrordown/remd-spoiler";
|
|
141
|
-
import "@mirrordown/remd-spoiler/spoiler.css";
|
|
142
|
-
|
|
143
|
-
export default defineConfig({
|
|
144
|
-
markdown: {
|
|
145
|
-
remarkPlugins: [remarkSpoiler],
|
|
146
|
-
remarkRehype: { handlers: spoilerHastHandlers }
|
|
147
|
-
}
|
|
130
|
+
remarkRehype: { handlers: spoilerHastHandlers },
|
|
131
|
+
},
|
|
148
132
|
});
|
|
149
133
|
```
|
|
150
134
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { Plugin } from "unified";
|
|
2
2
|
import { Data, Parent, PhrasingContent, Root } from "mdast";
|
|
3
3
|
import { Element, ElementContent } from "hast";
|
|
4
|
-
|
|
5
|
-
//#region src/plugin.d.ts
|
|
6
4
|
/** Optional data carried by a {@link Spoiler} node. */
|
|
7
|
-
interface SpoilerData extends Data {}
|
|
5
|
+
export interface SpoilerData extends Data {}
|
|
8
6
|
/**
|
|
9
7
|
* An mdast node for `||spoiler||` text, rendered as a click-to-reveal spoiler
|
|
10
8
|
* (a `<label>` wrapping a checkbox and a content `<span>`).
|
|
11
9
|
*/
|
|
12
|
-
interface Spoiler extends Parent {
|
|
10
|
+
export interface Spoiler extends Parent {
|
|
13
11
|
type: `spoiler`;
|
|
14
12
|
children: PhrasingContent[];
|
|
15
13
|
data?: SpoilerData | undefined;
|
|
@@ -20,17 +18,11 @@ interface HastState {
|
|
|
20
18
|
}
|
|
21
19
|
type SpoilerHandler = (state: HastState, node: Spoiler) => Element;
|
|
22
20
|
/** mdast-to-hast handler for spoiler nodes, for use with `remark-rehype`. */
|
|
23
|
-
declare const spoilerHastHandlers: Record<string, SpoilerHandler>;
|
|
21
|
+
export declare const spoilerHastHandlers: Record<string, SpoilerHandler>;
|
|
24
22
|
/**
|
|
25
|
-
* remark plugin for Discord-style spoiler syntax (`||text||`), wrapping each
|
|
26
|
-
* match in a {@link Spoiler} node. Pair with {@link spoilerHastHandlers} via
|
|
27
|
-
* `remarkRehype({ handlers: spoilerHastHandlers })` so the node renders as a
|
|
28
|
-
* click-to-reveal spoiler. Emits byte-identical HTML to
|
|
29
|
-
* `@mirrordown/mdit-spoiler`.
|
|
23
|
+
* remark plugin for Discord-style spoiler syntax (`||text||`), wrapping each match in a {@link Spoiler} node. Pair with {@link spoilerHastHandlers} via `remarkRehype({ handlers: spoilerHastHandlers })` so the node renders as a click-to-reveal spoiler. The scan is shared with markdown-it's pairing rules and the Sätteri plugin through `@mirrordown/core`, and the output is byte-identical to `@mirrordown/mdit-spoiler`.
|
|
30
24
|
*/
|
|
31
|
-
declare const remarkSpoiler: Plugin<[], Root>;
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/augment.d.ts
|
|
25
|
+
export declare const remarkSpoiler: Plugin<[], Root>;
|
|
34
26
|
declare module "mdast" {
|
|
35
27
|
interface PhrasingContentMap {
|
|
36
28
|
spoiler: Spoiler;
|
|
@@ -38,7 +30,6 @@ declare module "mdast" {
|
|
|
38
30
|
interface RootContentMap {
|
|
39
31
|
spoiler: Spoiler;
|
|
40
32
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { Spoiler, SpoilerData, remarkSpoiler, spoilerHastHandlers };
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
44
35
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin.ts","../src/augment.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/plugin.ts","../src/augment.ts"],"mappings":";;;;iBAOiB,oBAAoB;;;;;iBAMpB,gBAAgB;EAC/B;EACA,UAAU;EACV,OAAO;;UAOC;EACR,MAAM,MAAM,YAAY;EACxB,QAAQ,MAAM,SAAS,IAAI;;KAExB,kBAAkB,OAAO,WAAW,MAAM,YAAY;;qBAoC9C,qBAAqB,eAAe;;;;qBAOpC,eAAe,WAAW;;YChE3B;IACR,SAAS;;YAGD;IACR,SAAS"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { visit } from "unist-util-visit";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { findAllAfter } from "unist-util-find-all-after";
|
|
5
|
-
import { findAfter } from "unist-util-find-after";
|
|
6
|
-
import { u } from "unist-builder";
|
|
7
|
-
//#region src/plugin.ts
|
|
8
|
-
const REGEX = /\|\|(?![\s|])([\s\S]*?)(?<![\s|])\|\|/;
|
|
9
|
-
const REGEX_GLOBAL = /\|\|(?![\s|])([\s\S]*?)(?<![\s|])\|\|/g;
|
|
10
|
-
const REGEX_STARTING = /\|\|(?![\s]|\|+\s)/;
|
|
11
|
-
const REGEX_STARTING_GLOBAL = /\|\|(?![\s]|\|+\s)/g;
|
|
12
|
-
const REGEX_ENDING = /(?<!\s|\s\||\s\|\||\s\|\|\||\s\|\|\|\|)\|\|/;
|
|
13
|
-
const REGEX_ENDING_GLOBAL = /(?<!\s|\s\||\s\|\||\s\|\|\||\s\|\|\|\|)\|\|/g;
|
|
2
|
+
import { createDelimitedTransform, maskTreeEscapes } from "@mirrordown/core";
|
|
3
|
+
// src/plugin.ts
|
|
14
4
|
/**
|
|
15
5
|
* Build the `<label><input><span>...</span></label>` hast subtree. The checkbox
|
|
16
6
|
* precedes the content span so CSS's `:checked ~ .content` combinator can reach
|
|
@@ -43,88 +33,34 @@ const buildSpoilerHast = (state, node) => {
|
|
|
43
33
|
/** mdast-to-hast handler for spoiler nodes, for use with `remark-rehype`. */
|
|
44
34
|
const spoilerHastHandlers = { spoiler: buildSpoilerHast };
|
|
45
35
|
/**
|
|
46
|
-
* remark plugin for Discord-style spoiler syntax (`||text||`), wrapping each
|
|
47
|
-
* match in a {@link Spoiler} node. Pair with {@link spoilerHastHandlers} via
|
|
48
|
-
* `remarkRehype({ handlers: spoilerHastHandlers })` so the node renders as a
|
|
49
|
-
* click-to-reveal spoiler. Emits byte-identical HTML to
|
|
50
|
-
* `@mirrordown/mdit-spoiler`.
|
|
36
|
+
* remark plugin for Discord-style spoiler syntax (`||text||`), wrapping each match in a {@link Spoiler} node. Pair with {@link spoilerHastHandlers} via `remarkRehype({ handlers: spoilerHastHandlers })` so the node renders as a click-to-reveal spoiler. The scan is shared with markdown-it's pairing rules and the Sätteri plugin through `@mirrordown/core`, and the output is byte-identical to `@mirrordown/mdit-spoiler`.
|
|
51
37
|
*/
|
|
52
38
|
const remarkSpoiler = () => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
const transform = createDelimitedTransform(`|`, {
|
|
40
|
+
text: (value) => ({
|
|
41
|
+
type: `text`,
|
|
42
|
+
value
|
|
43
|
+
}),
|
|
44
|
+
wrap: (children) => ({
|
|
45
|
+
type: `spoiler`,
|
|
46
|
+
children
|
|
47
|
+
})
|
|
56
48
|
});
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (const match of matches) {
|
|
68
|
-
const [matched, spoilerText] = match;
|
|
69
|
-
const mIndex = match.index;
|
|
70
|
-
const mLength = matched.length;
|
|
71
|
-
const textPartIndex = prevMatchIndex + prevMatchLength;
|
|
72
|
-
prevMatchIndex = mIndex;
|
|
73
|
-
prevMatchLength = mLength;
|
|
74
|
-
if (mIndex > textPartIndex) children.push(u(`text`, value.substring(textPartIndex, mIndex)));
|
|
75
|
-
children.push(constructSpoilerNode([{
|
|
76
|
-
type: `text`,
|
|
77
|
-
value: (spoilerText ?? ``).trim()
|
|
78
|
-
}]));
|
|
79
|
-
tempValue = value.slice(mIndex + mLength);
|
|
80
|
-
}
|
|
81
|
-
if (tempValue) children.push(u(`text`, tempValue));
|
|
82
|
-
if (children.length) parent.children.splice(index, 1, ...children);
|
|
83
|
-
};
|
|
84
|
-
const visitorSecond = (node, index, parent) => {
|
|
85
|
-
/* v8 ignore next */
|
|
86
|
-
if (!parent || typeof index === `undefined`) return;
|
|
87
|
-
if (!REGEX_STARTING.test(node.value)) return;
|
|
88
|
-
const openingNode = node;
|
|
89
|
-
const closingNode = findAfter(parent, openingNode, (n) => {
|
|
90
|
-
return n.type === `text` && REGEX_ENDING.test(n.value);
|
|
49
|
+
const transformer = (tree, file) => {
|
|
50
|
+
const restoreEscapes = maskTreeEscapes(tree, String(file));
|
|
51
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
52
|
+
visit(tree, `text`, (_node, _index, parent) => {
|
|
53
|
+
if (!parent || seen.has(parent) || transform.built(parent)) return;
|
|
54
|
+
seen.add(parent);
|
|
55
|
+
const children = parent.children;
|
|
56
|
+
const next = transform(children, parent.type);
|
|
57
|
+
if (next !== children) parent.children = [...next];
|
|
58
|
+
return 0;
|
|
91
59
|
});
|
|
92
|
-
|
|
93
|
-
const beforeChildren = findAllBefore(parent, openingNode);
|
|
94
|
-
const mainChildren = findAllBetween(parent, openingNode, closingNode);
|
|
95
|
-
const afterChildren = findAllAfter(parent, closingNode);
|
|
96
|
-
const value = openingNode.value;
|
|
97
|
-
const match = Array.from(value.matchAll(REGEX_STARTING_GLOBAL))[0];
|
|
98
|
-
/* v8 ignore next */
|
|
99
|
-
if (!match) return;
|
|
100
|
-
const [matched] = match;
|
|
101
|
-
const mIndex = match.index;
|
|
102
|
-
const mLength = matched.length;
|
|
103
|
-
if (mIndex > 0) beforeChildren.push(u(`text`, value.substring(0, mIndex)));
|
|
104
|
-
if (value.length > mIndex + mLength) mainChildren.unshift(u(`text`, value.slice(mIndex + mLength)));
|
|
105
|
-
const value_ = closingNode.value;
|
|
106
|
-
const match_ = Array.from(value_.matchAll(REGEX_ENDING_GLOBAL))[0];
|
|
107
|
-
/* v8 ignore next */
|
|
108
|
-
if (!match_) return;
|
|
109
|
-
const [matched_] = match_;
|
|
110
|
-
const mIndex_ = match_.index;
|
|
111
|
-
const mLength_ = matched_.length;
|
|
112
|
-
if (mIndex_ > 0) mainChildren.push(u(`text`, value_.substring(0, mIndex_)));
|
|
113
|
-
if (value_.length > mIndex_ + mLength_) afterChildren.unshift(u(`text`, value_.slice(mIndex_ + mLength_)));
|
|
114
|
-
parent.children = [
|
|
115
|
-
...beforeChildren,
|
|
116
|
-
constructSpoilerNode(mainChildren),
|
|
117
|
-
...afterChildren
|
|
118
|
-
];
|
|
119
|
-
return index;
|
|
120
|
-
};
|
|
121
|
-
const transformer = (tree) => {
|
|
122
|
-
visit(tree, `text`, visitorFirst);
|
|
123
|
-
visit(tree, `text`, visitorSecond);
|
|
60
|
+
restoreEscapes();
|
|
124
61
|
};
|
|
125
62
|
return transformer;
|
|
126
63
|
};
|
|
127
|
-
//#endregion
|
|
128
64
|
export { remarkSpoiler, spoilerHastHandlers };
|
|
129
65
|
|
|
130
66
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { visit } from \"unist-util-visit\";\nimport type {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { visit } from \"unist-util-visit\";\nimport type { Plugin, Transformer } from \"unified\";\nimport type { Data, Parent, PhrasingContent, Root } from \"mdast\";\nimport type { Element, ElementContent, Properties } from \"hast\";\nimport { createDelimitedTransform, maskTreeEscapes } from \"@mirrordown/core\";\n\n/** Optional data carried by a {@link Spoiler} node. */\nexport interface SpoilerData extends Data {}\n\n/**\n * An mdast node for `||spoiler||` text, rendered as a click-to-reveal spoiler\n * (a `<label>` wrapping a checkbox and a content `<span>`).\n */\nexport interface Spoiler extends Parent {\n type: `spoiler`;\n children: PhrasingContent[];\n data?: SpoilerData | undefined;\n}\n\n// Minimal hast-handler surface. remark-rehype's real `State`/`Handler` types\n// carry the whole conversion API; we only need `all()` to convert this node's\n// mdast children into hast. Typed locally to avoid a dependency on\n// mdast-util-to-hast just for two type names.\ninterface HastState {\n all: (node: Spoiler) => ElementContent[];\n patch: (from: Spoiler, to: Element) => void;\n}\ntype SpoilerHandler = (state: HastState, node: Spoiler) => Element;\n\n/**\n * Build the `<label><input><span>...</span></label>` hast subtree. The checkbox\n * precedes the content span so CSS's `:checked ~ .content` combinator can reach\n * it; the content is a following sibling, not a child, of the checkbox.\n */\nconst buildSpoilerHast = (state: HastState, node: Spoiler): Element => {\n const inputProps: Properties = {\n type: `checkbox`,\n class: `markdown-spoiler-toggle`,\n \"aria-label\": `spoiler`\n };\n const input: Element = {\n type: `element`,\n tagName: `input`,\n properties: inputProps,\n children: []\n };\n const content: Element = {\n type: `element`,\n tagName: `span`,\n properties: { class: `markdown-spoiler-content` },\n children: state.all(node)\n };\n const result: Element = {\n type: `element`,\n tagName: `label`,\n properties: { class: `markdown-spoiler` },\n children: [input, content]\n };\n state.patch(node, result);\n return result;\n};\n\n/** mdast-to-hast handler for spoiler nodes, for use with `remark-rehype`. */\nexport const spoilerHastHandlers: Record<string, SpoilerHandler> = {\n spoiler: buildSpoilerHast\n};\n\n/**\n * remark plugin for Discord-style spoiler syntax (`||text||`), wrapping each match in a {@link Spoiler} node. Pair with {@link spoilerHastHandlers} via `remarkRehype({ handlers: spoilerHastHandlers })` so the node renders as a click-to-reveal spoiler. The scan is shared with markdown-it's pairing rules and the Sätteri plugin through `@mirrordown/core`, and the output is byte-identical to `@mirrordown/mdit-spoiler`.\n */\nexport const remarkSpoiler: Plugin<[], Root> = () => {\n const transform = createDelimitedTransform<PhrasingContent>(`|`, {\n text: (value) => ({ type: `text`, value }),\n wrap: (children): Spoiler => ({ type: `spoiler`, children })\n });\n\n const transformer: Transformer<Root> = (tree, file) => {\n // Escapes are resolved before this runs; mask escaped characters so a backslash-escaped delimiter is not matched, as in markdown-it.\n const restoreEscapes = maskTreeEscapes(tree, String(file));\n const seen = new WeakSet<Parent>();\n visit(tree, `text`, (_node, _index, parent: Parent | undefined) => {\n // Spoilers the scan built have already had their content scanned.\n if (!parent || seen.has(parent) || transform.built(parent)) return;\n seen.add(parent);\n // A text node's parent holds phrasing content.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const children = parent.children as PhrasingContent[];\n const next = transform(children, parent.type);\n if (next !== children) parent.children = [...next];\n // Walk the restructured children from the start; this parent is done.\n return 0;\n });\n restoreEscapes();\n };\n\n return transformer;\n};\n"],"mappings":";;;;;;;;AAkCA,MAAM,oBAAoB,OAAkB,SAA2B;CAkBrE,MAAM,SAAkB;EACtB,MAAM;EACN,SAAS;EACT,YAAY,EAAE,OAAO,mBAAmB;EACxC,UAAU,CAAC;GAfX,MAAM;GACN,SAAS;GACT,YAAY;IAPZ,MAAM;IACN,OAAO;IACP,cAAc;GAKO;GACrB,UAAU,CAAC;EAYI,GAAG;GATlB,MAAM;GACN,SAAS;GACT,YAAY,EAAE,OAAO,2BAA2B;GAChD,UAAU,MAAM,IAAI,IAAI;EAMA,CAAC;CAC3B;CACA,MAAM,MAAM,MAAM,MAAM;CACxB,OAAO;AACT;;AAGA,MAAa,sBAAsD,EACjE,SAAS,iBACX;;;;AAKA,MAAa,sBAAwC;CACnD,MAAM,YAAY,yBAA0C,KAAK;EAC/D,OAAO,WAAW;GAAE,MAAM;GAAQ;EAAM;EACxC,OAAO,cAAuB;GAAE,MAAM;GAAW;EAAS;CAC5D,CAAC;CAED,MAAM,eAAkC,MAAM,SAAS;EAErD,MAAM,iBAAiB,gBAAgB,MAAM,OAAO,IAAI,CAAC;EACzD,MAAM,uBAAO,IAAI,QAAgB;EACjC,MAAM,MAAM,SAAS,OAAO,QAAQ,WAA+B;GAEjE,IAAI,CAAC,UAAU,KAAK,IAAI,MAAM,KAAK,UAAU,MAAM,MAAM,GAAG;GAC5D,KAAK,IAAI,MAAM;GAGf,MAAM,WAAW,OAAO;GACxB,MAAM,OAAO,UAAU,UAAU,OAAO,IAAI;GAC5C,IAAI,SAAS,UAAU,OAAO,WAAW,CAAC,GAAG,IAAI;GAEjD,OAAO;EACT,CAAC;EACD,eAAe;CACjB;CAEA,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirrordown/remd-spoiler",
|
|
3
3
|
"description": "A remark plugin for Discord-style spoiler syntax (||text||), rendering click-to-reveal spoilers.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Drake Costa <drake@saeris.io> (https://saeris.gg)",
|
|
7
7
|
"repository": {
|
|
@@ -22,11 +22,7 @@
|
|
|
22
22
|
"./*.css": "./dist/*.css"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"unist-util-find-after": "^5.0.0",
|
|
27
|
-
"unist-util-find-all-after": "^5.0.0",
|
|
28
|
-
"unist-util-find-all-before": "^5.0.0",
|
|
29
|
-
"unist-util-find-between-all": "^1.1.6",
|
|
25
|
+
"@mirrordown/core": "^0.1.0",
|
|
30
26
|
"unist-util-visit": "^5.1.0"
|
|
31
27
|
},
|
|
32
28
|
"devDependencies": {
|