@mirrordown/sat-del 0.2.0 → 0.2.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 CHANGED
@@ -1,6 +1,96 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+
5
+ ## 0.2.1
6
+ <sub>2026-11-17</sub>
7
+
8
+ - *(patch)*
9
+ Fixes for edge cases where the three engines rendered `--deleted--` text differently, or wrongly.
10
+
11
+ - **An attribute block written right after a deletion goes on the `<del>`** (Sätteri, with its `attributes` feature on).
12
+
13
+ ```markdown
14
+ --deleted--{.removed}
15
+ ```
16
+
17
+ Was `<p class="removed"><del>deleted</del></p>`, and mid-paragraph the block stayed on the page as text. Now `<p><del class="removed">deleted</del></p>`, as in markdown-it and remark.
18
+
19
+ - **An escaped delimiter stays text after a deletion earlier in the paragraph** (remark, Sätteri).
20
+
21
+ ```markdown
22
+ --a-- \==b==
23
+ ```
24
+
25
+ Was `<del>a</del> <mark>b</mark>`. Now `<del>a</del> ==b==`, as in markdown-it. The same holds for `\++`, `\||` and `\[[` when those plugins run after this one.
26
+
27
+ - **A dash written as a character reference is not a delimiter** (remark, Sätteri).
28
+
29
+ ```markdown
30
+ &#45;-a--
31
+ ```
32
+
33
+ Was `<del>a</del>`. Now the text `--a--`.
34
+
35
+ - **The text of an autolink is left alone** (remark, Sätteri).
36
+
37
+ ```markdown
38
+ <http://x.com/--a-->
39
+ ```
40
+
41
+ Was a link whose text read `http://x.com/<del>a</del>`. Now the link text is the URL as written.
42
+
43
+ - **An escaped character or a character reference beside the dashes counts as punctuation** (remark, Sätteri). This decides whether a pair of dashes can open or close.
44
+
45
+ ```markdown
46
+ a--\*b--
47
+ ```
48
+
49
+ Was `a<del>*b</del>`. Now the text `a--*b--`, as in markdown-it. In the other direction, `--a&nbsp;--` was text and is now a deletion.
50
+
51
+ - **An escape is still honoured after an emoji written as a character reference** (remark, Sätteri).
52
+
53
+ ```markdown
54
+ &#x1F600; \--a--
55
+ ```
56
+
57
+ Was `😀 <del>a</del>`. Now `😀 --a--`.
58
+
59
+ - **An abbreviation beside the dashes is read as the word it is** (remark, Sätteri, with the abbr plugin).
60
+
61
+ ```markdown
62
+ *[HTML]: Hyper Text
63
+
64
+ --(a)--HTML
65
+ ```
66
+
67
+ Was `<del>(a)</del><abbr title="Hyper Text">HTML</abbr>`. Now `--(a)--<abbr title="Hyper Text">HTML</abbr>`, as in markdown-it.
68
+
69
+ - **A backslash line break right after the opening dashes does not stop them from opening** (remark, Sätteri).
70
+
71
+ ```markdown
72
+ (--\
73
+ a--
74
+ ```
75
+
76
+ Was `(--<br>a--`. Now `(<del><br>a</del>`, as in markdown-it.
77
+
78
+ - **An emoji or other character outside the Basic Multilingual Plane beside the dashes is read whole** (remark, Sätteri).
79
+
80
+ ```markdown
81
+ a--😀b--
82
+ ```
83
+
84
+ Was `a<del>😀b</del>`. Now the text `a--😀b--`, as in markdown-it.
85
+
86
+ - **Deletions nest up to 100 deep** (all engines). The markers of deeper ones stay text. Sätteri used to reject the whole document once spans nested deeper than 128, while markdown-it and remark rendered every level.
87
+
88
+ - **Private Use characters you typed are kept** (remark, Sätteri). Characters in the range U+F0021 to U+F007E, where some icon fonts put their glyphs, were rewritten to ASCII punctuation, in remark anywhere in the document, code blocks included.
89
+
90
+ - **A long run of backslashes no longer slows the scan down** (remark, Sätteri). A line of them could take many seconds.
91
+
92
+ The guide now lists the differences between engines that remain.
93
+
4
94
  ## 0.2.0
