@isdk/mdast-plus 0.1.1 → 0.1.2
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/README.cn.md +9 -0
- package/README.md +9 -0
- package/dist/index.d.mts +20 -7
- package/dist/index.d.ts +20 -7
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/README.md +9 -0
- package/docs/_media/README.cn.md +9 -0
- package/docs/classes/FluentProcessor.md +26 -10
- package/docs/functions/htmlStringify.md +23 -0
- package/docs/functions/markdownCommon.md +23 -0
- package/docs/functions/mdast.md +1 -1
- package/docs/globals.md +7 -2
- package/docs/interfaces/ConvertResult.md +3 -3
- package/docs/interfaces/MdastAsset.md +4 -4
- package/docs/interfaces/MdastDataOrigin.md +4 -4
- package/docs/interfaces/MdastFormatDefinition.md +3 -3
- package/docs/interfaces/MdastMark.md +3 -3
- package/docs/interfaces/MdastPlugin.md +5 -5
- package/docs/interfaces/MdastReader.md +2 -2
- package/docs/interfaces/MdastSub.md +3 -3
- package/docs/interfaces/MdastSup.md +3 -3
- package/docs/interfaces/MdastTransformer.md +2 -2
- package/docs/interfaces/MdastWriter.md +2 -2
- package/docs/type-aliases/Stage.md +1 -1
- package/docs/variables/htmlFormat.md +14 -0
- package/docs/variables/markdownFormat.md +14 -0
- package/package.json +1 -1
- package/docs/functions/htmlFormat.md +0 -24
- package/docs/functions/markdownFormat.md +0 -24
package/README.cn.md
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
- **表格跨行/跨列**: 支持 HTML 输出中的 `rowspan` 和 `colspan`。
|
|
18
18
|
- **代码元数据**: 对代码块元数据字符串进行结构化解析。
|
|
19
19
|
- **图片尺寸**: 支持 URL 糖语法 (例如 `image.png#=500x300`) 来设置图片尺寸。
|
|
20
|
+
- **行内样式**: 内置对 `==高亮==`、`~下标~` 和 `^上标^` 的支持。
|
|
20
21
|
- **深度类型支持**: 基于 TypeScript 构建,完整支持 unist/mdast 的模块扩充。
|
|
21
22
|
|
|
22
23
|
## 安装
|
|
@@ -46,6 +47,13 @@ const html = await mdast('').toHTML();
|
|
|
46
47
|
// 结果: <img src="cat.png" alt="Cat" width="500" height="300">
|
|
47
48
|
```
|
|
48
49
|
|
|
50
|
+
### AST 输出
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const ast = await mdast('==高亮内容==').toAST();
|
|
54
|
+
// 返回 mdast Root 对象
|
|
55
|
+
```
|
|
56
|
+
|
|
49
57
|
### 高级工作流
|
|
50
58
|
|
|
51
59
|
```typescript
|
|
@@ -99,6 +107,7 @@ const result = await mdast('Hello').to('reverse');
|
|
|
99
107
|
| `normalize-table-span` | normalize | 将表格单元格跨度迁移到 `hProperties`。 |
|
|
100
108
|
| `extract-code-meta` | normalize | 从代码块元数据中解析 `title="foo"`。 |
|
|
101
109
|
| `image-size` | normalize | 从图片 URL 中解析 `#=WxH`。 |
|
|
110
|
+
| `normalize-inline-styles` | normalize | 标准化 `==mark==`、`~sub~` 和 `^sup^`。 |
|
|
102
111
|
|
|
103
112
|
## 贡献
|
|
104
113
|
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ English | [简体中文](./README.cn.md) | [GitHub](https://github.com/isdk/mdas
|
|
|
17
17
|
- **Table Spans**: Support for `rowspan` and `colspan` in HTML output.
|
|
18
18
|
- **Code Meta**: Structured parsing of code block metadata strings.
|
|
19
19
|
- **Image Sizing**: URL "sugar" support (e.g., `image.png#=500x300`) for image dimensions.
|
|
20
|
+
- **Inline Styles**: Built-in support for `==Highlight==`, `~Subscript~`, and `^Superscript^`.
|
|
20
21
|
- **Deeply Typed**: Built on TypeScript with full support for unist/mdast module augmentation.
|
|
21
22
|
|
|
22
23
|
## Installation
|
|
@@ -46,6 +47,13 @@ const html = await mdast('').toHTML();
|
|
|
46
47
|
// Result: <img src="cat.png" alt="Cat" width="500" height="300">
|
|
47
48
|
```
|
|
48
49
|
|
|
50
|
+
### AST Output
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const ast = await mdast('==Highlighted==').toAST();
|
|
54
|
+
// Returns the mdast Root object
|
|
55
|
+
```
|
|
56
|
+
|
|
49
57
|
### Advanced Pipeline
|
|
50
58
|
|
|
51
59
|
```typescript
|
|
@@ -99,6 +107,7 @@ Plugins are executed based on their `stage` and `order`:
|
|
|
99
107
|
| `normalize-table-span` | normalize | Migrates table cell spans to `hProperties`. |
|
|
100
108
|
| `extract-code-meta` | normalize | Parses `title="foo"` from code block meta. |
|
|
101
109
|
| `image-size` | normalize | Parses `#=WxH` from image URLs. |
|
|
110
|
+
| `normalize-inline-styles` | normalize | Standardizes `==mark==`, `~sub~`, and `^sup^`. |
|
|
102
111
|
|
|
103
112
|
## Contributing
|
|
104
113
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1340,6 +1340,11 @@ declare class FluentProcessor {
|
|
|
1340
1340
|
* @returns A promise resolving to the HTML string
|
|
1341
1341
|
*/
|
|
1342
1342
|
toHTML(): Promise<string>;
|
|
1343
|
+
/**
|
|
1344
|
+
* Helper to get the processed mdast tree.
|
|
1345
|
+
* @returns A promise resolving to the mdast Root node
|
|
1346
|
+
*/
|
|
1347
|
+
toAST(): Promise<Root>;
|
|
1343
1348
|
}
|
|
1344
1349
|
/**
|
|
1345
1350
|
* Entry point for the fluent mdast-plus API.
|
|
@@ -1349,15 +1354,23 @@ declare class FluentProcessor {
|
|
|
1349
1354
|
declare function mdast(input: any): FluentProcessor;
|
|
1350
1355
|
|
|
1351
1356
|
/**
|
|
1352
|
-
*
|
|
1353
|
-
|
|
1357
|
+
* Common remark configuration for Markdown.
|
|
1358
|
+
*/
|
|
1359
|
+
declare function markdownCommon(this: any): void;
|
|
1360
|
+
/**
|
|
1361
|
+
* Markdown format definition for FluentProcessor.
|
|
1362
|
+
* Handles both parsing (Markdown -> MDAST) and stringifying (MDAST -> Markdown).
|
|
1354
1363
|
*/
|
|
1355
|
-
declare
|
|
1364
|
+
declare const markdownFormat: MdastFormatDefinition;
|
|
1356
1365
|
|
|
1357
1366
|
/**
|
|
1358
|
-
*
|
|
1359
|
-
|
|
1367
|
+
* Standard compiler/stringifier for HTML.
|
|
1368
|
+
*/
|
|
1369
|
+
declare function htmlStringify(this: any): void;
|
|
1370
|
+
/**
|
|
1371
|
+
* HTML format definition for FluentProcessor.
|
|
1372
|
+
* Handles both parsing (HTML -> MDAST) and stringifying (MDAST -> HTML).
|
|
1360
1373
|
*/
|
|
1361
|
-
declare
|
|
1374
|
+
declare const htmlFormat: MdastFormatDefinition;
|
|
1362
1375
|
|
|
1363
|
-
export { type ConvertResult, FluentProcessor, type MdastAsset, type MdastDataOrigin, type MdastFormatDefinition, type MdastMark, type MdastPlugin, type MdastReader, type MdastSub, type MdastSup, type MdastTransformer, type MdastWriter, type Stage, htmlFormat, markdownFormat, mdast };
|
|
1376
|
+
export { type ConvertResult, FluentProcessor, type MdastAsset, type MdastDataOrigin, type MdastFormatDefinition, type MdastMark, type MdastPlugin, type MdastReader, type MdastSub, type MdastSup, type MdastTransformer, type MdastWriter, type Stage, htmlFormat, htmlStringify, markdownCommon, markdownFormat, mdast };
|
package/dist/index.d.ts
CHANGED
|
@@ -1340,6 +1340,11 @@ declare class FluentProcessor {
|
|
|
1340
1340
|
* @returns A promise resolving to the HTML string
|
|
1341
1341
|
*/
|
|
1342
1342
|
toHTML(): Promise<string>;
|
|
1343
|
+
/**
|
|
1344
|
+
* Helper to get the processed mdast tree.
|
|
1345
|
+
* @returns A promise resolving to the mdast Root node
|
|
1346
|
+
*/
|
|
1347
|
+
toAST(): Promise<Root>;
|
|
1343
1348
|
}
|
|
1344
1349
|
/**
|
|
1345
1350
|
* Entry point for the fluent mdast-plus API.
|
|
@@ -1349,15 +1354,23 @@ declare class FluentProcessor {
|
|
|
1349
1354
|
declare function mdast(input: any): FluentProcessor;
|
|
1350
1355
|
|
|
1351
1356
|
/**
|
|
1352
|
-
*
|
|
1353
|
-
|
|
1357
|
+
* Common remark configuration for Markdown.
|
|
1358
|
+
*/
|
|
1359
|
+
declare function markdownCommon(this: any): void;
|
|
1360
|
+
/**
|
|
1361
|
+
* Markdown format definition for FluentProcessor.
|
|
1362
|
+
* Handles both parsing (Markdown -> MDAST) and stringifying (MDAST -> Markdown).
|
|
1354
1363
|
*/
|
|
1355
|
-
declare
|
|
1364
|
+
declare const markdownFormat: MdastFormatDefinition;
|
|
1356
1365
|
|
|
1357
1366
|
/**
|
|
1358
|
-
*
|
|
1359
|
-
|
|
1367
|
+
* Standard compiler/stringifier for HTML.
|
|
1368
|
+
*/
|
|
1369
|
+
declare function htmlStringify(this: any): void;
|
|
1370
|
+
/**
|
|
1371
|
+
* HTML format definition for FluentProcessor.
|
|
1372
|
+
* Handles both parsing (HTML -> MDAST) and stringifying (MDAST -> HTML).
|
|
1360
1373
|
*/
|
|
1361
|
-
declare
|
|
1374
|
+
declare const htmlFormat: MdastFormatDefinition;
|
|
1362
1375
|
|
|
1363
|
-
export { type ConvertResult, FluentProcessor, type MdastAsset, type MdastDataOrigin, type MdastFormatDefinition, type MdastMark, type MdastPlugin, type MdastReader, type MdastSub, type MdastSup, type MdastTransformer, type MdastWriter, type Stage, htmlFormat, markdownFormat, mdast };
|
|
1376
|
+
export { type ConvertResult, FluentProcessor, type MdastAsset, type MdastDataOrigin, type MdastFormatDefinition, type MdastMark, type MdastPlugin, type MdastReader, type MdastSub, type MdastSup, type MdastTransformer, type MdastWriter, type Stage, htmlFormat, htmlStringify, markdownCommon, markdownFormat, mdast };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e
|
|
1
|
+
"use strict";var t,e=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(t,e,s,o)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let u of n(e))a.call(t,u)||u===s||r(t,u,{get:()=>e[u],enumerable:!(o=i(e,u))||o.enumerable});return t},u=(t,i,n)=>(n=null!=t?e(s(t)):{},o(!i&&t&&t.__esModule?n:r(n,"default",{value:t,enumerable:!0}),t)),c={};((t,e)=>{for(var i in e)r(t,i,{get:e[i],enumerable:!0})})(c,{FluentProcessor:()=>P,htmlFormat:()=>F,htmlStringify:()=>D,markdownCommon:()=>q,markdownFormat:()=>z,mdast:()=>$}),module.exports=(t=c,o(r({},"__esModule",{value:!0}),t));var l=require("unified"),m=u(require("remark-parse")),h=u(require("remark-stringify")),f=u(require("remark-gfm")),p=u(require("remark-directive")),d=u(require("remark-math")),y=u(require("remark-frontmatter")),v=require("unist-util-visit");function g(t,e){return{type:t,children:e,data:{hName:t}}}var w={mark:(t,e)=>{const r={type:"mark",children:t.all(e)};return t.patch(e,r),r},sub:(t,e)=>{const r={type:"sub",children:t.all(e)};return t.patch(e,r),r},sup:(t,e)=>{const r={type:"sup",children:t.all(e)};return t.patch(e,r),r}},b={mark:(t,e,r)=>"=="+r.containerPhrasing(t,{before:"==",after:"=="})+"==",sub:(t,e,r)=>"~"+r.containerPhrasing(t,{before:"~",after:"~"})+"~",sup:(t,e,r)=>"^"+r.containerPhrasing(t,{before:"^",after:"^"})+"^"},k={name:"normalize-inline-styles",stage:"normalize",transform:t=>{!function(t){(0,v.visit)(t,"text",(t,e,r)=>{if(!r||void 0===e)return;const i=t.value;let n=0;const s=[];let a=!1;const o=/(==[^=]+==|~[^~]+~|\^[^^]+\^)/g;let u;for(;null!==(u=o.exec(i));){a=!0;const t=u[0],e=u.index;e>n&&s.push({type:"text",value:i.slice(n,e)});let r="mark",c="";t.startsWith("==")?(r="mark",c=t.slice(2,-2)):t.startsWith("~")?(r="sub",c=t.slice(1,-1)):t.startsWith("^")&&(r="sup",c=t.slice(1,-1)),s.push(g(r,[{type:"text",value:c}])),n=o.lastIndex}return a?(n<i.length&&s.push({type:"text",value:i.slice(n)}),r.children.splice(e,1,...s),e+s.length):void 0})}(t)}};function q(){const t=this.data();var e,r;r={handlers:b},t[e="toMarkdownExtensions"]?t[e].push(r):t[e]=[r],this.use(f.default,{singleTilde:!1}).use(p.default).use(d.default).use(y.default,["yaml","toml"])}var z={parse:t=>t.use(m.default).use(q),stringify:t=>t.use(h.default).use(q)},x=u(require("rehype-parse")),S=u(require("rehype-remark")),j=u(require("remark-rehype")),O=u(require("rehype-sanitize")),N=u(require("rehype-stringify"));function D(){this.use(j.default).use(O.default,{...O.defaultSchema,tagNames:[...O.defaultSchema.tagNames||[],"mark","sub","sup"],attributes:{...O.defaultSchema.attributes,"*":[...O.defaultSchema.attributes?.["*"]||[],"className","id","style"],td:[...O.defaultSchema.attributes?.td||[],"rowSpan","colSpan","rowspan","colspan"],th:[...O.defaultSchema.attributes?.th||[],"rowSpan","colSpan","rowspan","colspan"],img:[...O.defaultSchema.attributes?.img||[],"width","height"]}}).use(N.default)}var F={parse:t=>t.use(x.default).use(S.default,{handlers:w}),stringify:t=>t.use(D)},M=require("unist-util-visit"),T={error:"danger",warn:"warning",success:"tip",important:"important",caution:"caution",note:"note"},C={name:"normalize-directive",stage:"normalize",order:10,transform:async t=>{(0,M.visit)(t,["containerDirective","leafDirective","textDirective"],t=>{const e=t,r=e.name.toLowerCase();if(e.name=T[r]||r,e.children&&e.children.length>0){const t=e.children[0];if(t.data?.directiveLabel||"directiveLabel"===t.type){const r=t;let i="";(0,M.visit)(r,"text",t=>{i+=t.value}),i&&!e.attributes?.title&&(e.attributes=e.attributes||{},e.attributes.title=i.trim()),e.children.shift()}}e.attributes?.title&&(e.attributes.title=String(e.attributes.title).trim()),e.data=e.data||{},e.data.hName=e.data.hName||("containerDirective"===e.type?"div":"span"),e.data.hProperties={...e.data.hProperties||{},...e.attributes,className:[e.name,e.data.hProperties?.className].filter(Boolean).join(" ")}})}},I=require("unist-util-visit"),L={name:"normalize-table-span",stage:"normalize",order:20,transform:async t=>{(0,I.visit)(t,"tableCell",t=>{if(t.data){const{rowspan:e,colspan:r}=t.data;t.data.hProperties=t.data.hProperties||{},void 0!==e&&(t.data.hProperties.rowSpan=e,delete t.data.rowspan),void 0!==r&&(t.data.hProperties.colSpan=r,delete t.data.colspan)}})}},_=require("unist-util-visit"),A=require("shell-quote");var B={name:"extract-code-meta",stage:"normalize",order:30,transform:async t=>{(0,_.visit)(t,"code",t=>{if(t.meta){const e=function(t){const e={},r=(0,A.parse)(t);for(const t of r)if("string"==typeof t){const r=t.split("=",2);2===r.length?e[r[0]]=r[1]:e[t]="true"}return e}(t.meta),r=t.data=t.data||{};e.title&&(r.title=e.title),e.filename&&(r.filename=e.filename),r.kv={...r.kv||{},...e}}})}},E=require("unist-util-visit"),H={name:"image-size",stage:"normalize",order:40,transform:async t=>{(0,E.visit)(t,"image",t=>{const e=t.data=t.data||{},r=e.hProperties=e.hProperties||{},i=/[#?&](?:width=([0-9]+))?(?:&?height=([0-9]+))?(?:=([0-9]+)x([0-9]+))?$/,n=t.url.match(i);if(n){const e=n[1]||n[3],s=n[2]||n[4];e&&!r.width&&(r.width=parseInt(e,10)),s&&!r.height&&(r.height=parseInt(s,10)),t.url=t.url.replace(i,"")}e.width&&!r.width&&(r.width=e.width),e.height&&!r.height&&(r.height=e.height)})}},J=class t{constructor(t){this.inputFormat="markdown",this.plugins=[],this.globalData={},this.input=t,this.processor=(0,l.unified)(),this.use(C),this.use(L),this.use(B),this.use(H),this.use(k)}static registerFormat(e,r){t.formats[e.toLowerCase()]=r}from(t){return this.inputFormat=t.toLowerCase(),this}use(t){return this.plugins.push(t),this}data(t){return this.globalData={...this.globalData,...t},this}async to(e){e=e.toLowerCase();const r=t.formats[this.inputFormat];r?.parse&&r.parse(this.processor);let i="string"==typeof this.input?this.processor.parse(this.input):this.input;i=await this.processor.run(i),i.data={...i.data,...this.globalData};const n=[...this.plugins].sort((t,e)=>{const r={normalize:0,compile:1,finalize:2},i=t.stage||"normalize",n=e.stage||"normalize";return i!==n?r[i]-r[n]:(t.order||0)-(e.order||0)});for(const t of n)await t.transform(i,this.processor);const s=(0,l.unified)().data("settings",this.processor.data("settings")),a=t.formats[e];a?.stringify&&a.stringify(s),"markdown"!==e||a||z.stringify(s);const o=await s.run(i),u=s.stringify(o),c=[];return i.data&&i.data.assets&&c.push(...i.data.assets),{content:u,assets:c}}async toMarkdown(){return(await this.to("markdown")).content}async toHTML(){return(await this.to("html")).content}async toAST(){return(await this.to("ast")).content}};J.formats={markdown:z,html:F,ast:{parse:t=>{t.Parser=t=>JSON.parse(t)},stringify:t=>{t.Compiler=t=>t}}};var P=J;function $(t){return new P(t)}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{unified as t}from"unified";import r from"remark-parse";import i from"remark-stringify";import e from"
|
|
1
|
+
import{unified as t}from"unified";import r from"remark-parse";import i from"remark-stringify";import e from"remark-gfm";import s from"remark-directive";import n from"remark-math";import a from"remark-frontmatter";import{visit as o}from"unist-util-visit";function m(t,r){return{type:t,children:r,data:{hName:t}}}var c={mark:(t,r)=>{const i={type:"mark",children:t.all(r)};return t.patch(r,i),i},sub:(t,r)=>{const i={type:"sub",children:t.all(r)};return t.patch(r,i),i},sup:(t,r)=>{const i={type:"sup",children:t.all(r)};return t.patch(r,i),i}},l={mark:(t,r,i)=>"=="+i.containerPhrasing(t,{before:"==",after:"=="})+"==",sub:(t,r,i)=>"~"+i.containerPhrasing(t,{before:"~",after:"~"})+"~",sup:(t,r,i)=>"^"+i.containerPhrasing(t,{before:"^",after:"^"})+"^"},p={name:"normalize-inline-styles",stage:"normalize",transform:t=>{!function(t){o(t,"text",(t,r,i)=>{if(!i||void 0===r)return;const e=t.value;let s=0;const n=[];let a=!1;const o=/(==[^=]+==|~[^~]+~|\^[^^]+\^)/g;let c;for(;null!==(c=o.exec(e));){a=!0;const t=c[0],r=c.index;r>s&&n.push({type:"text",value:e.slice(s,r)});let i="mark",l="";t.startsWith("==")?(i="mark",l=t.slice(2,-2)):t.startsWith("~")?(i="sub",l=t.slice(1,-1)):t.startsWith("^")&&(i="sup",l=t.slice(1,-1)),n.push(m(i,[{type:"text",value:l}])),s=o.lastIndex}return a?(s<e.length&&n.push({type:"text",value:e.slice(s)}),i.children.splice(r,1,...n),r+n.length):void 0})}(t)}};function f(){const t=this.data();var r,i;i={handlers:l},t[r="toMarkdownExtensions"]?t[r].push(i):t[r]=[i],this.use(e,{singleTilde:!1}).use(s).use(n).use(a,["yaml","toml"])}var h={parse:t=>t.use(r).use(f),stringify:t=>t.use(i).use(f)};import u from"rehype-parse";import d from"rehype-remark";import v from"remark-rehype";import y,{defaultSchema as g}from"rehype-sanitize";import w from"rehype-stringify";function k(){this.use(v).use(y,{...g,tagNames:[...g.tagNames||[],"mark","sub","sup"],attributes:{...g.attributes,"*":[...g.attributes?.["*"]||[],"className","id","style"],td:[...g.attributes?.td||[],"rowSpan","colSpan","rowspan","colspan"],th:[...g.attributes?.th||[],"rowSpan","colSpan","rowspan","colspan"],img:[...g.attributes?.img||[],"width","height"]}}).use(w)}var z={parse:t=>t.use(u).use(d,{handlers:c}),stringify:t=>t.use(k)};import{visit as b}from"unist-util-visit";var x={error:"danger",warn:"warning",success:"tip",important:"important",caution:"caution",note:"note"},S={name:"normalize-directive",stage:"normalize",order:10,transform:async t=>{b(t,["containerDirective","leafDirective","textDirective"],t=>{const r=t,i=r.name.toLowerCase();if(r.name=x[i]||i,r.children&&r.children.length>0){const t=r.children[0];if(t.data?.directiveLabel||"directiveLabel"===t.type){let i="";b(t,"text",t=>{i+=t.value}),i&&!r.attributes?.title&&(r.attributes=r.attributes||{},r.attributes.title=i.trim()),r.children.shift()}}r.attributes?.title&&(r.attributes.title=String(r.attributes.title).trim()),r.data=r.data||{},r.data.hName=r.data.hName||("containerDirective"===r.type?"div":"span"),r.data.hProperties={...r.data.hProperties||{},...r.attributes,className:[r.name,r.data.hProperties?.className].filter(Boolean).join(" ")}})}};import{visit as N}from"unist-util-visit";var D={name:"normalize-table-span",stage:"normalize",order:20,transform:async t=>{N(t,"tableCell",t=>{if(t.data){const{rowspan:r,colspan:i}=t.data;t.data.hProperties=t.data.hProperties||{},void 0!==r&&(t.data.hProperties.rowSpan=r,delete t.data.rowspan),void 0!==i&&(t.data.hProperties.colSpan=i,delete t.data.colspan)}})}};import{visit as M}from"unist-util-visit";import{parse as T}from"shell-quote";var I={name:"extract-code-meta",stage:"normalize",order:30,transform:async t=>{M(t,"code",t=>{if(t.meta){const r=function(t){const r={},i=T(t);for(const t of i)if("string"==typeof t){const i=t.split("=",2);2===i.length?r[i[0]]=i[1]:r[t]="true"}return r}(t.meta),i=t.data=t.data||{};r.title&&(i.title=r.title),r.filename&&(i.filename=r.filename),i.kv={...i.kv||{},...r}}})}};import{visit as L}from"unist-util-visit";var q={name:"image-size",stage:"normalize",order:40,transform:async t=>{L(t,"image",t=>{const r=t.data=t.data||{},i=r.hProperties=r.hProperties||{},e=/[#?&](?:width=([0-9]+))?(?:&?height=([0-9]+))?(?:=([0-9]+)x([0-9]+))?$/,s=t.url.match(e);if(s){const r=s[1]||s[3],n=s[2]||s[4];r&&!i.width&&(i.width=parseInt(r,10)),n&&!i.height&&(i.height=parseInt(n,10)),t.url=t.url.replace(e,"")}r.width&&!i.width&&(i.width=r.width),r.height&&!i.height&&(i.height=r.height)})}},A=class r{constructor(r){this.inputFormat="markdown",this.plugins=[],this.globalData={},this.input=r,this.processor=t(),this.use(S),this.use(D),this.use(I),this.use(q),this.use(p)}static registerFormat(t,i){r.formats[t.toLowerCase()]=i}from(t){return this.inputFormat=t.toLowerCase(),this}use(t){return this.plugins.push(t),this}data(t){return this.globalData={...this.globalData,...t},this}async to(i){i=i.toLowerCase();const e=r.formats[this.inputFormat];e?.parse&&e.parse(this.processor);let s="string"==typeof this.input?this.processor.parse(this.input):this.input;s=await this.processor.run(s),s.data={...s.data,...this.globalData};const n=[...this.plugins].sort((t,r)=>{const i={normalize:0,compile:1,finalize:2},e=t.stage||"normalize",s=r.stage||"normalize";return e!==s?i[e]-i[s]:(t.order||0)-(r.order||0)});for(const t of n)await t.transform(s,this.processor);const a=t().data("settings",this.processor.data("settings")),o=r.formats[i];o?.stringify&&o.stringify(a),"markdown"!==i||o||h.stringify(a);const m=await a.run(s),c=a.stringify(m),l=[];return s.data&&s.data.assets&&l.push(...s.data.assets),{content:c,assets:l}}async toMarkdown(){return(await this.to("markdown")).content}async toHTML(){return(await this.to("html")).content}async toAST(){return(await this.to("ast")).content}};A.formats={markdown:h,html:z,ast:{parse:t=>{t.Parser=t=>JSON.parse(t)},stringify:t=>{t.Compiler=t=>t}}};var B=A;function C(t){return new B(t)}export{B as FluentProcessor,z as htmlFormat,k as htmlStringify,f as markdownCommon,h as markdownFormat,C as mdast};
|
package/docs/README.md
CHANGED
|
@@ -21,6 +21,7 @@ English | [简体中文](_media/README.cn.md) | [GitHub](https://github.com/isdk
|
|
|
21
21
|
- **Table Spans**: Support for `rowspan` and `colspan` in HTML output.
|
|
22
22
|
- **Code Meta**: Structured parsing of code block metadata strings.
|
|
23
23
|
- **Image Sizing**: URL "sugar" support (e.g., `image.png#=500x300`) for image dimensions.
|
|
24
|
+
- **Inline Styles**: Built-in support for `==Highlight==`, `~Subscript~`, and `^Superscript^`.
|
|
24
25
|
- **Deeply Typed**: Built on TypeScript with full support for unist/mdast module augmentation.
|
|
25
26
|
|
|
26
27
|
## Installation
|
|
@@ -50,6 +51,13 @@ const html = await mdast('').toHTML();
|
|
|
50
51
|
// Result: <img src="cat.png" alt="Cat" width="500" height="300">
|
|
51
52
|
```
|
|
52
53
|
|
|
54
|
+
### AST Output
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const ast = await mdast('==Highlighted==').toAST();
|
|
58
|
+
// Returns the mdast Root object
|
|
59
|
+
```
|
|
60
|
+
|
|
53
61
|
### Advanced Pipeline
|
|
54
62
|
|
|
55
63
|
```typescript
|
|
@@ -103,6 +111,7 @@ Plugins are executed based on their `stage` and `order`:
|
|
|
103
111
|
| `normalize-table-span` | normalize | Migrates table cell spans to `hProperties`. |
|
|
104
112
|
| `extract-code-meta` | normalize | Parses `title="foo"` from code block meta. |
|
|
105
113
|
| `image-size` | normalize | Parses `#=WxH` from image URLs. |
|
|
114
|
+
| `normalize-inline-styles` | normalize | Standardizes `==mark==`, `~sub~`, and `^sup^`. |
|
|
106
115
|
|
|
107
116
|
## Contributing
|
|
108
117
|
|
package/docs/_media/README.cn.md
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
- **表格跨行/跨列**: 支持 HTML 输出中的 `rowspan` 和 `colspan`。
|
|
18
18
|
- **代码元数据**: 对代码块元数据字符串进行结构化解析。
|
|
19
19
|
- **图片尺寸**: 支持 URL 糖语法 (例如 `image.png#=500x300`) 来设置图片尺寸。
|
|
20
|
+
- **行内样式**: 内置对 `==高亮==`、`~下标~` 和 `^上标^` 的支持。
|
|
20
21
|
- **深度类型支持**: 基于 TypeScript 构建,完整支持 unist/mdast 的模块扩充。
|
|
21
22
|
|
|
22
23
|
## 安装
|
|
@@ -46,6 +47,13 @@ const html = await mdast('').toHTML();
|
|
|
46
47
|
// 结果: <img src="cat.png" alt="Cat" width="500" height="300">
|
|
47
48
|
```
|
|
48
49
|
|
|
50
|
+
### AST 输出
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const ast = await mdast('==高亮内容==').toAST();
|
|
54
|
+
// 返回 mdast Root 对象
|
|
55
|
+
```
|
|
56
|
+
|
|
49
57
|
### 高级工作流
|
|
50
58
|
|
|
51
59
|
```typescript
|
|
@@ -99,6 +107,7 @@ const result = await mdast('Hello').to('reverse');
|
|
|
99
107
|
| `normalize-table-span` | normalize | 将表格单元格跨度迁移到 `hProperties`。 |
|
|
100
108
|
| `extract-code-meta` | normalize | 从代码块元数据中解析 `title="foo"`。 |
|
|
101
109
|
| `image-size` | normalize | 从图片 URL 中解析 `#=WxH`。 |
|
|
110
|
+
| `normalize-inline-styles` | normalize | 标准化 `==mark==`、`~sub~` 和 `^sup^`。 |
|
|
102
111
|
|
|
103
112
|
## 贡献
|
|
104
113
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: FluentProcessor
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
9
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:20](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L20)
|
|
10
10
|
|
|
11
11
|
Fluent processor for mdast transformations.
|
|
12
12
|
Allows chaining configuration and finally converting to a target format.
|
|
@@ -17,7 +17,7 @@ Allows chaining configuration and finally converting to a target format.
|
|
|
17
17
|
|
|
18
18
|
> **new FluentProcessor**(`input`): `FluentProcessor`
|
|
19
19
|
|
|
20
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
20
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:54](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L54)
|
|
21
21
|
|
|
22
22
|
Creates a new FluentProcessor instance.
|
|
23
23
|
|
|
@@ -39,7 +39,7 @@ The input content (string or mdast tree)
|
|
|
39
39
|
|
|
40
40
|
> `static` **formats**: `Record`\<`string`, [`MdastFormatDefinition`](../interfaces/MdastFormatDefinition.md)\>
|
|
41
41
|
|
|
42
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
42
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:22](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L22)
|
|
43
43
|
|
|
44
44
|
Map of registered format definitions
|
|
45
45
|
|
|
@@ -49,7 +49,7 @@ Map of registered format definitions
|
|
|
49
49
|
|
|
50
50
|
> **data**(`data`): `this`
|
|
51
51
|
|
|
52
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
52
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:88](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L88)
|
|
53
53
|
|
|
54
54
|
Merges global data into the processor.
|
|
55
55
|
|
|
@@ -71,7 +71,7 @@ Key-value pairs to store in global data
|
|
|
71
71
|
|
|
72
72
|
> **from**(`format`): `this`
|
|
73
73
|
|
|
74
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
74
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:70](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L70)
|
|
75
75
|
|
|
76
76
|
Specifies the input format.
|
|
77
77
|
|
|
@@ -93,7 +93,7 @@ The input format name (default: 'markdown')
|
|
|
93
93
|
|
|
94
94
|
> **to**(`format`): `Promise`\<[`ConvertResult`](../interfaces/ConvertResult.md)\<`string`\>\>
|
|
95
95
|
|
|
96
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
96
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:98](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L98)
|
|
97
97
|
|
|
98
98
|
Converts the input content to the specified format.
|
|
99
99
|
|
|
@@ -113,11 +113,27 @@ A promise resolving to the conversion result (content and assets)
|
|
|
113
113
|
|
|
114
114
|
***
|
|
115
115
|
|
|
116
|
+
### toAST()
|
|
117
|
+
|
|
118
|
+
> **toAST**(): `Promise`\<`Root`\>
|
|
119
|
+
|
|
120
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:180](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L180)
|
|
121
|
+
|
|
122
|
+
Helper to get the processed mdast tree.
|
|
123
|
+
|
|
124
|
+
#### Returns
|
|
125
|
+
|
|
126
|
+
`Promise`\<`Root`\>
|
|
127
|
+
|
|
128
|
+
A promise resolving to the mdast Root node
|
|
129
|
+
|
|
130
|
+
***
|
|
131
|
+
|
|
116
132
|
### toHTML()
|
|
117
133
|
|
|
118
134
|
> **toHTML**(): `Promise`\<`string`\>
|
|
119
135
|
|
|
120
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
136
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:171](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L171)
|
|
121
137
|
|
|
122
138
|
Helper to convert content to HTML.
|
|
123
139
|
|
|
@@ -133,7 +149,7 @@ A promise resolving to the HTML string
|
|
|
133
149
|
|
|
134
150
|
> **toMarkdown**(): `Promise`\<`string`\>
|
|
135
151
|
|
|
136
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
152
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:162](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L162)
|
|
137
153
|
|
|
138
154
|
Helper to convert content to Markdown.
|
|
139
155
|
|
|
@@ -149,7 +165,7 @@ A promise resolving to the Markdown string
|
|
|
149
165
|
|
|
150
166
|
> **use**(`plugin`): `this`
|
|
151
167
|
|
|
152
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
168
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:79](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L79)
|
|
153
169
|
|
|
154
170
|
Adds a plugin to the processing pipeline.
|
|
155
171
|
|
|
@@ -171,7 +187,7 @@ The mdast plugin to use
|
|
|
171
187
|
|
|
172
188
|
> `static` **registerFormat**(`name`, `definition`): `void`
|
|
173
189
|
|
|
174
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
190
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:40](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L40)
|
|
175
191
|
|
|
176
192
|
Registers a new format definition.
|
|
177
193
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[**@isdk/mdast-plus**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/mdast-plus](../globals.md) / htmlStringify
|
|
6
|
+
|
|
7
|
+
# Function: htmlStringify()
|
|
8
|
+
|
|
9
|
+
> **htmlStringify**(`this`): `void`
|
|
10
|
+
|
|
11
|
+
Defined in: [packages/mdast-plus/src/formats/html.ts:12](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/formats/html.ts#L12)
|
|
12
|
+
|
|
13
|
+
Standard compiler/stringifier for HTML.
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
### this
|
|
18
|
+
|
|
19
|
+
`any`
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`void`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[**@isdk/mdast-plus**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/mdast-plus](../globals.md) / markdownCommon
|
|
6
|
+
|
|
7
|
+
# Function: markdownCommon()
|
|
8
|
+
|
|
9
|
+
> **markdownCommon**(`this`): `void`
|
|
10
|
+
|
|
11
|
+
Defined in: [packages/mdast-plus/src/formats/markdown.ts:13](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/formats/markdown.ts#L13)
|
|
12
|
+
|
|
13
|
+
Common remark configuration for Markdown.
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
### this
|
|
18
|
+
|
|
19
|
+
`any`
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`void`
|
package/docs/functions/mdast.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **mdast**(`input`): [`FluentProcessor`](../classes/FluentProcessor.md)
|
|
10
10
|
|
|
11
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:
|
|
11
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:191](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/pipeline.ts#L191)
|
|
12
12
|
|
|
13
13
|
Entry point for the fluent mdast-plus API.
|
|
14
14
|
|
package/docs/globals.md
CHANGED
|
@@ -26,8 +26,13 @@
|
|
|
26
26
|
|
|
27
27
|
- [Stage](type-aliases/Stage.md)
|
|
28
28
|
|
|
29
|
+
## Variables
|
|
30
|
+
|
|
31
|
+
- [htmlFormat](variables/htmlFormat.md)
|
|
32
|
+
- [markdownFormat](variables/markdownFormat.md)
|
|
33
|
+
|
|
29
34
|
## Functions
|
|
30
35
|
|
|
31
|
-
- [
|
|
32
|
-
- [
|
|
36
|
+
- [htmlStringify](functions/htmlStringify.md)
|
|
37
|
+
- [markdownCommon](functions/markdownCommon.md)
|
|
33
38
|
- [mdast](functions/mdast.md)
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: ConvertResult\<T\>
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:50](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:50](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L50)
|
|
10
10
|
|
|
11
11
|
Result of a conversion process.
|
|
12
12
|
|
|
@@ -24,7 +24,7 @@ The type of the main content (default: string)
|
|
|
24
24
|
|
|
25
25
|
> **assets**: [`MdastAsset`](MdastAsset.md)[]
|
|
26
26
|
|
|
27
|
-
Defined in: [packages/mdast-plus/src/types.ts:54](https://github.com/isdk/mdast-plus.js/blob/
|
|
27
|
+
Defined in: [packages/mdast-plus/src/types.ts:54](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L54)
|
|
28
28
|
|
|
29
29
|
Extracted assets
|
|
30
30
|
|
|
@@ -34,6 +34,6 @@ Extracted assets
|
|
|
34
34
|
|
|
35
35
|
> **content**: `T`
|
|
36
36
|
|
|
37
|
-
Defined in: [packages/mdast-plus/src/types.ts:52](https://github.com/isdk/mdast-plus.js/blob/
|
|
37
|
+
Defined in: [packages/mdast-plus/src/types.ts:52](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L52)
|
|
38
38
|
|
|
39
39
|
The converted content
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastAsset
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:37](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:37](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L37)
|
|
10
10
|
|
|
11
11
|
Represents an asset (e.g., image) extracted during processing.
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Represents an asset (e.g., image) extracted during processing.
|
|
|
16
16
|
|
|
17
17
|
> **bytes**: `Uint8Array`
|
|
18
18
|
|
|
19
|
-
Defined in: [packages/mdast-plus/src/types.ts:43](https://github.com/isdk/mdast-plus.js/blob/
|
|
19
|
+
Defined in: [packages/mdast-plus/src/types.ts:43](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L43)
|
|
20
20
|
|
|
21
21
|
Raw content as bytes
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ Raw content as bytes
|
|
|
26
26
|
|
|
27
27
|
> **contentType**: `string`
|
|
28
28
|
|
|
29
|
-
Defined in: [packages/mdast-plus/src/types.ts:41](https://github.com/isdk/mdast-plus.js/blob/
|
|
29
|
+
Defined in: [packages/mdast-plus/src/types.ts:41](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L41)
|
|
30
30
|
|
|
31
31
|
MIME type of the asset
|
|
32
32
|
|
|
@@ -36,6 +36,6 @@ MIME type of the asset
|
|
|
36
36
|
|
|
37
37
|
> **path**: `string`
|
|
38
38
|
|
|
39
|
-
Defined in: [packages/mdast-plus/src/types.ts:39](https://github.com/isdk/mdast-plus.js/blob/
|
|
39
|
+
Defined in: [packages/mdast-plus/src/types.ts:39](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L39)
|
|
40
40
|
|
|
41
41
|
Relative path or identifier for the asset
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastDataOrigin
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:60](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:60](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L60)
|
|
10
10
|
|
|
11
11
|
Original metadata for a node.
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ Original metadata for a node.
|
|
|
20
20
|
|
|
21
21
|
> **format**: `string`
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/mdast-plus/src/types.ts:62](https://github.com/isdk/mdast-plus.js/blob/
|
|
23
|
+
Defined in: [packages/mdast-plus/src/types.ts:62](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L62)
|
|
24
24
|
|
|
25
25
|
Source format
|
|
26
26
|
|
|
@@ -30,7 +30,7 @@ Source format
|
|
|
30
30
|
|
|
31
31
|
> `optional` **hash**: `string`
|
|
32
32
|
|
|
33
|
-
Defined in: [packages/mdast-plus/src/types.ts:66](https://github.com/isdk/mdast-plus.js/blob/
|
|
33
|
+
Defined in: [packages/mdast-plus/src/types.ts:66](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L66)
|
|
34
34
|
|
|
35
35
|
Hash of the source content
|
|
36
36
|
|
|
@@ -40,6 +40,6 @@ Hash of the source content
|
|
|
40
40
|
|
|
41
41
|
> `optional` **raw**: `unknown`
|
|
42
42
|
|
|
43
|
-
Defined in: [packages/mdast-plus/src/types.ts:64](https://github.com/isdk/mdast-plus.js/blob/
|
|
43
|
+
Defined in: [packages/mdast-plus/src/types.ts:64](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L64)
|
|
44
44
|
|
|
45
45
|
Raw data from the source
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastFormatDefinition
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:27](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:27](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L27)
|
|
10
10
|
|
|
11
11
|
Definition for an mdast format (parser/stringifier).
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Definition for an mdast format (parser/stringifier).
|
|
|
16
16
|
|
|
17
17
|
> `optional` **parse**: (`processor`) => `void`
|
|
18
18
|
|
|
19
|
-
Defined in: [packages/mdast-plus/src/types.ts:29](https://github.com/isdk/mdast-plus.js/blob/
|
|
19
|
+
Defined in: [packages/mdast-plus/src/types.ts:29](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L29)
|
|
20
20
|
|
|
21
21
|
Function to register parser plugins
|
|
22
22
|
|
|
@@ -36,7 +36,7 @@ Function to register parser plugins
|
|
|
36
36
|
|
|
37
37
|
> `optional` **stringify**: (`processor`) => `void`
|
|
38
38
|
|
|
39
|
-
Defined in: [packages/mdast-plus/src/types.ts:31](https://github.com/isdk/mdast-plus.js/blob/
|
|
39
|
+
Defined in: [packages/mdast-plus/src/types.ts:31](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L31)
|
|
40
40
|
|
|
41
41
|
Function to register stringifier plugins
|
|
42
42
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastMark
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:73](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:73](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L73)
|
|
10
10
|
|
|
11
11
|
mdast node for highlighted text (mark).
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ mdast node for highlighted text (mark).
|
|
|
20
20
|
|
|
21
21
|
> **children**: `PhrasingContent`[]
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/mdast-plus/src/types.ts:75](https://github.com/isdk/mdast-plus.js/blob/
|
|
23
|
+
Defined in: [packages/mdast-plus/src/types.ts:75](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L75)
|
|
24
24
|
|
|
25
25
|
List of children.
|
|
26
26
|
|
|
@@ -65,7 +65,7 @@ have a position.
|
|
|
65
65
|
|
|
66
66
|
> **type**: `"mark"`
|
|
67
67
|
|
|
68
|
-
Defined in: [packages/mdast-plus/src/types.ts:74](https://github.com/isdk/mdast-plus.js/blob/
|
|
68
|
+
Defined in: [packages/mdast-plus/src/types.ts:74](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L74)
|
|
69
69
|
|
|
70
70
|
Node type.
|
|
71
71
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastPlugin
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:13](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:13](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L13)
|
|
10
10
|
|
|
11
11
|
Definition for an mdast plugin.
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Definition for an mdast plugin.
|
|
|
16
16
|
|
|
17
17
|
> **name**: `string`
|
|
18
18
|
|
|
19
|
-
Defined in: [packages/mdast-plus/src/types.ts:15](https://github.com/isdk/mdast-plus.js/blob/
|
|
19
|
+
Defined in: [packages/mdast-plus/src/types.ts:15](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L15)
|
|
20
20
|
|
|
21
21
|
Plugin name
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ Plugin name
|
|
|
26
26
|
|
|
27
27
|
> `optional` **order**: `number`
|
|
28
28
|
|
|
29
|
-
Defined in: [packages/mdast-plus/src/types.ts:19](https://github.com/isdk/mdast-plus.js/blob/
|
|
29
|
+
Defined in: [packages/mdast-plus/src/types.ts:19](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L19)
|
|
30
30
|
|
|
31
31
|
Execution order within the stage (lower numbers run first)
|
|
32
32
|
|
|
@@ -36,7 +36,7 @@ Execution order within the stage (lower numbers run first)
|
|
|
36
36
|
|
|
37
37
|
> `optional` **stage**: [`Stage`](../type-aliases/Stage.md)
|
|
38
38
|
|
|
39
|
-
Defined in: [packages/mdast-plus/src/types.ts:17](https://github.com/isdk/mdast-plus.js/blob/
|
|
39
|
+
Defined in: [packages/mdast-plus/src/types.ts:17](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L17)
|
|
40
40
|
|
|
41
41
|
Processing stage the plugin belongs to
|
|
42
42
|
|
|
@@ -46,7 +46,7 @@ Processing stage the plugin belongs to
|
|
|
46
46
|
|
|
47
47
|
> **transform**: (`tree`, `ctx`) => `void` \| `Promise`\<`void`\>
|
|
48
48
|
|
|
49
|
-
Defined in: [packages/mdast-plus/src/types.ts:21](https://github.com/isdk/mdast-plus.js/blob/
|
|
49
|
+
Defined in: [packages/mdast-plus/src/types.ts:21](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L21)
|
|
50
50
|
|
|
51
51
|
Transformation function
|
|
52
52
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastReader\<I\>
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:131](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:131](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L131)
|
|
10
10
|
|
|
11
11
|
Interface for reading input into an mdast tree.
|
|
12
12
|
|
|
@@ -24,7 +24,7 @@ Input type
|
|
|
24
24
|
|
|
25
25
|
> **read**(`input`): `Promise`\<`Root`\>
|
|
26
26
|
|
|
27
|
-
Defined in: [packages/mdast-plus/src/types.ts:136](https://github.com/isdk/mdast-plus.js/blob/
|
|
27
|
+
Defined in: [packages/mdast-plus/src/types.ts:136](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L136)
|
|
28
28
|
|
|
29
29
|
Reads input and returns an mdast Root node.
|
|
30
30
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastSub
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:81](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:81](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L81)
|
|
10
10
|
|
|
11
11
|
mdast node for subscript text.
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ mdast node for subscript text.
|
|
|
20
20
|
|
|
21
21
|
> **children**: `PhrasingContent`[]
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/mdast-plus/src/types.ts:83](https://github.com/isdk/mdast-plus.js/blob/
|
|
23
|
+
Defined in: [packages/mdast-plus/src/types.ts:83](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L83)
|
|
24
24
|
|
|
25
25
|
List of children.
|
|
26
26
|
|
|
@@ -65,7 +65,7 @@ have a position.
|
|
|
65
65
|
|
|
66
66
|
> **type**: `"sub"`
|
|
67
67
|
|
|
68
|
-
Defined in: [packages/mdast-plus/src/types.ts:82](https://github.com/isdk/mdast-plus.js/blob/
|
|
68
|
+
Defined in: [packages/mdast-plus/src/types.ts:82](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L82)
|
|
69
69
|
|
|
70
70
|
Node type.
|
|
71
71
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastSup
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:89](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:89](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L89)
|
|
10
10
|
|
|
11
11
|
mdast node for superscript text.
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ mdast node for superscript text.
|
|
|
20
20
|
|
|
21
21
|
> **children**: `PhrasingContent`[]
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/mdast-plus/src/types.ts:91](https://github.com/isdk/mdast-plus.js/blob/
|
|
23
|
+
Defined in: [packages/mdast-plus/src/types.ts:91](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L91)
|
|
24
24
|
|
|
25
25
|
List of children.
|
|
26
26
|
|
|
@@ -65,7 +65,7 @@ have a position.
|
|
|
65
65
|
|
|
66
66
|
> **type**: `"sup"`
|
|
67
67
|
|
|
68
|
-
Defined in: [packages/mdast-plus/src/types.ts:90](https://github.com/isdk/mdast-plus.js/blob/
|
|
68
|
+
Defined in: [packages/mdast-plus/src/types.ts:90](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L90)
|
|
69
69
|
|
|
70
70
|
Node type.
|
|
71
71
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastTransformer
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:142](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:142](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L142)
|
|
10
10
|
|
|
11
11
|
Interface for transforming an mdast tree.
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Interface for transforming an mdast tree.
|
|
|
16
16
|
|
|
17
17
|
> **transform**(`tree`): `Promise`\<\{ `assets?`: [`MdastAsset`](MdastAsset.md)[]; `tree`: `Root`; \}\>
|
|
18
18
|
|
|
19
|
-
Defined in: [packages/mdast-plus/src/types.ts:147](https://github.com/isdk/mdast-plus.js/blob/
|
|
19
|
+
Defined in: [packages/mdast-plus/src/types.ts:147](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L147)
|
|
20
20
|
|
|
21
21
|
Transforms the given mdast tree.
|
|
22
22
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Interface: MdastWriter\<Output\>
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/types.ts:154](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/types.ts:154](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L154)
|
|
10
10
|
|
|
11
11
|
Interface for writing an mdast tree to an output format.
|
|
12
12
|
|
|
@@ -24,7 +24,7 @@ Output type (default: string)
|
|
|
24
24
|
|
|
25
25
|
> **write**(`tree`, `assets?`): `Promise`\<[`ConvertResult`](ConvertResult.md)\<`Output`\>\>
|
|
26
26
|
|
|
27
|
-
Defined in: [packages/mdast-plus/src/types.ts:160](https://github.com/isdk/mdast-plus.js/blob/
|
|
27
|
+
Defined in: [packages/mdast-plus/src/types.ts:160](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L160)
|
|
28
28
|
|
|
29
29
|
Writes the mdast tree to the target output.
|
|
30
30
|
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
> **Stage** = `"normalize"` \| `"compile"` \| `"finalize"`
|
|
10
10
|
|
|
11
|
-
Defined in: [packages/mdast-plus/src/types.ts:8](https://github.com/isdk/mdast-plus.js/blob/
|
|
11
|
+
Defined in: [packages/mdast-plus/src/types.ts:8](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/types.ts#L8)
|
|
12
12
|
|
|
13
13
|
Stages for mdast-plus pipeline processing.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[**@isdk/mdast-plus**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/mdast-plus](../globals.md) / htmlFormat
|
|
6
|
+
|
|
7
|
+
# Variable: htmlFormat
|
|
8
|
+
|
|
9
|
+
> `const` **htmlFormat**: [`MdastFormatDefinition`](../interfaces/MdastFormatDefinition.md)
|
|
10
|
+
|
|
11
|
+
Defined in: [packages/mdast-plus/src/formats/html.ts:33](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/formats/html.ts#L33)
|
|
12
|
+
|
|
13
|
+
HTML format definition for FluentProcessor.
|
|
14
|
+
Handles both parsing (HTML -> MDAST) and stringifying (MDAST -> HTML).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[**@isdk/mdast-plus**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@isdk/mdast-plus](../globals.md) / markdownFormat
|
|
6
|
+
|
|
7
|
+
# Variable: markdownFormat
|
|
8
|
+
|
|
9
|
+
> `const` **markdownFormat**: [`MdastFormatDefinition`](../interfaces/MdastFormatDefinition.md)
|
|
10
|
+
|
|
11
|
+
Defined in: [packages/mdast-plus/src/formats/markdown.ts:39](https://github.com/isdk/mdast-plus.js/blob/75ee549d3fb31ef4bc1b4a6b3307f6368072874e/src/formats/markdown.ts#L39)
|
|
12
|
+
|
|
13
|
+
Markdown format definition for FluentProcessor.
|
|
14
|
+
Handles both parsing (Markdown -> MDAST) and stringifying (MDAST -> Markdown).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isdk/mdast-plus",
|
|
3
3
|
"description": "A semantic-first Markdown processing toolkit based on unified, remark, and rehype with a Fluent API and staged plugin system.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Riceball LEE <snowyu.lee@gmail.com>",
|
|
7
7
|
"homepage": "https://github.com/isdk/mdast-plus.js",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[**@isdk/mdast-plus**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@isdk/mdast-plus](../globals.md) / htmlFormat
|
|
6
|
-
|
|
7
|
-
# Function: htmlFormat()
|
|
8
|
-
|
|
9
|
-
> **htmlFormat**(`this`): `void`
|
|
10
|
-
|
|
11
|
-
Defined in: [packages/mdast-plus/src/formats/html.ts:9](https://github.com/isdk/mdast-plus.js/blob/c94d215035e579925cf60814f0a5c05c543ca784/src/formats/html.ts#L9)
|
|
12
|
-
|
|
13
|
-
Unified plugin/configuration for HTML format.
|
|
14
|
-
Includes mdast-to-hast conversion, sanitization (with table span support), and stringification.
|
|
15
|
-
|
|
16
|
-
## Parameters
|
|
17
|
-
|
|
18
|
-
### this
|
|
19
|
-
|
|
20
|
-
`any`
|
|
21
|
-
|
|
22
|
-
## Returns
|
|
23
|
-
|
|
24
|
-
`void`
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
[**@isdk/mdast-plus**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@isdk/mdast-plus](../globals.md) / markdownFormat
|
|
6
|
-
|
|
7
|
-
# Function: markdownFormat()
|
|
8
|
-
|
|
9
|
-
> **markdownFormat**(`this`): `void`
|
|
10
|
-
|
|
11
|
-
Defined in: [packages/mdast-plus/src/formats/markdown.ts:10](https://github.com/isdk/mdast-plus.js/blob/c94d215035e579925cf60814f0a5c05c543ca784/src/formats/markdown.ts#L10)
|
|
12
|
-
|
|
13
|
-
Unified plugin/configuration for Markdown format.
|
|
14
|
-
Includes GFM, directives, math, and frontmatter.
|
|
15
|
-
|
|
16
|
-
## Parameters
|
|
17
|
-
|
|
18
|
-
### this
|
|
19
|
-
|
|
20
|
-
`any`
|
|
21
|
-
|
|
22
|
-
## Returns
|
|
23
|
-
|
|
24
|
-
`void`
|