@mirrordown/remd-sup 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
@@ -4,6 +4,13 @@
4
4
 
5
5
 
6
6
 
7
+
8
+ ## 0.2.1
9
+ <sub>2026-11-17</sub>
10
+
11
+ - *(patch)*
12
+ No change to what `^superscript^` renders. The guide now states what Sätteri's built-in superscript does differently, and that a footnote-style reference with no definition (`[^1] x^2^`) opens a superscript in every engine.
13
+
7
14
  ## 0.2.0
8
15
  <sub>2026-10-28</sub>
9
16
 
package/README.md CHANGED
@@ -24,12 +24,18 @@ The Pythagorean theorem: a^2^ + b^2^ = c^2^
24
24
 
25
25
  ### Formatting inside
26
26
 
27
- The content is inline markup, like emphasis: it can hold spaces, other formatting and subscript, but can't start or end with a space.
27
+ The content is inline markup, like emphasis: it can hold spaces, other formatting and subscript, but can't start or end with a space. As with emphasis, a caret between a letter or digit and punctuation doesn't open or close one, so `10^-3^` and `x^(2)^` stay as written; after a space it does (`x ^-1^`).
28
28
 
29
29
  ````markdown
30
30
  e^x~0~^ and the ^*n*th power^
31
31
  ````
32
32
 
33
+ A backslash keeps a caret literal (`x\^2\^`). A caret right after `[` opens a superscript like any other, so a footnote-style reference with no definition (`[^1] x^2^`) pairs with the next closing caret. A few things differ between the engines:
34
+
35
+ - Spans have to nest. When a superscript crosses a span another plugin builds (`==a ^b== c^`), each engine resolves it its own way. Crossing emphasis (`^a *b^ c*`) renders the same in all three.
36
+ - A run of two or more carets is plain text in markdown-it and remark. Sätteri pairs two runs of the same length, so `^^a^^` is a superscript there.
37
+ - Sätteri's superscript takes no attribute block: `x^2^{.s} y` sets the class with the markdown-it and remark attrs plugins and keeps the braces as text on Sätteri, where a block at the end of a paragraph, heading or list item sets the class on that element instead.
38
+
33
39
  ## Install
34
40
 