5
95
  <sub>2026-11-11</sub>
6
96
 
package/README.md CHANGED
@@ -23,7 +23,15 @@ You can use it inline: the price was --$50-- $35.
23
23
  ````
24
24
 
25
25
  > [!NOTE]
26
- > Smart punctuation rewrites `--` as an en dash before this plugin sees it, and Astro turns it on by default (`smartypants` for remark, `smartPunctuation` for Sätteri). Turn it off, or use a Mirrordown preset, which does.
26
+ > Smart punctuation rewrites `--` as an en dash before this plugin sees it, and Astro turns it on by default (`smartypants` for remark, `smartPunctuation` for Sätteri). Turn it off, or use a Mirrordown preset, which does. With it off, two `--` used as dashes on one line pair up: `2020--2021 and 2022--2023` strikes out `2021 and 2022`. Escape one of them (`2020\--2021`).
27
+
28
+ A delimiter needs text right against it, as emphasis does: an opening `--` can't be followed by a space and a closing one can't follow a space, so `a -- b -- c` stays as written. Of a run of three, one dash stays outside (`---a---` is a deletion between two dashes). A deletion can run over a line break, not over a blank line. A URL written bare in the text is read like any other text, also where GFM makes it a link (`https://example.com/a--b--c` strikes out the `b`): write it as an autolink (`<https://…>`) or as a link's target to keep it whole.
29
+
30
+ A backslash keeps a delimiter literal (`\--not deleted--`), and so does writing a dash as a character reference (`&#45;`). Deletions nest up to 100 deep; the markers of deeper ones stay text. An attribute block written right after a deletion (`--text--{.name}`) goes on the `<del>`, with the [`attrs`](/guide/plugins/attrs) plugin or Sätteri's `attributes` feature on. A few things differ between the engines:
31
+
32
+ - Spans have to nest. When a span crosses another one or crosses emphasis (`--a *b-- c*`, `--a ++b-- c++`), each engine resolves it its own way, and in remark and Sätteri the result depends on the order the plugins are listed in.
33
+ - In image alt text (`![--a--](x.png)`), markdown-it drops the dashes and remark and Sätteri keep the text as written.
34
+ - The remark plugin reads escapes from the source, so it needs the file: `processor.runSync(tree)` on a tree alone treats `\--` as `--`.
27
35
 
28
36
  ## Install
29
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAQK,cAAc,YAAY;;;;iBAKd;EACf;EACA;IAAW;;EACX,UAAU,MAAM,WAAW;;;;;qBAMhB,oBACL,KAAK,yBAAyB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAaK,cAAc,YAAY;;;;iBAKd;EACf;EACA;IAAW;;EACX,UAAU,MAAM,WAAW;;;;;qBAMhB,oBACL,KAAK,yBAAyB"}
package/dist/index.mjs CHANGED
@@ -1,10 +1,11 @@
1
- import { createDelimitedTransform } from "@mirrordown/core";
2
- import { defineMdastPlugin } from "satteri";
1
+ import { createAttributeReader, createDelimitedTransform, scanSpans } from "@mirrordown/core";
2
+ import { defineMdastPlugin, markdownToMdast } from "satteri";
3
3
  // src/index.ts
4
4
  /**
5
5
  * Sätteri plugin for deletion syntax (`--text--`), wrapping each match in a `delete` node that renders as a `<del>` element. The scan is shared with the remark plugin and markdown-it's pairing rules through `@mirrordown/core`; it runs once per parent, the first time one of the parent's text nodes is visited.
6
6
  */
