@mirrordown/sat-abbr 0.0.0 → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+ <sub>2026-10-28</sub>
5
+
6
+ - *(minor)*
7
+ New `@mirrordown/sat-abbr`: abbreviations (`*[term]: definition`) for Sätteri, with the same output as `remd-abbr` and `mdit-abbr`, and included in `@mirrordown/preset-satteri`. The definition and term rules move into `@mirrordown/core` (`parseAbbreviations`, `createAbbreviationScan`), which `remd-abbr` now uses too; its output is unchanged.
8
+ - *(patch)*
9
+ Sätteri 0.11 reads attribute blocks and definition lists the way Mirrordown's other engines do, so the Sätteri suite now covers every feature:
10
+
11
+ - `preset-satteri` has `attrs` and `definitionList` options, on by default like the other presets, which turn on Sätteri's own `attributes` and `definitionList` features. With them, the preset renders every shared fixture as `preset-remark` and `preset-markdown-it` do.
12
+ - The `sat-*` packages accept Sätteri 0.11 as well as 0.10 (`^0.10.5 || ^0.11.0`); Astro's Sätteri integration is still on 0.10, where the plugins work as before.
13
+ - An attribute block ending a tab or step header (`% Tab {.tab}`, `@1. Step {.step}`) now goes on the item in `sat-tabs` and `sat-steps`, as in the other engines: Sätteri read it off the header's paragraph before recognition, and the item didn't get it.
14
+ - `sat-ruby` parses a ruby's base and reading with the document's features, which Sätteri 0.11.3 and later tell plugins; its `features` option is only needed with an older Sätteri.
package/README.md CHANGED
@@ -1,9 +1,64 @@
1
1
  # @mirrordown/sat-abbr
2
2
 
