@mirrordown/preset-remark 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 +13 -0
- package/README.md +105 -4
- package/dist/index.d.mts +57 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +69 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +7 -0
- package/package.json +57 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
<sub>2026-10-28</sub>
|
|
5
|
+
|
|
6
|
+
- *(minor)*
|
|
7
|
+
New presets for adopting the whole suite in one call: `@mirrordown/preset-markdown-it` (`md.use(mirrordown, options)`) and `@mirrordown/preset-remark` (`mirrordown(options)`, which plugs into Astro's `unified()` processor or a unified pipeline). Every feature is on by default, `false` turns one off, and an options object configures it. Each preset also ships a stylesheet that imports every plugin's CSS.
|
|
8
|
+
|
|
9
|
+
`mdit-autolink-headings` no longer adds an anchor to a heading whose id is empty (a heading with no text, such as one holding only an image): there is nothing to link to, and `remd-autolink-headings` already skipped it.
|
|
10
|
+
- *(patch)*
|
|
11
|
+
Attrs run after the other remark plugins, as `mdit-attrs` does in markdown-it, so attributes on a step title (`@1. Step {.cls}`) or a tab label (`% Tab {.cls}`) reach the step or tab instead of being dropped.
|
|
12
|
+
- *(patch)*
|
|
13
|
+
`remd-github-alerts` applies other plugins' `data` to a blockquote that isn't an alert, as remark-rehype's own handler does, so attributes on a blockquote (`> quote` then `{.note}`) are no longer dropped when alerts are on.
|
package/README.md
CHANGED
|
@@ -1,9 +1,110 @@
|
|
|
1
1
|
# @mirrordown/preset-remark
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified and markdown-it ecosystems.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The whole Mirrordown suite for remark and rehype in one call. Every feature is on by default and renders the same HTML as [`@mirrordown/preset-markdown-it`](https://github.com/mirrordown/mirrordown/tree/main/packages/preset-markdown-it). If you only want some features, install the individual `@mirrordown/remd-*` packages instead.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```sh
|
|
10
|
+
npm install @mirrordown/preset-remark
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
`mirrordown(options)` returns `{ remarkPlugins, rehypePlugins, remarkRehype, gfm, smartypants }`.
|
|
16
|
+
|
|
17
|
+
### Astro
|
|
18
|
+
|
|
19
|
+
The result is the shape Astro's `unified()` processor takes:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// astro.config.ts
|
|
23
|
+
import { defineConfig } from "astro/config";
|
|
24
|
+
import { unified } from "@astrojs/markdown-remark";
|
|
25
|
+
import { mirrordown } from "@mirrordown/preset-remark";
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
markdown: {
|
|
29
|
+
processor: unified(mirrordown())
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Unified
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { unified } from "unified";
|
|
38
|
+
import remarkParse from "remark-parse";
|
|
39
|
+
import remarkRehype from "remark-rehype";
|
|
40
|
+
import rehypeStringify from "rehype-stringify";
|
|
41
|
+
import { mirrordown } from "@mirrordown/preset-remark";
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
remarkPlugins,
|
|
45
|
+
rehypePlugins,
|
|
46
|
+
remarkRehype: remarkRehypeOptions
|
|
47
|
+
} = mirrordown();
|
|
48
|
+
|
|
49
|
+
const processor = unified()
|
|
50
|
+
.use(remarkParse)
|
|
51
|
+
.use(remarkPlugins)
|
|
52
|
+
.use(remarkRehype, remarkRehypeOptions)
|
|
53
|
+
.use(rehypePlugins)
|
|
54
|
+
.use(rehypeStringify);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Styles
|
|
58
|
+
|
|
59
|
+
Tabs, steps, alerts, spoilers, the lightbox and heading anchors ship stylesheets. Import them all at once:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import "@mirrordown/preset-remark/styles.css";
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Options
|
|
66
|
+
|
|
67
|
+
Every feature is on unless you set it to `false`. Features with options also take an options object, passed to their plugin:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
mirrordown({
|
|
71
|
+
lightbox: false,
|
|
72
|
+
githubAlerts: { icons: false },
|
|
73
|
+
slug: { prefix: "user-content-" }
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| Option | Syntax | Plugin |
|
|
78
|
+
| ------------------- | -------------------------------- | ------------------------------------- |
|
|
79
|
+
| `gfm` | tables, `~~strike~~`, task lists | `remark-gfm` |
|
|
80
|
+
| `abbr` | `*[HTML]: HyperText…` | `@mirrordown/remd-abbr` |
|
|
81
|
+
| `attrs` | `{.class #id}` | `@mirrordown/remd-attrs` |
|
|
82
|
+
| `autolinkHeadings` | anchor links on headings | `@mirrordown/remd-autolink-headings` |
|
|
83
|
+
| `definitionList` | `Term` / `: Definition` | `@mirrordown/remd-definition-list` |
|
|
84
|
+
| `del` | `--deleted--` | `@mirrordown/remd-del` |
|
|
85
|
+
| `githubAlerts` | `> [!NOTE]` | `@mirrordown/remd-github-alerts` |
|
|
86
|
+
| `ins` | `++inserted++` | `@mirrordown/remd-ins` |
|
|
87
|
+
| `kbd` | `[[Ctrl]]` | `@mirrordown/remd-kbd` |
|
|
88
|
+
| `lightbox` | `!` | `@mirrordown/remd-lightbox` |
|
|
89
|
+
| `mark` | `==highlight==` | `@mirrordown/remd-mark` |
|
|
90
|
+
| `ruby` | `{漢字\|かんじ}` | `@mirrordown/remd-ruby` |
|
|
91
|
+
| `sectionize` | headings wrapped in `<section>` | `@mirrordown/remd-sectionize` |
|
|
92
|
+
| `slug` | heading ids | `@mirrordown/remd-slug` |
|
|
93
|
+
| `spoiler` | `\|\|spoiler\|\|` | `@mirrordown/remd-spoiler` |
|
|
94
|
+
| `squeezeParagraphs` | empty paragraphs removed | `@mirrordown/remd-squeeze-paragraphs` |
|
|
95
|
+
| `steps` | `@1. Step` | `@mirrordown/remd-steps` |
|
|
96
|
+
| `sub` | `~subscript~` | `@mirrordown/remd-sub` |
|
|
97
|
+
| `sup` | `^superscript^` | `@mirrordown/remd-sup` |
|
|
98
|
+
| `tabs` | `% Tab` | `@mirrordown/remd-tabs` |
|
|
99
|
+
| `unwrapImages` | images not wrapped in `<p>` | `@mirrordown/remd-unwrap-images` |
|
|
100
|
+
|
|
101
|
+
## Notes
|
|
102
|
+
|
|
103
|
+
- **GFM is included.** The preset adds `remark-gfm` with single-tilde strikethrough off, so `~text~` is subscript and `~~text~~` is strikethrough. It returns `gfm: false` so a processor that adds its own GFM, like Astro's, doesn't add it again with single-tilde strikethrough on. Set `gfm: false` in the options to leave GFM out.
|
|
104
|
+
- **Smart punctuation stays off.** The preset returns `smartypants: false`: smart quotes and dashes would rewrite text that `del` and `attrs` read. To turn it on anyway, override it: `unified({ ...mirrordown(), smartypants: true })`.
|
|
105
|
+
- **`inline-svg` is not included.** It reads SVG files from disk and runs asynchronously; add [`@mirrordown/remd-inline-svg`](https://github.com/mirrordown/mirrordown/tree/main/packages/remd-inline-svg) to `rehypePlugins` yourself where that fits.
|
|
106
|
+
- **Braces at the end of a block are attributes.** With `attrs` on, `{…}` at the end of a paragraph, heading or list item is always read as attributes, even escaped; turn `attrs` off if your content ends blocks with literal braces.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT © [Drake Costa](https://saeris.gg)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AttrsOptions } from "@mirrordown/remd-attrs";
|
|
2
|
+
import { AutolinkHeadingsOptions } from "@mirrordown/remd-autolink-headings";
|
|
3
|
+
import { AlertOptions } from "@mirrordown/remd-github-alerts";
|
|
4
|
+
import { RubyOptions } from "@mirrordown/remd-ruby";
|
|
5
|
+
import { SlugOptions } from "@mirrordown/remd-slug";
|
|
6
|
+
import { StepsOptions } from "@mirrordown/remd-steps";
|
|
7
|
+
import { TabsOptions } from "@mirrordown/remd-tabs";
|
|
8
|
+
import { Root } from "hast";
|
|
9
|
+
import { Root as Root$1 } from "mdast";
|
|
10
|
+
import { Handler } from "mdast-util-to-hast";
|
|
11
|
+
import { Plugin } from "unified";
|
|
12
|
+
/** Every feature is on by default: `false` turns one off, an options object configures it. */
|
|
13
|
+
export interface MirrordownOptions {
|
|
14
|
+
/** GitHub Flavored Markdown through `remark-gfm`, with single-tilde strikethrough off so `~sub~` is subscript. */
|
|
15
|
+
gfm?: boolean;
|
|
16
|
+
abbr?: boolean;
|
|
17
|
+
attrs?: boolean | AttrsOptions;
|
|
18
|
+
autolinkHeadings?: boolean | AutolinkHeadingsOptions;
|
|
19
|
+
definitionList?: boolean;
|
|
20
|
+
del?: boolean;
|
|
21
|
+
githubAlerts?: boolean | AlertOptions;
|
|
22
|
+
ins?: boolean;
|
|
23
|
+
kbd?: boolean;
|
|
24
|
+
lightbox?: boolean;
|
|
25
|
+
mark?: boolean;
|
|
26
|
+
ruby?: boolean | RubyOptions;
|
|
27
|
+
sectionize?: boolean;
|
|
28
|
+
slug?: boolean | SlugOptions;
|
|
29
|
+
spoiler?: boolean;
|
|
30
|
+
squeezeParagraphs?: boolean;
|
|
31
|
+
steps?: boolean | StepsOptions;
|
|
32
|
+
sub?: boolean;
|
|
33
|
+
sup?: boolean;
|
|
34
|
+
tabs?: boolean | TabsOptions;
|
|
35
|
+
unwrapImages?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A plugin, alone or with its options. Narrower than unified's `PluggableList` (no presets or processors), so the lists also fit processors that only take plugins, such as Astro's `unified()`.
|
|
39
|
+
*/
|
|
40
|
+
export type PluginEntry<Tree extends Root$1 | Root> = Plugin<any[], Tree> | [Plugin<any[], Tree>, unknown];
|
|
41
|
+
/**
|
|
42
|
+
* The suite as unified pipeline pieces, in the shape Astro's `unified()` processor takes. `gfm` and `smartypants` are `false` for processors that add their own: GFM is already in `remarkPlugins`, configured for `~sub~`, and smart punctuation would rewrite the delimiters some plugins read.
|
|
43
|
+
*/
|
|
44
|
+
export interface MirrordownPreset {
|
|
45
|
+
remarkPlugins: Array<PluginEntry<Root$1>>;
|
|
46
|
+
rehypePlugins: Array<PluginEntry<Root>>;
|
|
47
|
+
remarkRehype: {
|
|
48
|
+
handlers: Record<string, Handler>;
|
|
49
|
+
};
|
|
50
|
+
gfm: false;
|
|
51
|
+
smartypants: false;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The full Mirrordown suite for remark and rehype. `inline-svg` is not included: it reads files from disk and runs asynchronously, so add `@mirrordown/remd-inline-svg` to `rehypePlugins` yourself where that fits.
|
|
55
|
+
*/
|
|
56
|
+
export declare const mirrordown: (options?: MirrordownOptions) => MirrordownPreset;
|
|
57
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["MdastRoot","HastRoot"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;iBA6CiB;;EAEf;EACA;EACA,kBAAkB;EAClB,6BAA6B;EAC7B;EACA;EACA,yBAAyB;EACzB;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EACA,iBAAiB;EACjB;EACA;EACA,kBAAkB;EAClB;EACA;EACA,iBAAiB;EACjB;;;;;YAMU,YAAY,aAAaA,SAAYC,QAG/C,cAAc,SAAS,cAAc;;;;iBAKtB;EACf,eAAe,MAAM,YAAYD;EACjC,eAAe,MAAM,YAAYC;EACjC;IAAgB,UAAU,eAAe;;EACzC;EACA;;;;;qBAMW,aACX,UAAS,sBACR"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import remarkGfm from "remark-gfm";
|
|
2
|
+
import { remarkAbbr } from "@mirrordown/remd-abbr";
|
|
3
|
+
import { remarkAttrs } from "@mirrordown/remd-attrs";
|
|
4
|
+
import { rehypeAutolinkHeadings } from "@mirrordown/remd-autolink-headings";
|
|
5
|
+
import { defListHastHandlers, remarkDefinitionList } from "@mirrordown/remd-definition-list";
|
|
6
|
+
import { remarkDel } from "@mirrordown/remd-del";
|
|
7
|
+
import { githubAlertsHastHandlers, remarkGithubAlerts } from "@mirrordown/remd-github-alerts";
|
|
8
|
+
import { remarkIns } from "@mirrordown/remd-ins";
|
|
9
|
+
import { remarkKbd } from "@mirrordown/remd-kbd";
|
|
10
|
+
import { rehypeLightbox } from "@mirrordown/remd-lightbox";
|
|
11
|
+
import { remarkMark } from "@mirrordown/remd-mark";
|
|
12
|
+
import { remarkRuby } from "@mirrordown/remd-ruby";
|
|
13
|
+
import { rehypeSectionize } from "@mirrordown/remd-sectionize";
|
|
14
|
+
import { rehypeSlug } from "@mirrordown/remd-slug";
|
|
15
|
+
import { remarkSpoiler, spoilerHastHandlers } from "@mirrordown/remd-spoiler";
|
|
16
|
+
import { rehypeSqueezeParagraphs } from "@mirrordown/remd-squeeze-paragraphs";
|
|
17
|
+
import { remarkSteps, stepsHastHandlers } from "@mirrordown/remd-steps";
|
|
18
|
+
import { remarkSub } from "@mirrordown/remd-sub";
|
|
19
|
+
import { remarkSup } from "@mirrordown/remd-sup";
|
|
20
|
+
import { remarkTabs, tabsHastHandlers } from "@mirrordown/remd-tabs";
|
|
21
|
+
import { rehypeUnwrapImages } from "@mirrordown/remd-unwrap-images";
|
|
22
|
+
// src/index.ts
|
|
23
|
+
/**
|
|
24
|
+
* The full Mirrordown suite for remark and rehype. `inline-svg` is not included: it reads files from disk and runs asynchronously, so add `@mirrordown/remd-inline-svg` to `rehypePlugins` yourself where that fits.
|
|
25
|
+
*/
|
|
26
|
+
const mirrordown = (options = {}) => {
|
|
27
|
+
const configured = (setting, plugin) => setting === false ? [] : setting === true || setting === void 0 ? [plugin] : [[plugin, setting]];
|
|
28
|
+
const on = (setting, plugin) => setting === false ? [] : [plugin];
|
|
29
|
+
const handlers = (setting, map) => setting === false ? {} : map;
|
|
30
|
+
return {
|
|
31
|
+
remarkPlugins: [
|
|
32
|
+
...options.gfm === false ? [] : [[remarkGfm, { singleTilde: false }]],
|
|
33
|
+
...on(options.abbr, remarkAbbr),
|
|
34
|
+
...on(options.definitionList, remarkDefinitionList),
|
|
35
|
+
...on(options.del, remarkDel),
|
|
36
|
+
...configured(options.githubAlerts, remarkGithubAlerts),
|
|
37
|
+
...on(options.ins, remarkIns),
|
|
38
|
+
...on(options.kbd, remarkKbd),
|
|
39
|
+
...on(options.mark, remarkMark),
|
|
40
|
+
...configured(options.ruby, remarkRuby),
|
|
41
|
+
...configured(options.steps, remarkSteps),
|
|
42
|
+
...on(options.spoiler, remarkSpoiler),
|
|
43
|
+
...on(options.sub, remarkSub),
|
|
44
|
+
...on(options.sup, remarkSup),
|
|
45
|
+
...configured(options.tabs, remarkTabs),
|
|
46
|
+
...configured(options.attrs, remarkAttrs)
|
|
47
|
+
],
|
|
48
|
+
rehypePlugins: [
|
|
49
|
+
...on(options.sectionize, rehypeSectionize),
|
|
50
|
+
...configured(options.slug, rehypeSlug),
|
|
51
|
+
...configured(options.autolinkHeadings, rehypeAutolinkHeadings),
|
|
52
|
+
...on(options.lightbox, rehypeLightbox),
|
|
53
|
+
...on(options.unwrapImages, rehypeUnwrapImages),
|
|
54
|
+
...on(options.squeezeParagraphs, rehypeSqueezeParagraphs)
|
|
55
|
+
],
|
|
56
|
+
remarkRehype: { handlers: {
|
|
57
|
+
...handlers(options.definitionList, defListHastHandlers),
|
|
58
|
+
...handlers(options.githubAlerts, githubAlertsHastHandlers),
|
|
59
|
+
...handlers(options.steps, stepsHastHandlers),
|
|
60
|
+
...handlers(options.spoiler, spoilerHastHandlers),
|
|
61
|
+
...handlers(options.tabs, tabsHastHandlers)
|
|
62
|
+
} },
|
|
63
|
+
gfm: false,
|
|
64
|
+
smartypants: false
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export { mirrordown };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Root as HastRoot } from \"hast\";\nimport type { Root as MdastRoot } from \"mdast\";\nimport type { Handler } from \"mdast-util-to-hast\";\nimport remarkGfm from \"remark-gfm\";\nimport type { Plugin } from \"unified\";\nimport { remarkAbbr } from \"@mirrordown/remd-abbr\";\nimport { remarkAttrs, type AttrsOptions } from \"@mirrordown/remd-attrs\";\nimport {\n rehypeAutolinkHeadings,\n type AutolinkHeadingsOptions\n} from \"@mirrordown/remd-autolink-headings\";\nimport {\n remarkDefinitionList,\n defListHastHandlers\n} from \"@mirrordown/remd-definition-list\";\nimport { remarkDel } from \"@mirrordown/remd-del\";\nimport {\n remarkGithubAlerts,\n githubAlertsHastHandlers,\n type AlertOptions\n} from \"@mirrordown/remd-github-alerts\";\nimport { remarkIns } from \"@mirrordown/remd-ins\";\nimport { remarkKbd } from \"@mirrordown/remd-kbd\";\nimport { rehypeLightbox } from \"@mirrordown/remd-lightbox\";\nimport { remarkMark } from \"@mirrordown/remd-mark\";\nimport { remarkRuby, type RubyOptions } from \"@mirrordown/remd-ruby\";\nimport { rehypeSectionize } from \"@mirrordown/remd-sectionize\";\nimport { rehypeSlug, type SlugOptions } from \"@mirrordown/remd-slug\";\nimport { remarkSpoiler, spoilerHastHandlers } from \"@mirrordown/remd-spoiler\";\nimport { rehypeSqueezeParagraphs } from \"@mirrordown/remd-squeeze-paragraphs\";\nimport {\n remarkSteps,\n stepsHastHandlers,\n type StepsOptions\n} from \"@mirrordown/remd-steps\";\nimport { remarkSub } from \"@mirrordown/remd-sub\";\nimport { remarkSup } from \"@mirrordown/remd-sup\";\nimport {\n remarkTabs,\n tabsHastHandlers,\n type TabsOptions\n} from \"@mirrordown/remd-tabs\";\nimport { rehypeUnwrapImages } from \"@mirrordown/remd-unwrap-images\";\n\n/** Every feature is on by default: `false` turns one off, an options object configures it. */\nexport interface MirrordownOptions {\n /** GitHub Flavored Markdown through `remark-gfm`, with single-tilde strikethrough off so `~sub~` is subscript. */\n gfm?: boolean;\n abbr?: boolean;\n attrs?: boolean | AttrsOptions;\n autolinkHeadings?: boolean | AutolinkHeadingsOptions;\n definitionList?: boolean;\n del?: boolean;\n githubAlerts?: boolean | AlertOptions;\n ins?: boolean;\n kbd?: boolean;\n lightbox?: boolean;\n mark?: boolean;\n ruby?: boolean | RubyOptions;\n sectionize?: boolean;\n slug?: boolean | SlugOptions;\n spoiler?: boolean;\n squeezeParagraphs?: boolean;\n steps?: boolean | StepsOptions;\n sub?: boolean;\n sup?: boolean;\n tabs?: boolean | TabsOptions;\n unwrapImages?: boolean;\n}\n\n/**\n * A plugin, alone or with its options. Narrower than unified's `PluggableList` (no presets or processors), so the lists also fit processors that only take plugins, such as Astro's `unified()`.\n */\nexport type PluginEntry<Tree extends MdastRoot | HastRoot> =\n // `any[]` parameters, as in the hosts' own plugin types: each plugin takes its own options.\n // oxlint-disable-next-line typescript/no-explicit-any\n Plugin<any[], Tree> | [Plugin<any[], Tree>, unknown];\n\n/**\n * The suite as unified pipeline pieces, in the shape Astro's `unified()` processor takes. `gfm` and `smartypants` are `false` for processors that add their own: GFM is already in `remarkPlugins`, configured for `~sub~`, and smart punctuation would rewrite the delimiters some plugins read.\n */\nexport interface MirrordownPreset {\n remarkPlugins: Array<PluginEntry<MdastRoot>>;\n rehypePlugins: Array<PluginEntry<HastRoot>>;\n remarkRehype: { handlers: Record<string, Handler> };\n gfm: false;\n smartypants: false;\n}\n\n/**\n * The full Mirrordown suite for remark and rehype. `inline-svg` is not included: it reads files from disk and runs asynchronously, so add `@mirrordown/remd-inline-svg` to `rehypePlugins` yourself where that fits.\n */\nexport const mirrordown = (\n options: MirrordownOptions = {}\n): MirrordownPreset => {\n // A plugin with options: `true` (or unset) uses its defaults.\n const configured = <O extends object, T extends MdastRoot | HastRoot>(\n setting: boolean | O | undefined,\n plugin: Plugin<[O?], T>\n ): Array<PluginEntry<T>> =>\n setting === false\n ? []\n : setting === true || setting === undefined\n ? [plugin]\n : [[plugin, setting]];\n const on = <T extends MdastRoot | HastRoot>(\n setting: boolean | undefined,\n plugin: Plugin<[], T>\n ): Array<PluginEntry<T>> => (setting === false ? [] : [plugin]);\n const handlers = (\n setting: unknown,\n map: Record<string, Handler>\n ): Record<string, Handler> => (setting === false ? {} : map);\n\n const gfm: Array<PluginEntry<MdastRoot>> =\n options.gfm === false ? [] : [[remarkGfm, { singleTilde: false }]];\n\n return {\n remarkPlugins: [\n ...gfm,\n ...on(options.abbr, remarkAbbr),\n ...on(options.definitionList, remarkDefinitionList),\n ...on(options.del, remarkDel),\n ...configured(options.githubAlerts, remarkGithubAlerts),\n ...on(options.ins, remarkIns),\n ...on(options.kbd, remarkKbd),\n ...on(options.mark, remarkMark),\n ...configured(options.ruby, remarkRuby),\n ...configured(options.steps, remarkSteps),\n ...on(options.spoiler, remarkSpoiler),\n ...on(options.sub, remarkSub),\n ...on(options.sup, remarkSup),\n ...configured(options.tabs, remarkTabs),\n // Attrs last, as markdown-it applies them after parsing: step titles, tab labels and the other plugins' nodes exist by then.\n ...configured(options.attrs, remarkAttrs)\n ],\n rehypePlugins: [\n ...on(options.sectionize, rehypeSectionize),\n ...configured(options.slug, rehypeSlug),\n ...configured(options.autolinkHeadings, rehypeAutolinkHeadings),\n ...on(options.lightbox, rehypeLightbox),\n ...on(options.unwrapImages, rehypeUnwrapImages),\n ...on(options.squeezeParagraphs, rehypeSqueezeParagraphs)\n ],\n remarkRehype: {\n handlers: {\n ...handlers(options.definitionList, defListHastHandlers),\n ...handlers(options.githubAlerts, githubAlertsHastHandlers),\n ...handlers(options.steps, stepsHastHandlers),\n ...handlers(options.spoiler, spoilerHastHandlers),\n ...handlers(options.tabs, tabsHastHandlers)\n }\n },\n gfm: false,\n smartypants: false\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,MAAa,cACX,UAA6B,CAAC,MACT;CAErB,MAAM,cACJ,SACA,WAEA,YAAY,QACR,CAAC,IACD,YAAY,QAAQ,YAAY,KAAA,IAC9B,CAAC,MAAM,IACP,CAAC,CAAC,QAAQ,OAAO,CAAC;CAC1B,MAAM,MACJ,SACA,WAC2B,YAAY,QAAQ,CAAC,IAAI,CAAC,MAAM;CAC7D,MAAM,YACJ,SACA,QAC6B,YAAY,QAAQ,CAAC,IAAI;CAKxD,OAAO;EACL,eAAe;GACb,GAJF,QAAQ,QAAQ,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,aAAa,MAAM,CAAC,CAAC;GAK/D,GAAG,GAAG,QAAQ,MAAM,UAAU;GAC9B,GAAG,GAAG,QAAQ,gBAAgB,oBAAoB;GAClD,GAAG,GAAG,QAAQ,KAAK,SAAS;GAC5B,GAAG,WAAW,QAAQ,cAAc,kBAAkB;GACtD,GAAG,GAAG,QAAQ,KAAK,SAAS;GAC5B,GAAG,GAAG,QAAQ,KAAK,SAAS;GAC5B,GAAG,GAAG,QAAQ,MAAM,UAAU;GAC9B,GAAG,WAAW,QAAQ,MAAM,UAAU;GACtC,GAAG,WAAW,QAAQ,OAAO,WAAW;GACxC,GAAG,GAAG,QAAQ,SAAS,aAAa;GACpC,GAAG,GAAG,QAAQ,KAAK,SAAS;GAC5B,GAAG,GAAG,QAAQ,KAAK,SAAS;GAC5B,GAAG,WAAW,QAAQ,MAAM,UAAU;GAEtC,GAAG,WAAW,QAAQ,OAAO,WAAW;EAC1C;EACA,eAAe;GACb,GAAG,GAAG,QAAQ,YAAY,gBAAgB;GAC1C,GAAG,WAAW,QAAQ,MAAM,UAAU;GACtC,GAAG,WAAW,QAAQ,kBAAkB,sBAAsB;GAC9D,GAAG,GAAG,QAAQ,UAAU,cAAc;GACtC,GAAG,GAAG,QAAQ,cAAc,kBAAkB;GAC9C,GAAG,GAAG,QAAQ,mBAAmB,uBAAuB;EAC1D;EACA,cAAc,EACZ,UAAU;GACR,GAAG,SAAS,QAAQ,gBAAgB,mBAAmB;GACvD,GAAG,SAAS,QAAQ,cAAc,wBAAwB;GAC1D,GAAG,SAAS,QAAQ,OAAO,iBAAiB;GAC5C,GAAG,SAAS,QAAQ,SAAS,mBAAmB;GAChD,GAAG,SAAS,QAAQ,MAAM,gBAAgB;EAC5C,EACF;EACA,KAAK;EACL,aAAa;CACf;AACF"}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* Every Mirrordown remark/rehype plugin's stylesheet, so one import styles the whole suite. */
|
|
2
|
+
@import "@mirrordown/remd-autolink-headings/autolink-headings.css";
|
|
3
|
+
@import "@mirrordown/remd-github-alerts/github-alerts.css";
|
|
4
|
+
@import "@mirrordown/remd-lightbox/lightbox.css";
|
|
5
|
+
@import "@mirrordown/remd-spoiler/spoiler.css";
|
|
6
|
+
@import "@mirrordown/remd-steps/steps.css";
|
|
7
|
+
@import "@mirrordown/remd-tabs/tabs.css";
|
package/package.json
CHANGED
|
@@ -1,11 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirrordown/preset-remark",
|
|
3
|
-
"version": "0.0.0",
|
|
4
3
|
"description": "The full Mirrordown suite for remark/rehype (unified) in one call.",
|
|
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
|
+
"./*.css": "./dist/*.css"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@mirrordown/remd-abbr": "^0.1.4",
|
|
25
|
+
"@mirrordown/remd-attrs": "^0.2.0",
|
|
26
|
+
"@mirrordown/remd-autolink-headings": "^0.1.1",
|
|
27
|
+
"@mirrordown/remd-definition-list": "^0.2.1",
|
|
28
|
+
"@mirrordown/remd-del": "^0.1.4",
|
|
29
|
+
"@mirrordown/remd-github-alerts": "^0.2.0",
|
|
30
|
+
"@mirrordown/remd-ins": "^0.1.4",
|
|
31
|
+
"@mirrordown/remd-kbd": "^0.1.4",
|
|
32
|
+
"@mirrordown/remd-lightbox": "^0.1.1",
|
|
33
|
+
"@mirrordown/remd-mark": "^0.1.4",
|
|
34
|
+
"@mirrordown/remd-ruby": "^0.1.4",
|
|
35
|
+
"@mirrordown/remd-sectionize": "^0.1.1",
|
|
36
|
+
"@mirrordown/remd-slug": "^0.1.1",
|
|
37
|
+
"@mirrordown/remd-spoiler": "^0.1.1",
|
|
38
|
+
"@mirrordown/remd-squeeze-paragraphs": "^0.1.1",
|
|
39
|
+
"@mirrordown/remd-steps": "^0.1.4",
|
|
40
|
+
"@mirrordown/remd-sub": "^0.2.0",
|
|
41
|
+
"@mirrordown/remd-sup": "^0.2.0",
|
|
42
|
+
"@mirrordown/remd-tabs": "^0.2.0",
|
|
43
|
+
"@mirrordown/remd-unwrap-images": "^0.1.4",
|
|
44
|
+
"mdast-util-to-hast": "^13.0.0",
|
|
45
|
+
"remark-gfm": "^4.0.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/hast": "^3.0.4",
|
|
49
|
+
"@types/mdast": "^4.0.4",
|
|
50
|
+
"unified": "^11.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"unified": "^11.0.0"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=24.0.0"
|
|
57
|
+
},
|
|
58
|
+
"bumpy": {
|
|
59
|
+
"publishCommand": [
|
|
60
|
+
"node ../../scripts/sync-jsr-version.mjs",
|
|
61
|
+
"node ../../scripts/npm-publish.mjs",
|
|
62
|
+
"node ../../scripts/jsr-resolve-deps.mjs",
|
|
63
|
+
"node ../../scripts/jsr-publish.mjs"
|
|
64
|
+
]
|
|
10
65
|
}
|
|
11
|
-
}
|
|
66
|
+
}
|