7
- const satteriDel = () => ({ source }) => {
7
+ const satteriDel = () => ({ source, features }) => {
8
+ const read = features.attributes === true ? createAttributeReader(markdownToMdast) : void 0;
8
9
  const transform = createDelimitedTransform(`-`, {
9
10
  text: (value) => ({
10
11
  type: `text`,
@@ -25,8 +26,17 @@ const satteriDel = () => ({ source }) => {
25
26
  const parent = ctx.parent(node);
26
27
  if (seen.has(parent)) return;
27
28
  seen.add(parent);
28
- const children = transform.withSource(parent.children, parent.type, source);
29
- if (children) ctx.setProperty(parent, `children`, children);
29
+ scanSpans(transform, parent, {
30
+ source,
31
+ read,
32
+ parent: (of) => ctx.parent(of),
33
+ setChildren: (of, children) => {
34
+ ctx.setProperty(of, `children`, children);
35
+ },
36
+ setData: (of, data) => {
37
+ ctx.setProperty(of, `data`, data);
38
+ }
39
+ });
30
40
  }
31
41
  });
32
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { createDelimitedTransform } from \"@mirrordown/core\";\nimport {\n defineMdastPlugin,\n type MdastPluginInstance,\n type MdastTarget,\n type PluginFactoryContext\n} from \"satteri\";\n\ntype TextVisitor = NonNullable<MdastPluginInstance[\"text\"]>;\n\n/**\n * The plugin's definition: only the keys it defines, with a synchronous visitor, so `markdownToHtml` returns its result directly.\n */\nexport interface DelPlugin {\n name: string;\n options: { position: boolean };\n text: (...args: Parameters<TextVisitor>) => void;\n}\n\n/**\n * Sätteri plugin for deletion syntax (`--text--`), wrapping each match in a `delete` node that renders as a `<del>` element. The scan is shared with the remark plugin and markdown-it's pairing rules through `@mirrordown/core`; it runs once per parent, the first time one of the parent's text nodes is visited.\n */\nexport const satteriDel =\n (): ((ctx: PluginFactoryContext) => DelPlugin) =>\n ({ source }) => {\n const transform = createDelimitedTransform<MdastTarget>(`-`, {\n text: (value) => ({ type: `text`, value }),\n wrap: (children) => ({ type: `delete`, data: { hName: `del` }, children })\n });\n const seen = new WeakSet<object>();\n return defineMdastPlugin({\n name: `del`,\n // Positions let the scan tell escaped markers (`\\--`) from real ones.\n options: { position: true },\n text(node, ctx) {\n if (!node.value.includes(`--`)) return;\n const parent = ctx.parent(node);\n if (seen.has(parent)) return;\n seen.add(parent);\n const children = transform.withSource(\n parent.children,\n parent.type,\n source\n );\n if (children) ctx.setProperty(parent, `children`, children);\n }\n });\n };\n"],"mappings":";;;;;;AAsBA,MAAa,oBAEV,EAAE,aAAa;CACd,MAAM,YAAY,yBAAsC,KAAK;EAC3D,OAAO,WAAW;GAAE,MAAM;GAAQ;EAAM;EACxC,OAAO,cAAc;GAAE,MAAM;GAAU,MAAM,EAAE,OAAO,MAAM;GAAG;EAAS;CAC1E,CAAC;CACD,MAAM,uBAAO,IAAI,QAAgB;CACjC,OAAO,kBAAkB;EACvB,MAAM;EAEN,SAAS,EAAE,UAAU,KAAK;EAC1B,KAAK,MAAM,KAAK;GACd,IAAI,CAAC,KAAK,MAAM,SAAS,IAAI,GAAG;GAChC,MAAM,SAAS,IAAI,OAAO,IAAI;GAC9B,IAAI,KAAK,IAAI,MAAM,GAAG;GACtB,KAAK,IAAI,MAAM;GACf,MAAM,WAAW,UAAU,WACzB,OAAO,UACP,OAAO,MACP,MACF;GACA,IAAI,UAAU,IAAI,YAAY,QAAQ,YAAY,QAAQ;EAC5D;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n createAttributeReader,\n createDelimitedTransform,\n scanSpans\n} from \"@mirrordown/core\";\nimport {\n defineMdastPlugin,\n markdownToMdast,\n type MdastPluginInstance,\n type MdastTarget,\n type PluginFactoryContext\n} from \"satteri\";\n\ntype TextVisitor = NonNullable<MdastPluginInstance[\"text\"]>;\n\n/**\n * The plugin's definition: only the keys it defines, with a synchronous visitor, so `markdownToHtml` returns its result directly.\n */\nexport interface DelPlugin {\n name: string;\n options: { position: boolean };\n text: (...args: Parameters<TextVisitor>) => void;\n}\n\n/**\n * Sätteri plugin for deletion syntax (`--text--`), wrapping each match in a `delete` node that renders as a `<del>` element. The scan is shared with the remark plugin and markdown-it's pairing rules through `@mirrordown/core`; it runs once per parent, the first time one of the parent's text nodes is visited.\n */\nexport const satteriDel =\n (): ((ctx: PluginFactoryContext) => DelPlugin) =>\n ({ source, features }) => {\n // Sätteri reads attribute blocks before plugins run, when the document's features turn them on: a block written right after a span is then the span's to take.\n const read =\n features.attributes === true\n ? createAttributeReader(markdownToMdast)\n : undefined;\n const transform = createDelimitedTransform<MdastTarget>(`-`, {\n text: (value) => ({ type: `text`, value }),\n wrap: (children) => ({ type: `delete`, data: { hName: `del` }, children })\n });\n const seen = new WeakSet<object>();\n return defineMdastPlugin({\n name: `del`,\n // Positions let the scan tell escaped markers (`\\--`) from real ones.\n options: { position: true },\n text(node, ctx) {\n if (!node.value.includes(`--`)) return;\n const parent = ctx.parent(node);\n if (seen.has(parent)) return;\n seen.add(parent);\n scanSpans(transform, parent, {\n source,\n read,\n parent: (of) => ctx.parent(of),\n setChildren: (of, children) => {\n ctx.setProperty(of, `children`, children);\n },\n setData: (of, data) => {\n ctx.setProperty(of, `data`, data);\n }\n });\n }\n });\n };\n"],"mappings":";;;;;;AA2BA,MAAa,oBAEV,EAAE,QAAQ,eAAe;CAExB,MAAM,OACJ,SAAS,eAAe,OACpB,sBAAsB,eAAe,IACrC,KAAA;CACN,MAAM,YAAY,yBAAsC,KAAK;EAC3D,OAAO,WAAW;GAAE,MAAM;GAAQ;EAAM;EACxC,OAAO,cAAc;GAAE,MAAM;GAAU,MAAM,EAAE,OAAO,MAAM;GAAG;EAAS;CAC1E,CAAC;CACD,MAAM,uBAAO,IAAI,QAAgB;CACjC,OAAO,kBAAkB;EACvB,MAAM;EAEN,SAAS,EAAE,UAAU,KAAK;EAC1B,KAAK,MAAM,KAAK;GACd,IAAI,CAAC,KAAK,MAAM,SAAS,IAAI,GAAG;GAChC,MAAM,SAAS,IAAI,OAAO,IAAI;GAC9B,IAAI,KAAK,IAAI,MAAM,GAAG;GACtB,KAAK,IAAI,MAAM;GACf,UAAU,WAAW,QAAQ;IAC3B;IACA;IACA,SAAS,OAAO,IAAI,OAAO,EAAE;IAC7B,cAAc,IAAI,aAAa;KAC7B,IAAI,YAAY,IAAI,YAAY,QAAQ;IAC1C;IACA,UAAU,IAAI,SAAS;KACrB,IAAI,YAAY,IAAI,QAAQ,IAAI;IAClC;GACF,CAAC;EACH;CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mirrordown/sat-del",
3
3
  "description": "A Sätteri plugin for deletion syntax (--text--), rendering <del> elements.",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "license": "MIT",
6
6
  "author": "Drake Costa <drake@saeris.io> (https://saeris.gg)",
7
7
  "repository": {
@@ -20,7 +20,7 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@mirrordown/core": "^0.1.4"
23
+ "@mirrordown/core": "^0.2.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "satteri": "^0.11.6"