3
- 🐣 This package name has been claimed with [fledgling](https://github.com/dmno-dev/fledgling) for [https://github.com/mirrordown/mirrordown](https://github.com/mirrordown/mirrordown), and a real release will land here soon.
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
- This is a placeholder — there is nothing to install yet.
5
+ A Sätteri plugin for the `abbr` syntax extension.
6
6
 
7
- ---
7
+ ## Overview
8
8
 
9
- Want to claim a name of your own? Run `npx fledgling add <name> --new --yes` — it reserves the name on npm and can set up token-less (OIDC trusted) publishing for when you are ready.
9
+ The `abbr` plugin lets you define abbreviations once and automatically wraps every occurrence in an `<abbr>` element with a `title` attribute for the full expansion.
10
+
11
+ ```html
12
+ <abbr title="HyperText Markup Language">HTML</abbr>
13
+ ```
14
+
15
+ ## Syntax
16
+
17
+ Define abbreviations anywhere in the document using the `*[ABBR]: Full text` syntax. Definitions are removed from the output and all matching words are wrapped automatically.
18
+
19
+ ````markdown
20
+ *[HTML]: HyperText Markup Language
21
+ *[CSS]: Cascading Style Sheets
22
+
23
+ Write HTML and CSS as normal — they are automatically expanded with tooltips.
24
+ ````
25
+
26
+ ## Install
27
+
28
+ ```sh
29
+ npm install @mirrordown/sat-abbr
30
+ ```
31
+
32
+ ### Standalone
33
+
34
+ ```ts
35
+ import { markdownToHtml } from "satteri";
36
+ import { satteriAbbr } from "@mirrordown/sat-abbr";
37
+
38
+ const { html } = markdownToHtml(source, {
39
+ mdastPlugins: [satteriAbbr()],
40
+ });
41
+ ```
42
+
43
+ ### Astro
44
+
45
+ ```ts
46
+ // astro.config.ts
47
+ import { defineConfig } from "astro/config";
48
+ import { satteri } from "@astrojs/markdown-satteri";
49
+ import { satteriAbbr } from "@mirrordown/sat-abbr";
50
+
51
+ export default defineConfig({
52
+ markdown: {
53
+ processor: satteri({ mdastPlugins: [satteriAbbr()] }),
54
+ },
55
+ });
56
+ ```
57
+
58
+ ## Documentation
59
+
60
+ Full documentation, more examples, and configuration options: [github.com/mirrordown/mirrordown](https://github.com/mirrordown/mirrordown) (dedicated docs site coming soon).
61
+
62
+ ## License
63
+
64
+ MIT © [Drake Costa](https://saeris.gg)
@@ -0,0 +1,17 @@
1
+ import { MdastPluginInstance, PluginFactoryContext } from "satteri";
2
+ type TextVisitor = NonNullable<MdastPluginInstance["text"]>;
3
+ type BeforeHook = NonNullable<MdastPluginInstance["before"]>;
4
+ /**
5
+ * The plugin's definition: only the keys it defines, with synchronous visitors, so `markdownToHtml` returns its result directly.
6
+ */
7
+ export interface AbbrPlugin {
8
+ name: string;
9
+ before: (...args: Parameters<BeforeHook>) => void;
10
+ text: (...args: Parameters<TextVisitor>) => void;
11
+ }
12
+ /**
13
+ * Sätteri plugin for abbreviations: a paragraph of `*[term]: definition` lines defines them (and is removed), and each defined term elsewhere renders as `<abbr title="definition">`. The definition and term rules are shared with the markdown-it and remark plugins through `@mirrordown/core`.
14
+ */
15
+ export declare const satteriAbbr: () => ((ctx: PluginFactoryContext) => AbbrPlugin);
16
+ export {};
17
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAQK,cAAc,YAAY;KAC1B,aAAa,YAAY;;;;iBAKb;EACf;EACA,YAAY,MAAM,WAAW;EAC7B,UAAU,MAAM,WAAW;;;;;qBAMhB,qBACL,KAAK,yBAAyB"}
package/dist/index.mjs ADDED
@@ -0,0 +1,51 @@
1
+ import { createAbbreviationScan, parseAbbreviations } from "@mirrordown/core";
2
+ import { defineMdastPlugin } from "satteri";
3
+ // src/index.ts
4
+ /**
5
+ * Sätteri plugin for abbreviations: a paragraph of `*[term]: definition` lines defines them (and is removed), and each defined term elsewhere renders as `<abbr title="definition">`. The definition and term rules are shared with the markdown-it and remark plugins through `@mirrordown/core`.
6
+ */
7
+ const satteriAbbr = () => () => {
8
+ let scan;
9
+ return defineMdastPlugin({
10
+ name: `abbr`,
11
+ before(root, ctx) {
12
+ const abbreviations = /* @__PURE__ */ new Map();
13
+ const walk = (node) => {
14
+ if (!(`children` in node)) return;
15
+ if (node.type === `paragraph`) {
16
+ const [only] = node.children;
17
+ const definitions = node.children.length === 1 && only?.type === `text` && typeof only.value === `string` ? parseAbbreviations(only.value) : void 0;
18
+ if (definitions) {
19
+ for (const [term, title] of definitions) if (!abbreviations.has(term)) abbreviations.set(term, title);
20
+ ctx.removeNode(node);
21
+ }
22
+ return;
23
+ }
24
+ node.children.forEach(walk);
25
+ };
26
+ walk(root);
27
+ scan = abbreviations.size > 0 ? createAbbreviationScan(abbreviations) : void 0;
28
+ },
29
+ text(node, ctx) {
30
+ const parts = scan?.(node.value);
31
+ if (!parts) return;
32
+ ctx.replaceNode(node, parts.map((part) => `text` in part ? {
33
+ type: `text`,
34
+ value: part.text
35
+ } : {
36
+ type: `abbr`,
37
+ data: {
38
+ hName: `abbr`,
39
+ hProperties: { title: part.title }
40
+ },
41
+ children: [{
42
+ type: `text`,
43
+ value: part.term
44
+ }]
45
+ }));
46
+ }
47
+ });
48
+ };
49
+ export { satteriAbbr };
50
+
51
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { createAbbreviationScan, parseAbbreviations } from \"@mirrordown/core\";\nimport {\n defineMdastPlugin,\n type MdastPluginInstance,\n type MdastTarget,\n type PluginFactoryContext\n} from \"satteri\";\n\ntype TextVisitor = NonNullable<MdastPluginInstance[\"text\"]>;\ntype BeforeHook = NonNullable<MdastPluginInstance[\"before\"]>;\n\n/**\n * The plugin's definition: only the keys it defines, with synchronous visitors, so `markdownToHtml` returns its result directly.\n */\nexport interface AbbrPlugin {\n name: string;\n before: (...args: Parameters<BeforeHook>) => void;\n text: (...args: Parameters<TextVisitor>) => void;\n}\n\n/**\n * Sätteri plugin for abbreviations: a paragraph of `*[term]: definition` lines defines them (and is removed), and each defined term elsewhere renders as `<abbr title=\"definition\">`. The definition and term rules are shared with the markdown-it and remark plugins through `@mirrordown/core`.\n */\nexport const satteriAbbr =\n (): ((ctx: PluginFactoryContext) => AbbrPlugin) => () => {\n let scan: ReturnType<typeof createAbbreviationScan> | undefined;\n return defineMdastPlugin({\n name: `abbr`,\n // Definitions can follow their uses, so they are all collected before any text is visited.\n before(root, ctx) {\n const abbreviations = new Map<string, string>();\n const walk = (node: MdastTarget): void => {\n if (!(`children` in node)) return;\n if (node.type === `paragraph`) {\n const [only] = node.children;\n const definitions =\n node.children.length === 1 &&\n only?.type === `text` &&\n typeof only.value === `string`\n ? parseAbbreviations(only.value)\n : undefined;\n if (definitions) {\n // The first definition of a term wins.\n for (const [term, title] of definitions) {\n if (!abbreviations.has(term)) abbreviations.set(term, title);\n }\n ctx.removeNode(node);\n }\n return;\n }\n node.children.forEach(walk);\n };\n walk(root);\n scan =\n abbreviations.size > 0\n ? createAbbreviationScan(abbreviations)\n : undefined;\n },\n text(node, ctx) {\n const parts = scan?.(node.value);\n if (!parts) return;\n ctx.replaceNode(\n node,\n parts.map((part): MdastTarget =>\n `text` in part\n ? { type: `text`, value: part.text }\n : {\n type: `abbr`,\n data: { hName: `abbr`, hProperties: { title: part.title } },\n children: [{ type: `text`, value: part.term }]\n }\n )\n );\n }\n });\n };\n"],"mappings":";;;;;;AAuBA,MAAa,0BAC8C;CACvD,IAAI;CACJ,OAAO,kBAAkB;EACvB,MAAM;EAEN,OAAO,MAAM,KAAK;GAChB,MAAM,gCAAgB,IAAI,IAAoB;GAC9C,MAAM,QAAQ,SAA4B;IACxC,IAAI,EAAE,cAAc,OAAO;IAC3B,IAAI,KAAK,SAAS,aAAa;KAC7B,MAAM,CAAC,QAAQ,KAAK;KACpB,MAAM,cACJ,KAAK,SAAS,WAAW,KACzB,MAAM,SAAS,UACf,OAAO,KAAK,UAAU,WAClB,mBAAmB,KAAK,KAAK,IAC7B,KAAA;KACN,IAAI,aAAa;MAEf,KAAK,MAAM,CAAC,MAAM,UAAU,aAC1B,IAAI,CAAC,cAAc,IAAI,IAAI,GAAG,cAAc,IAAI,MAAM,KAAK;MAE7D,IAAI,WAAW,IAAI;KACrB;KACA;IACF;IACA,KAAK,SAAS,QAAQ,IAAI;GAC5B;GACA,KAAK,IAAI;GACT,OACE,cAAc,OAAO,IACjB,uBAAuB,aAAa,IACpC,KAAA;EACR;EACA,KAAK,MAAM,KAAK;GACd,MAAM,QAAQ,OAAO,KAAK,KAAK;GAC/B,IAAI,CAAC,OAAO;GACZ,IAAI,YACF,MACA,MAAM,KAAK,SACT,UAAU,OACN;IAAE,MAAM;IAAQ,OAAO,KAAK;GAAK,IACjC;IACE,MAAM;IACN,MAAM;KAAE,OAAO;KAAQ,aAAa,EAAE,OAAO,KAAK,MAAM;IAAE;IAC1D,UAAU,CAAC;KAAE,MAAM;KAAQ,OAAO,KAAK;IAAK,CAAC;GAC/C,CACN,CACF;EACF;CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,11 +1,42 @@
1
1
  {
2
2
  "name": "@mirrordown/sat-abbr",
3
- "version": "0.0.0",
4
3
  "description": "A Sätteri plugin for abbreviations (*[term]: definition), rendering <abbr> elements.",
4
+ "version": "0.1.0",
5
5
  "license": "MIT",
6
6
  "author": "Drake Costa <drake@saeris.io> (https://saeris.gg)",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/mirrordown/mirrordown.git"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "development": "./src/index.ts",
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs"
20
+ }
21
+ },
22
+ "dependencies": {
23
+ "@mirrordown/core": "^0.1.0"
24
+ },
25
+ "devDependencies": {
26
+ "satteri": "^0.11.5"
27
+ },
28
+ "peerDependencies": {
29
+ "satteri": "^0.10.5 || ^0.11.0"
30
+ },
31
+ "engines": {
32
+ "node": ">=24.0.0"
33
+ },
34
+ "bumpy": {
35
+ "publishCommand": [
36
+ "node ../../scripts/sync-jsr-version.mjs",
37
+ "node ../../scripts/npm-publish.mjs",
38
+ "node ../../scripts/jsr-resolve-deps.mjs",
39
+ "node ../../scripts/jsr-publish.mjs"
40
+ ]
10
41
  }
11
- }
42
+ }