35
41
  ```sh
package/dist/index.d.mts CHANGED
@@ -12,7 +12,7 @@ export interface Superscript extends Parent {
12
12
  /** mdast-util-from-markdown extension turning `superscript` tokens into {@link Superscript} nodes. */
13
13
  export declare const superscriptFromMarkdown: Extension;
14
14
  /**
15
- * remark plugin for superscript syntax (`^text^`), parsed as a {@link Superscript} node that renders as a `<sup>` element. A single `^` is a delimiter run like emphasis, and its content is inline markup; it shares its syntax with `remd-sub` through `@mirrordown/core`, so the two nest and resolve crossing runs leftmost-first.
15
+ * remark plugin for superscript syntax (`^text^`), parsed as a {@link Superscript} node that renders as a `<sup>` element. A single `^` is a delimiter run like emphasis, and its content is inline markup; it shares its syntax with `remd-sub` through `@mirrordown/core`, so the two nest and resolve runs that cross each other leftmost-first.
16
16
  */
17
17
  export declare const remarkSup: Plugin<[], Root>;
18
18
  declare module "mdast" {
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ const superscriptFromMarkdown = {
15
15
  } }
16
16
  };
17
17
  /**
18
- * remark plugin for superscript syntax (`^text^`), parsed as a {@link Superscript} node that renders as a `<sup>` element. A single `^` is a delimiter run like emphasis, and its content is inline markup; it shares its syntax with `remd-sub` through `@mirrordown/core`, so the two nest and resolve crossing runs leftmost-first.
18
+ * remark plugin for superscript syntax (`^text^`), parsed as a {@link Superscript} node that renders as a `<sup>` element. A single `^` is a delimiter run like emphasis, and its content is inline markup; it shares its syntax with `remd-sub` through `@mirrordown/core`, so the two nest and resolve runs that cross each other leftmost-first.
19
19
  */
20
20
  const remarkSup = function() {
21
21
  const data = this.data();
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { Plugin } from \"unified\";\nimport type { Data, Nodes, Parent, PhrasingContent, Root } from \"mdast\";\nimport type {\n CompileContext,\n Extension as FromMarkdownExtension,\n Token\n} from \"mdast-util-from-markdown\";\nimport { scriptSyntax } from \"@mirrordown/core\";\n\n/** Optional data carried by a {@link Superscript} node. */\nexport interface SuperscriptData extends Data {}\n\n/** An mdast node for `^superscript^` text, rendered as a `<sup>` element. */\nexport interface Superscript extends Parent {\n type: `superscript`;\n children: PhrasingContent[];\n data?: SuperscriptData | undefined;\n}\n\n/** mdast-util-from-markdown extension turning `superscript` tokens into {@link Superscript} nodes. */\nexport const superscriptFromMarkdown: FromMarkdownExtension = {\n canContainEols: [`superscript`],\n enter: {\n superscript(this: CompileContext, token: Token) {\n const node: Superscript = {\n type: `superscript`,\n children: [],\n data: { hName: `sup` }\n };\n // The JSR build has no mdast augmentation, so `Superscript` is not in `Nodes` there.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion, typescript/no-unnecessary-type-assertion\n this.enter(node as unknown as Nodes, token);\n }\n },\n exit: {\n superscript(this: CompileContext, token: Token) {\n this.exit(token);\n }\n }\n};\n\n/**\n * remark plugin for superscript syntax (`^text^`), parsed as a {@link Superscript} node that renders as a `<sup>` element. A single `^` is a delimiter run like emphasis, and its content is inline markup; it shares its syntax with `remd-sub` through `@mirrordown/core`, so the two nest and resolve crossing runs leftmost-first.\n */\nexport const remarkSup: Plugin<[], Root> = function () {\n // this.data() in remark plugin context returns a generic shape; the cast narrows the known extension arrays.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const data = this.data() as {\n micromarkExtensions?: unknown[];\n fromMarkdownExtensions?: unknown[];\n };\n (data.micromarkExtensions ??= []).push(scriptSyntax(`^`));\n (data.fromMarkdownExtensions ??= []).push(superscriptFromMarkdown);\n};\n"],"mappings":";;;AAoBA,MAAa,0BAAiD;CAC5D,gBAAgB,CAAC,aAAa;CAC9B,OAAO,EACL,YAAkC,OAAc;EAQ9C,KAAK,MAAM;GANT,MAAM;GACN,UAAU,CAAC;GACX,MAAM,EAAE,OAAO,MAAM;EAIT,GAAuB,KAAK;CAC5C,EACF;CACA,MAAM,EACJ,YAAkC,OAAc;EAC9C,KAAK,KAAK,KAAK;CACjB,EACF;AACF;;;;AAKA,MAAa,YAA8B,WAAY;CAGrD,MAAM,OAAO,KAAK,KAAK;CAIvB,CAAC,KAAK,wBAAwB,CAAC,EAAA,CAAG,KAAK,aAAa,GAAG,CAAC;CACxD,CAAC,KAAK,2BAA2B,CAAC,EAAA,CAAG,KAAK,uBAAuB;AACnE"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import type { Plugin } from \"unified\";\nimport type { Data, Nodes, Parent, PhrasingContent, Root } from \"mdast\";\nimport type {\n CompileContext,\n Extension as FromMarkdownExtension,\n Token\n} from \"mdast-util-from-markdown\";\nimport { scriptSyntax } from \"@mirrordown/core\";\n\n/** Optional data carried by a {@link Superscript} node. */\nexport interface SuperscriptData extends Data {}\n\n/** An mdast node for `^superscript^` text, rendered as a `<sup>` element. */\nexport interface Superscript extends Parent {\n type: `superscript`;\n children: PhrasingContent[];\n data?: SuperscriptData | undefined;\n}\n\n/** mdast-util-from-markdown extension turning `superscript` tokens into {@link Superscript} nodes. */\nexport const superscriptFromMarkdown: FromMarkdownExtension = {\n canContainEols: [`superscript`],\n enter: {\n superscript(this: CompileContext, token: Token) {\n const node: Superscript = {\n type: `superscript`,\n children: [],\n data: { hName: `sup` }\n };\n // The JSR build has no mdast augmentation, so `Superscript` is not in `Nodes` there.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion, typescript/no-unnecessary-type-assertion\n this.enter(node as unknown as Nodes, token);\n }\n },\n exit: {\n superscript(this: CompileContext, token: Token) {\n this.exit(token);\n }\n }\n};\n\n/**\n * remark plugin for superscript syntax (`^text^`), parsed as a {@link Superscript} node that renders as a `<sup>` element. A single `^` is a delimiter run like emphasis, and its content is inline markup; it shares its syntax with `remd-sub` through `@mirrordown/core`, so the two nest and resolve runs that cross each other leftmost-first.\n */\nexport const remarkSup: Plugin<[], Root> = function () {\n // this.data() in remark plugin context returns a generic shape; the cast narrows the known extension arrays.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const data = this.data() as {\n micromarkExtensions?: unknown[];\n fromMarkdownExtensions?: unknown[];\n };\n (data.micromarkExtensions ??= []).push(scriptSyntax(`^`));\n (data.fromMarkdownExtensions ??= []).push(superscriptFromMarkdown);\n};\n"],"mappings":";;;AAoBA,MAAa,0BAAiD;CAC5D,gBAAgB,CAAC,aAAa;CAC9B,OAAO,EACL,YAAkC,OAAc;EAQ9C,KAAK,MAAM;GANT,MAAM;GACN,UAAU,CAAC;GACX,MAAM,EAAE,OAAO,MAAM;EAIT,GAAuB,KAAK;CAC5C,EACF;CACA,MAAM,EACJ,YAAkC,OAAc;EAC9C,KAAK,KAAK,KAAK;CACjB,EACF;AACF;;;;AAKA,MAAa,YAA8B,WAAY;CAGrD,MAAM,OAAO,KAAK,KAAK;CAIvB,CAAC,KAAK,wBAAwB,CAAC,EAAA,CAAG,KAAK,aAAa,GAAG,CAAC;CACxD,CAAC,KAAK,2BAA2B,CAAC,EAAA,CAAG,KAAK,uBAAuB;AACnE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mirrordown/remd-sup",
3
3
  "description": "A remark plugin for superscript syntax (^text^), rendering <sup> 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.0",
23
+ "@mirrordown/core": "^0.2.0",
24
24
  "mdast-util-from-markdown": "^2.0.3"
25
25
  },
26
26
  "devDependencies": {