orz-markdown 1.0.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/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +159 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/attrs.d.ts +3 -0
- package/dist/plugins/attrs.d.ts.map +1 -0
- package/dist/plugins/attrs.js +60 -0
- package/dist/plugins/attrs.js.map +1 -0
- package/dist/plugins/emoji.d.ts +2 -0
- package/dist/plugins/emoji.d.ts.map +1 -0
- package/dist/plugins/emoji.js +51 -0
- package/dist/plugins/emoji.js.map +1 -0
- package/dist/plugins/markdown-include.d.ts +3 -0
- package/dist/plugins/markdown-include.d.ts.map +1 -0
- package/dist/plugins/markdown-include.js +44 -0
- package/dist/plugins/markdown-include.js.map +1 -0
- package/dist/plugins/mermaid.d.ts +2 -0
- package/dist/plugins/mermaid.d.ts.map +1 -0
- package/dist/plugins/mermaid.js +18 -0
- package/dist/plugins/mermaid.js.map +1 -0
- package/dist/plugins/nyml.d.ts +2 -0
- package/dist/plugins/nyml.d.ts.map +1 -0
- package/dist/plugins/nyml.js +21 -0
- package/dist/plugins/nyml.js.map +1 -0
- package/dist/plugins/nyml_parser.d.ts +32 -0
- package/dist/plugins/nyml_parser.d.ts.map +1 -0
- package/dist/plugins/nyml_parser.js +236 -0
- package/dist/plugins/nyml_parser.js.map +1 -0
- package/dist/plugins/qrcode.d.ts +2 -0
- package/dist/plugins/qrcode.d.ts.map +1 -0
- package/dist/plugins/qrcode.js +21 -0
- package/dist/plugins/qrcode.js.map +1 -0
- package/dist/plugins/smiles.d.ts +2 -0
- package/dist/plugins/smiles.d.ts.map +1 -0
- package/dist/plugins/smiles.js +19 -0
- package/dist/plugins/smiles.js.map +1 -0
- package/dist/plugins/space.d.ts +2 -0
- package/dist/plugins/space.d.ts.map +1 -0
- package/dist/plugins/space.js +15 -0
- package/dist/plugins/space.js.map +1 -0
- package/dist/plugins/span.d.ts +3 -0
- package/dist/plugins/span.d.ts.map +1 -0
- package/dist/plugins/span.js +18 -0
- package/dist/plugins/span.js.map +1 -0
- package/dist/plugins/test.d.ts +2 -0
- package/dist/plugins/test.d.ts.map +1 -0
- package/dist/plugins/test.js +14 -0
- package/dist/plugins/test.js.map +1 -0
- package/dist/plugins/toc.d.ts +3 -0
- package/dist/plugins/toc.d.ts.map +1 -0
- package/dist/plugins/toc.js +62 -0
- package/dist/plugins/toc.js.map +1 -0
- package/dist/plugins/yaml.d.ts +2 -0
- package/dist/plugins/yaml.d.ts.map +1 -0
- package/dist/plugins/yaml.js +12 -0
- package/dist/plugins/yaml.js.map +1 -0
- package/dist/plugins/youtube.d.ts +2 -0
- package/dist/plugins/youtube.d.ts.map +1 -0
- package/dist/plugins/youtube.js +19 -0
- package/dist/plugins/youtube.js.map +1 -0
- package/dist/prepare-sources.d.ts +10 -0
- package/dist/prepare-sources.d.ts.map +1 -0
- package/dist/prepare-sources.js +31 -0
- package/dist/prepare-sources.js.map +1 -0
- package/dist/registry.d.ts +10 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +24 -0
- package/dist/registry.js.map +1 -0
- package/dist/rules/block-dispatcher.d.ts +9 -0
- package/dist/rules/block-dispatcher.d.ts.map +1 -0
- package/dist/rules/block-dispatcher.js +108 -0
- package/dist/rules/block-dispatcher.js.map +1 -0
- package/dist/rules/inline-dispatcher.d.ts +9 -0
- package/dist/rules/inline-dispatcher.d.ts.map +1 -0
- package/dist/rules/inline-dispatcher.js +62 -0
- package/dist/rules/inline-dispatcher.js.map +1 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +128 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +70 -0
- package/themes/beige-decent-1.css +559 -0
- package/themes/beige-decent-2.css +578 -0
- package/themes/common.css +178 -0
- package/themes/dark-elegant-1.css +729 -0
- package/themes/dark-elegant-2.css +1376 -0
- package/themes/light-academic-1.css +541 -0
- package/themes/light-academic-2.css +462 -0
- package/themes/light-neat-1.css +1244 -0
- package/themes/light-neat-2.css +1185 -0
- package/themes/light-playful-1.css +493 -0
- package/themes/light-playful-2.css +494 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yu Wang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# orz-markdown
|
|
2
|
+
|
|
3
|
+
A deeply customized markdown-it parser configured with several official plugins and many custom plugins designed to render interactive objects, embedded rich media, and invisible data. Crafted alongside beautifully optimized CSS themes for an excellent out-of-the-box rendering experience. An agent skill is available for using this markdown parser with AI agents.
|
|
4
|
+
|
|
5
|
+
Rendered HTML is intended to live inside a `.markdown-body` container and be paired with one of the bundled themes.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the package via npm:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install orz-markdown
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Import the configured markdown instance and use it to render markdown strings into HTML:
|
|
18
|
+
|
|
19
|
+
> **HTML Support:** The parser is initialized with `html: true`, so any raw
|
|
20
|
+
> HTML tags included in your markdown (e.g. `<div>Example</div>`) will be
|
|
21
|
+
> emitted verbatim instead of being escaped. Be aware of XSS risks when
|
|
22
|
+
> rendering untrusted content.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import md from 'orz-markdown';
|
|
27
|
+
|
|
28
|
+
const markdownSource = `
|
|
29
|
+
# Hello World
|
|
30
|
+
{{emoji wave}} This is a customized inline parsed text!
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const html = md.render(markdownSource);
|
|
34
|
+
|
|
35
|
+
document.body.innerHTML = `<article class="markdown-body">${html}</article>`;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Browser Runtime
|
|
39
|
+
|
|
40
|
+
Some rendered features expect a small browser runtime layer after the HTML is mounted. This currently includes QR-code expand/collapse behavior and is designed so more client-side enhancements can share the same entry point.
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
import { getBrowserRuntimeScript } from 'orz-markdown/runtime';
|
|
44
|
+
|
|
45
|
+
const runtimeScript = document.createElement('script');
|
|
46
|
+
runtimeScript.textContent = getBrowserRuntimeScript();
|
|
47
|
+
document.body.appendChild(runtimeScript);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If your app controls initialization directly, the runtime also exposes `window.OrzMarkdownRuntime.init(root)` and `window.OrzMarkdownRuntime.initQrCodes(root)`.
|
|
51
|
+
|
|
52
|
+
## Themes
|
|
53
|
+
|
|
54
|
+
We provide multiple ready-to-use CSS themes for rendering the output! You do not need to style the custom plugins from scratch.
|
|
55
|
+
|
|
56
|
+
Themes can be easily imported directly from the `themes` directory if you are using a bundler (like Vite, Webpack, etc.):
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
import 'orz-markdown/themes/light-academic-1.css';
|
|
60
|
+
// Or try: dark-elegant-2.css, light-playful-1.css, etc!
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Each shipped theme now imports a shared structural stylesheet internally, so you only need to import a single theme file.
|
|
64
|
+
|
|
65
|
+
The bundled themes cover the parser's custom output, including:
|
|
66
|
+
|
|
67
|
+
- semantic containers
|
|
68
|
+
- tabs and columns
|
|
69
|
+
- KaTeX blocks
|
|
70
|
+
- Mermaid placeholders
|
|
71
|
+
- SMILES canvases
|
|
72
|
+
- clickable QR codes with overlay expansion hooks
|
|
73
|
+
|
|
74
|
+
For a full list of provided themes and the underlying CSS class reference for theme authors, please read the [Themes Documentation](themes/README.md).
|
|
75
|
+
|
|
76
|
+
## Packaging
|
|
77
|
+
|
|
78
|
+
To rebuild distributable assets locally:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npm run build
|
|
82
|
+
npm test
|
|
83
|
+
npm pack
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The generated tarball is written to the repository root and includes `dist/` and `themes/`.
|
|
87
|
+
|
|
88
|
+
## Official Plugins Bundled
|
|
89
|
+
|
|
90
|
+
This project builds upon `markdown-it` and pre-configures a curated selection of official and popular community plugins.
|
|
91
|
+
|
|
92
|
+
- **markdown-it-anchor**: Header anchors
|
|
93
|
+
- **markdown-it-container**:
|
|
94
|
+
- Semantic Blocks: `success`, `info`, `warning`, `danger`
|
|
95
|
+
- Layout Blocks: `left` (optional CSS width arg, e.g. `::: left 30%`), `right`, `center`
|
|
96
|
+
- Interactive Blocks: `spoil` (spoilers), `tabs/tab`, `cols/col` (optional width ratios, e.g. `:::: cols 1 2 1`)
|
|
97
|
+
- Arbitrary class: any `::: ClassName` not in the reserved list above becomes `<div class="ClassName">`
|
|
98
|
+
- Note: a space between `:::` and the name is required; nesting uses more colons on the outer level
|
|
99
|
+
- **markdown-it-footnote**: Footnotes syntax (`[^1]`)
|
|
100
|
+
- **markdown-it-imsize**: Image sizing (``)
|
|
101
|
+
- **markdown-it-mark**: Highlighted text (`==marked==`)
|
|
102
|
+
- **markdown-it-sub** & **markdown-it-sup**: Subscript (`~sub~`) and Superscript (`^sup^`)
|
|
103
|
+
- **markdown-it-ins**: Inserted text (`++inserted++`)
|
|
104
|
+
- **markdown-it-task-lists**: GitHub-style task lists (`- [x] Task`)
|
|
105
|
+
- **@traptitech/markdown-it-katex**: Math rendering, capable of rendering block math (`$$E=mc^2$$`), inline math (`$E=mc^2$`), and built-in `mhchem` chemistry extension.
|
|
106
|
+
|
|
107
|
+
## Custom Plugin Syntax Reference
|
|
108
|
+
|
|
109
|
+
We utilize a generalized and uniform `{{plugin_name ...}}` syntax for all custom plugins. Single-line: `{{name body}}`. Multi-line: `{{name\nbody\n}}`. Both forms close with `}}` — there is no `{{/name}}` closing tag.
|
|
110
|
+
|
|
111
|
+
| Plugin Name | Alias | Syntax Example | Description |
|
|
112
|
+
| :--- | :--- | :--- | :--- |
|
|
113
|
+
| **Span Styles** | `sp` | `{{span[red] red text}}` | Inline span element. Perfect for colorizing or badging text. Supports color classes (`red`, `yellow`, `green`, `blue`) and badge classes (`success`, `info`, `warning`, `danger`). |
|
|
114
|
+
| **Attributes** | N/A | `# Header {{attrs[id="my-id"]}}`| Injects continuous HTML attributes (classes, IDs, config properties) to the immediately preceding element. |
|
|
115
|
+
| **Emoji** | `em` | `{{emoji smile}}` / `{{em tada}}` | Renders the specific text alias directly into the corresponding Unicode emoji natively. |
|
|
116
|
+
| **Table of Content** | N/A | `{{toc}}` or `{{toc 2,3}}` | Autogenerates a Table of Contents based on document headings. Allows specifying bound heading ranges. |
|
|
117
|
+
| **Space** | N/A | `{{space 4}}` | Inserts inline horizontal whitespace entities directly into the text. |
|
|
118
|
+
| **YouTube** | `yt` | `{{youtube dQw4w9WgXcQ}}` | Embedded block element containing a responsive YouTube video iframe matching the ID. |
|
|
119
|
+
| **Markdown Source**| `md` | `{{md path/to/file.md}}` | Securely embeds the complete content of an external markdown file directly into the parsed structure. |
|
|
120
|
+
| **QR Code** | `qr` | `{{qr https://example.com}}` | Transforms text inline implicitly into an internally generated SVG QR Code natively. |
|
|
121
|
+
| **Mermaid** | `mm` | `{{mermaid\ngraph LR\nA-->B\n}}` | Compiles logic into a specific preconfigured payload targeted for Mermaid client-side rendering. |
|
|
122
|
+
| **SMILES Chemistry**| `sm` | `{{smiles C1=CC=CC=C1}}` | Embeds SMILES chemical formulas parsed specifically for `smilesDrawer` visualization. |
|
|
123
|
+
| **YAML Objects** | `yml` | `{{yaml\ntitle: Doc\n}}` | Embeds the multiline YAML configuration blindly into an invisible `<script type="application/yaml">` block. |
|
|
124
|
+
| **NYML Parser** | N/A | `{{nyml\nkey: value\n}}` | NYML-specific parser logic. Evaluates and injects the resulting properties as an invisible `<script type="application/json">` block. |
|
|
125
|
+
| **Test** | N/A | `{{test-block}}` | Reserved testing elements for structural plugin resolution constraints. |
|
|
126
|
+
|
|
127
|
+
> **📝 Escaping Plugins:**
|
|
128
|
+
> If you wish to display the literal plugin text `{{` instead of parsing it, you can escape the starting braces by putting a backslash in front: `\{{emoji smile}}`.
|
|
129
|
+
|
|
130
|
+
## Environment Requirement
|
|
131
|
+
|
|
132
|
+
Designed natively for standard ESM environments Node.js 20+.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import 'katex/contrib/mhchem';
|
|
2
|
+
import MarkdownIt from 'markdown-it';
|
|
3
|
+
import './plugins/test.js';
|
|
4
|
+
import './plugins/emoji.js';
|
|
5
|
+
import './plugins/space.js';
|
|
6
|
+
import './plugins/youtube.js';
|
|
7
|
+
import './plugins/mermaid.js';
|
|
8
|
+
import './plugins/smiles.js';
|
|
9
|
+
import './plugins/qrcode.js';
|
|
10
|
+
import './plugins/yaml.js';
|
|
11
|
+
import './plugins/nyml.js';
|
|
12
|
+
export { register } from './registry.js';
|
|
13
|
+
export type { PluginDefinition } from './registry.js';
|
|
14
|
+
export { prepareSources } from './prepare-sources.js';
|
|
15
|
+
declare const md: MarkdownIt;
|
|
16
|
+
export default md;
|
|
17
|
+
export { md };
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,UAAU,MAAM,aAAa,CAAC;AAkBrC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,mBAAmB,CAAC;AAE3B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,QAAA,MAAM,EAAE,YAMN,CAAC;AAkIH,eAAe,EAAE,CAAC;AAClB,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.md = exports.prepareSources = exports.register = void 0;
|
|
7
|
+
require("katex/contrib/mhchem");
|
|
8
|
+
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
9
|
+
const markdown_it_anchor_1 = __importDefault(require("markdown-it-anchor"));
|
|
10
|
+
const markdown_it_container_1 = __importDefault(require("markdown-it-container"));
|
|
11
|
+
const markdown_it_footnote_1 = __importDefault(require("markdown-it-footnote"));
|
|
12
|
+
const markdown_it_imsize_1 = __importDefault(require("markdown-it-imsize"));
|
|
13
|
+
const markdown_it_mark_1 = __importDefault(require("markdown-it-mark"));
|
|
14
|
+
const markdown_it_sub_1 = __importDefault(require("markdown-it-sub"));
|
|
15
|
+
const markdown_it_sup_1 = __importDefault(require("markdown-it-sup"));
|
|
16
|
+
const markdown_it_ins_1 = __importDefault(require("markdown-it-ins"));
|
|
17
|
+
const markdown_it_task_lists_1 = __importDefault(require("markdown-it-task-lists"));
|
|
18
|
+
const markdown_it_katex_1 = __importDefault(require("@traptitech/markdown-it-katex"));
|
|
19
|
+
const block_dispatcher_js_1 = require("./rules/block-dispatcher.js");
|
|
20
|
+
const inline_dispatcher_js_1 = require("./rules/inline-dispatcher.js");
|
|
21
|
+
const registry_js_1 = require("./registry.js");
|
|
22
|
+
const span_js_1 = require("./plugins/span.js");
|
|
23
|
+
const toc_js_1 = require("./plugins/toc.js");
|
|
24
|
+
const attrs_js_1 = require("./plugins/attrs.js");
|
|
25
|
+
const markdown_include_js_1 = require("./plugins/markdown-include.js");
|
|
26
|
+
require("./plugins/test.js");
|
|
27
|
+
require("./plugins/emoji.js");
|
|
28
|
+
require("./plugins/space.js");
|
|
29
|
+
require("./plugins/youtube.js");
|
|
30
|
+
require("./plugins/mermaid.js");
|
|
31
|
+
require("./plugins/smiles.js");
|
|
32
|
+
require("./plugins/qrcode.js");
|
|
33
|
+
require("./plugins/yaml.js");
|
|
34
|
+
require("./plugins/nyml.js");
|
|
35
|
+
var registry_js_2 = require("./registry.js");
|
|
36
|
+
Object.defineProperty(exports, "register", { enumerable: true, get: function () { return registry_js_2.register; } });
|
|
37
|
+
var prepare_sources_js_1 = require("./prepare-sources.js");
|
|
38
|
+
Object.defineProperty(exports, "prepareSources", { enumerable: true, get: function () { return prepare_sources_js_1.prepareSources; } });
|
|
39
|
+
const md = new markdown_it_1.default({
|
|
40
|
+
// allow raw HTML tags in source text. disabling this (the default) causes
|
|
41
|
+
// tags like `<div>...</div>` to be escaped into `<div>`.
|
|
42
|
+
html: true,
|
|
43
|
+
linkify: true,
|
|
44
|
+
typographer: true,
|
|
45
|
+
});
|
|
46
|
+
exports.md = md;
|
|
47
|
+
// Official plugins (anchor must be first: TOC depends on its id generation)
|
|
48
|
+
md.use(markdown_it_anchor_1.default);
|
|
49
|
+
// Semantic color containers
|
|
50
|
+
md.use(markdown_it_container_1.default, 'success');
|
|
51
|
+
md.use(markdown_it_container_1.default, 'info');
|
|
52
|
+
md.use(markdown_it_container_1.default, 'warning');
|
|
53
|
+
md.use(markdown_it_container_1.default, 'danger');
|
|
54
|
+
// Layout containers
|
|
55
|
+
md.use(markdown_it_container_1.default, 'left', {
|
|
56
|
+
render(tokens, idx) {
|
|
57
|
+
if (tokens[idx].nesting === 1) {
|
|
58
|
+
const width = tokens[idx].info.trim().slice('left'.length).trim();
|
|
59
|
+
if (width)
|
|
60
|
+
return `<div class="left" style="max-width: ${width}; width: ${width}">\n`;
|
|
61
|
+
return '<div class="left">\n';
|
|
62
|
+
}
|
|
63
|
+
return '</div>\n';
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
md.use(markdown_it_container_1.default, 'right');
|
|
67
|
+
md.use(markdown_it_container_1.default, 'center');
|
|
68
|
+
// Interactive containers
|
|
69
|
+
md.use(markdown_it_container_1.default, 'spoil', {
|
|
70
|
+
render(tokens, idx) {
|
|
71
|
+
if (tokens[idx].nesting === 1) {
|
|
72
|
+
// Extract label from params: "::: spoil My Title" → "My Title"
|
|
73
|
+
const label = tokens[idx].info.trim().slice('spoil'.length).trim();
|
|
74
|
+
return `<details class="spoil"><summary>${label || 'Show/hide'}</summary>\n`;
|
|
75
|
+
}
|
|
76
|
+
return '</details>\n';
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
md.use(markdown_it_container_1.default, 'tabs');
|
|
80
|
+
md.use(markdown_it_container_1.default, 'tab', {
|
|
81
|
+
render(tokens, idx) {
|
|
82
|
+
if (tokens[idx].nesting === 1) {
|
|
83
|
+
// Extract label from params: "::: tab Python" → "Python"
|
|
84
|
+
const label = tokens[idx].info.trim().slice('tab'.length).trim();
|
|
85
|
+
return `<div class="tab" data-label="${label}">\n`;
|
|
86
|
+
}
|
|
87
|
+
return '</div>\n';
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
md.use(markdown_it_container_1.default, 'cols', {
|
|
91
|
+
render(tokens, idx) {
|
|
92
|
+
if (tokens[idx].nesting === 1) {
|
|
93
|
+
const rest = tokens[idx].info.trim().slice('cols'.length).trim();
|
|
94
|
+
if (rest) {
|
|
95
|
+
// Plain numbers become fr units; CSS lengths (%, px, em, …) pass through as-is
|
|
96
|
+
const cols = rest.split(/\s+/).map(p => /^\d+(\.\d+)?$/.test(p) ? `${p}fr` : p).join(' ');
|
|
97
|
+
return `<div class="cols" style="grid-template-columns: ${cols}">\n`;
|
|
98
|
+
}
|
|
99
|
+
return '<div class="cols">\n';
|
|
100
|
+
}
|
|
101
|
+
return '</div>\n';
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
md.use(markdown_it_container_1.default, 'col');
|
|
105
|
+
// Catch-all: ::: ClassName → <div class="ClassName"> for any identifier not already registered
|
|
106
|
+
const RESERVED_CONTAINERS = new Set([
|
|
107
|
+
'success', 'info', 'warning', 'danger',
|
|
108
|
+
'left', 'right', 'center',
|
|
109
|
+
'spoil', 'tabs', 'tab',
|
|
110
|
+
'cols', 'col',
|
|
111
|
+
]);
|
|
112
|
+
md.use(markdown_it_container_1.default, 'div', {
|
|
113
|
+
validate: (params) => {
|
|
114
|
+
const name = params.trim().split(/\s+/)[0];
|
|
115
|
+
return /^[A-Za-z][A-Za-z0-9_-]*$/.test(name) && !RESERVED_CONTAINERS.has(name);
|
|
116
|
+
},
|
|
117
|
+
render(tokens, idx) {
|
|
118
|
+
const name = tokens[idx].info.trim().split(/\s+/)[0];
|
|
119
|
+
if (tokens[idx].nesting === 1)
|
|
120
|
+
return `<div class="${name}">\n`;
|
|
121
|
+
return '</div>\n';
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
md.use(markdown_it_footnote_1.default);
|
|
125
|
+
md.use(markdown_it_imsize_1.default);
|
|
126
|
+
md.use(markdown_it_mark_1.default);
|
|
127
|
+
md.use(markdown_it_sub_1.default);
|
|
128
|
+
md.use(markdown_it_sup_1.default);
|
|
129
|
+
md.use(markdown_it_ins_1.default);
|
|
130
|
+
md.use(markdown_it_task_lists_1.default);
|
|
131
|
+
md.use(markdown_it_katex_1.default, { enableMhchem: true });
|
|
132
|
+
// Custom dispatchers
|
|
133
|
+
md.block.ruler.after('blockquote', 'plugin_block_dispatcher', block_dispatcher_js_1.blockDispatcher, { alt: ['paragraph', 'reference', 'blockquote', 'list'] });
|
|
134
|
+
md.inline.ruler.after('escape', 'plugin_inline_dispatcher', inline_dispatcher_js_1.inlineDispatcher);
|
|
135
|
+
// Register plugins that need access to the md instance
|
|
136
|
+
(0, span_js_1.registerSpan)(md);
|
|
137
|
+
(0, toc_js_1.registerToc)(md);
|
|
138
|
+
(0, attrs_js_1.registerAttrs)(md);
|
|
139
|
+
(0, markdown_include_js_1.registerMarkdownInclude)(md);
|
|
140
|
+
// Renderer for plugin_block tokens
|
|
141
|
+
md.renderer.rules['plugin_block'] = (tokens, idx, _options, env) => {
|
|
142
|
+
const token = tokens[idx];
|
|
143
|
+
const def = (0, registry_js_1.getDefinition)(token.info);
|
|
144
|
+
if (!def)
|
|
145
|
+
return '';
|
|
146
|
+
const args = token.meta?.args ?? null;
|
|
147
|
+
return def.render(args, token.content || null, env);
|
|
148
|
+
};
|
|
149
|
+
// Renderer for plugin_inline tokens
|
|
150
|
+
md.renderer.rules['plugin_inline'] = (tokens, idx, _options, env) => {
|
|
151
|
+
const token = tokens[idx];
|
|
152
|
+
const def = (0, registry_js_1.getDefinition)(token.info);
|
|
153
|
+
if (!def)
|
|
154
|
+
return '';
|
|
155
|
+
const args = token.meta?.args ?? null;
|
|
156
|
+
return def.render(args, token.content || null, env);
|
|
157
|
+
};
|
|
158
|
+
exports.default = md;
|
|
159
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gCAA8B;AAC9B,8DAAqC;AACrC,4EAAwC;AACxC,kFAA8C;AAC9C,gFAA4C;AAC5C,4EAAwC;AACxC,wEAAoC;AACpC,sEAAkC;AAClC,sEAAkC;AAClC,sEAAkC;AAClC,oFAA+C;AAC/C,sFAAwD;AACxD,qEAA8D;AAC9D,uEAAgE;AAChE,+CAA8C;AAC9C,+CAAiD;AACjD,6CAA+C;AAC/C,iDAAmD;AACnD,uEAAwE;AACxE,6BAA2B;AAC3B,8BAA4B;AAC5B,8BAA4B;AAC5B,gCAA8B;AAC9B,gCAA8B;AAC9B,+BAA6B;AAC7B,+BAA6B;AAC7B,6BAA2B;AAC3B,6BAA2B;AAE3B,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AAEjB,2DAAsD;AAA7C,oHAAA,cAAc,OAAA;AAEvB,MAAM,EAAE,GAAG,IAAI,qBAAU,CAAC;IACxB,0EAA0E;IAC1E,+DAA+D;IAC/D,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AAmIM,gBAAE;AAjIX,4EAA4E;AAC5E,EAAE,CAAC,GAAG,CAAC,4BAAM,CAAC,CAAC;AACf,4BAA4B;AAC5B,EAAE,CAAC,GAA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AK,CAAC,eAAe,CAAC,GAAG,CACnC,MAA0B,EAC1B,GAAW,EACX,QAA4B,EAC5B,GAAW,EACH,EAAE;IACV,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,GAAG,GAAG,IAAA,2BAAa,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC;IACtC,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC,CAAC;AAEF,kBAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attrs.d.ts","sourceRoot":"","sources":["../../src/plugins/attrs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAoB1C,wBAAgB,aAAa,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAsClD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAttrs = registerAttrs;
|
|
4
|
+
const registry_js_1 = require("../registry.js");
|
|
5
|
+
function parseAttrs(attrString) {
|
|
6
|
+
const result = [];
|
|
7
|
+
// Match: .classname, #idname, key="value", or bare key
|
|
8
|
+
const re = /\.([^\s.#=]+)|#([^\s.#=]+)|([a-zA-Z][\w-]*)(?:="([^"]*)")?/g;
|
|
9
|
+
let m;
|
|
10
|
+
while ((m = re.exec(attrString)) !== null) {
|
|
11
|
+
if (m[1]) {
|
|
12
|
+
result.push(['class', m[1]]);
|
|
13
|
+
}
|
|
14
|
+
else if (m[2]) {
|
|
15
|
+
result.push(['id', m[2]]);
|
|
16
|
+
}
|
|
17
|
+
else if (m[3]) {
|
|
18
|
+
result.push([m[3], m[4] ?? '']);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
function registerAttrs(md) {
|
|
24
|
+
// The inline token acts as a marker; actual work is done in the core rule
|
|
25
|
+
(0, registry_js_1.register)({
|
|
26
|
+
type: 'inline',
|
|
27
|
+
aliases: ['attrs'],
|
|
28
|
+
render(_args, _body, _env) {
|
|
29
|
+
// Rendered content is empty — the core rule removes this token and
|
|
30
|
+
// applies the attributes to the preceding block token instead
|
|
31
|
+
return '';
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
md.core.ruler.push('attrs_resolve', (state) => {
|
|
35
|
+
for (let i = 0; i < state.tokens.length; i++) {
|
|
36
|
+
const blockToken = state.tokens[i];
|
|
37
|
+
if (blockToken.type !== 'inline')
|
|
38
|
+
continue;
|
|
39
|
+
const children = blockToken.children ?? [];
|
|
40
|
+
for (let j = 0; j < children.length; j++) {
|
|
41
|
+
const child = children[j];
|
|
42
|
+
if (child.type !== 'plugin_inline' || child.info !== 'attrs')
|
|
43
|
+
continue;
|
|
44
|
+
const attrString = child.meta?.args;
|
|
45
|
+
if (attrString) {
|
|
46
|
+
const prevToken = state.tokens[i - 1];
|
|
47
|
+
if (prevToken && prevToken.nesting === 1) {
|
|
48
|
+
for (const [key, val] of parseAttrs(attrString)) {
|
|
49
|
+
prevToken.attrSet(key, val);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Remove the marker token from inline children
|
|
54
|
+
children.splice(j, 1);
|
|
55
|
+
j--;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=attrs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attrs.js","sourceRoot":"","sources":["../../src/plugins/attrs.ts"],"names":[],"mappings":";;AAoBA,sCAsCC;AAzDD,gDAA0C;AA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AAE,CAAC;YAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACnC,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ;gBAAE,SAAS;YAE3C,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAC;YAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAC1B,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;oBAAE,SAAS;gBAEvE,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,IAAqB,CAAC;gBACrD,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;oBACtC,IAAI,SAAS,IAAI,SAAS,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;wBACzC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;4BAChD,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;wBAC9B,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,+CAA+C;gBAC/C,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACtB,CAAC,EAAE,CAAC;YACN,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji.d.ts","sourceRoot":"","sources":["../../src/plugins/emoji.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const nodeEmoji = __importStar(require("node-emoji"));
|
|
37
|
+
const registry_js_1 = require("../registry.js");
|
|
38
|
+
(0, registry_js_1.register)({
|
|
39
|
+
type: 'inline',
|
|
40
|
+
aliases: ['emoji', 'em'],
|
|
41
|
+
render(_args, body, _env) {
|
|
42
|
+
const name = body?.trim() ?? '';
|
|
43
|
+
const result = nodeEmoji.get(name);
|
|
44
|
+
// node-emoji returns undefined for unknown names; fall back to original text
|
|
45
|
+
if (!result) {
|
|
46
|
+
return `{{emoji ${name}}}`;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=emoji.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emoji.js","sourceRoot":"","sources":["../../src/plugins/emoji.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,gDAA0C;AAE1C,IAAA,sBAAQ,EAAC;IACP,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;IACxB,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI;QACtB,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,6EAA6E;QAC7E,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,WAAW,IAAI,IAAI,CAAC;QAC7B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-include.d.ts","sourceRoot":"","sources":["../../src/plugins/markdown-include.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAG1C,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAkC5D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerMarkdownInclude = registerMarkdownInclude;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const registry_js_1 = require("../registry.js");
|
|
10
|
+
function registerMarkdownInclude(md) {
|
|
11
|
+
(0, registry_js_1.register)({
|
|
12
|
+
type: 'block',
|
|
13
|
+
aliases: ['markdown', 'md', 'md-include'],
|
|
14
|
+
render(_args, body, env) {
|
|
15
|
+
const filePath = body?.trim();
|
|
16
|
+
if (!filePath)
|
|
17
|
+
return '';
|
|
18
|
+
const envObj = env;
|
|
19
|
+
// Guard against nested includes
|
|
20
|
+
if (envObj['markdownIncludeActive'])
|
|
21
|
+
return '';
|
|
22
|
+
// Resolve path: prefer env.markdownBasePath (document dir) over process.cwd()
|
|
23
|
+
const basePath = envObj['markdownBasePath'] ?? process.cwd();
|
|
24
|
+
const resolved = path_1.default.isAbsolute(filePath)
|
|
25
|
+
? filePath
|
|
26
|
+
: path_1.default.resolve(basePath, filePath);
|
|
27
|
+
let source;
|
|
28
|
+
try {
|
|
29
|
+
source = fs_1.default.readFileSync(resolved, 'utf8');
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
envObj['markdownIncludeActive'] = true;
|
|
35
|
+
try {
|
|
36
|
+
return md.render(source, env);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
envObj['markdownIncludeActive'] = false;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=markdown-include.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-include.js","sourceRoot":"","sources":["../../src/plugins/markdown-include.ts"],"names":[],"mappings":";;;;;AAKA,0DAkCC;AAvCD,4CAAoB;AACpB,gD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/plugins/mermaid.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const registry_js_1 = require("../registry.js");
|
|
4
|
+
function escapeHtml(str) {
|
|
5
|
+
return str
|
|
6
|
+
.replace(/&/g, '&')
|
|
7
|
+
.replace(/</g, '<')
|
|
8
|
+
.replace(/>/g, '>');
|
|
9
|
+
}
|
|
10
|
+
(0, registry_js_1.register)({
|
|
11
|
+
type: 'block',
|
|
12
|
+
aliases: ['mermaid', 'mm'],
|
|
13
|
+
render(_args, body, _env) {
|
|
14
|
+
const content = body?.trim() ?? '';
|
|
15
|
+
return `<div class="mermaid">${escapeHtml(content)}</div>\n`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=mermaid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.js","sourceRoot":"","sources":["../../src/plugins/mermaid.ts"],"names":[],"mappings":";;AAAA,gDAA0C;AAE1C,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,IAAA,sBAAQ,EAAC;IACP,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC;IAC1B,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI;QACtB,MAAM,OAAO,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACnC,OAAO,wBAAwB,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC;IAC/D,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nyml.d.ts","sourceRoot":"","sources":["../../src/plugins/nyml.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const registry_js_1 = require("../registry.js");
|
|
4
|
+
const nyml_parser_js_1 = require("./nyml_parser.js");
|
|
5
|
+
(0, registry_js_1.register)({
|
|
6
|
+
type: 'block',
|
|
7
|
+
aliases: ['nyml'],
|
|
8
|
+
render(_args, body, _env) {
|
|
9
|
+
const rawContent = body ?? '';
|
|
10
|
+
let parsedContent;
|
|
11
|
+
try {
|
|
12
|
+
parsedContent = (0, nyml_parser_js_1.parseNymlV2)(rawContent);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
parsedContent = { error: 'Failed to parse NYML' };
|
|
16
|
+
}
|
|
17
|
+
const jsonContent = JSON.stringify(parsedContent, null, 2).replace(/<\/script>/gi, '<\\/script>');
|
|
18
|
+
return `<script type="application/json" id="nyml-data">\n${jsonContent}\n</script>\n`;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=nyml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nyml.js","sourceRoot":"","sources":["../../src/plugins/nyml.ts"],"names":[],"mappings":";;AAAA,gDAA0C;AAC1C,qDAA+C;AAE/C,IAAA,sBAAQ,EAAC;IACP,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,CAAC,MAAM,CAAC;IACjB,MAAM,CAAC,KAAoB,EAAE,IAAmB,EAAE,IAAY;QAC5D,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,IAAI,aAAa,CAAC;QAClB,IAAI,CAAC;YACH,aAAa,GAAG,IAAA,4BAAW,EAAC,UAAU,CAAC,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,aAAa,GAAG,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;QACpD,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;QAClG,OAAO,oDAAoD,WAAW,eAAe,CAAC;IACxF,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NYML V2 Parser implementation.
|
|
3
|
+
*
|
|
4
|
+
* V2 introduces list-based output where:
|
|
5
|
+
* - Root is always a list of entries
|
|
6
|
+
* - Multi-value fields create nested lists
|
|
7
|
+
* - Mixed content (strings + key/value pairs) is supported
|
|
8
|
+
* - No comments (# is allowed in values)
|
|
9
|
+
*/
|
|
10
|
+
declare class ParseError extends Error {
|
|
11
|
+
code: string;
|
|
12
|
+
line: number;
|
|
13
|
+
column: number | null;
|
|
14
|
+
constructor(code: string, message: string, line: number, column?: number | null);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse NYML V2 text into a list structure.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} text - The NYML V2 content to parse
|
|
20
|
+
* @returns {Array} - A list representing the parsed data
|
|
21
|
+
*/
|
|
22
|
+
declare function parseNymlV2(text: string): any[];
|
|
23
|
+
/**
|
|
24
|
+
* Serialize a V2 data structure back to NYML format.
|
|
25
|
+
*
|
|
26
|
+
* @param {Array} data - List structure as returned by parseNymlV2()
|
|
27
|
+
* @param {number} indent - Current indentation level (spaces)
|
|
28
|
+
* @returns {string} - NYML formatted string
|
|
29
|
+
*/
|
|
30
|
+
declare function serializeNymlV2(data: any[], indent?: number): string;
|
|
31
|
+
export { parseNymlV2, serializeNymlV2, ParseError };
|
|
32
|
+
//# sourceMappingURL=nyml_parser.d.ts.map
|