@isdk/mdast-plus 0.3.4 → 0.3.5
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/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/classes/MdastBasePipeline.md +20 -20
- package/docs/classes/MdastPipeline.md +28 -28
- package/docs/enumerations/PipelineStage.md +6 -6
- package/docs/functions/astCompiler.md +1 -1
- package/docs/functions/checkHtmlUrlExists.md +1 -1
- package/docs/functions/checkUrlExists.md +1 -1
- package/docs/functions/jsonParser.md +1 -1
- package/docs/functions/mdast.md +1 -1
- package/docs/interfaces/MdastDataOrigin.md +4 -4
- package/docs/interfaces/MdastFormat.md +7 -7
- package/docs/interfaces/MdastMark.md +3 -3
- package/docs/interfaces/MdastPlugin.md +9 -9
- package/docs/interfaces/MdastSub.md +3 -3
- package/docs/interfaces/MdastSup.md +3 -3
- package/docs/interfaces/PipelineRunOptions.md +4 -4
- package/docs/interfaces/ReadabilityOptions.md +11 -11
- package/docs/interfaces/SmartExcerptOptions.md +3 -3
- package/docs/type-aliases/PipelineStageName.md +1 -1
- package/docs/variables/DefaultPipelineStage.md +1 -1
- package/docs/variables/astFormat.md +1 -1
- package/docs/variables/htmlFormat.md +1 -1
- package/docs/variables/htmlReadability.md +1 -1
- package/docs/variables/htmlReadabilityPlugin.md +1 -1
- package/docs/variables/htmlReadabilityPlugins.md +1 -1
- package/docs/variables/markdownFormat.md +1 -1
- package/docs/variables/restoreReadabilityMetaPlugin.md +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,a=(t,e,s,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let l of n(e))o.call(t,l)||l===s||r(t,l,{get:()=>e[l],enumerable:!(a=i(e,l))||a.enumerable});return t},l=(t,i,n)=>(n=null!=t?e(s(t)):{},a(!i&&t&&t.__esModule?n:r(n,"default",{value:t,enumerable:!0}),t)),u={};((t,e)=>{for(var i in e)r(t,i,{get:e[i],enumerable:!0})})(u,{DefaultPipelineStage:()=>p,MdastBasePipeline:()=>Q,MdastPipeline:()=>K,PipelineStage:()=>c,astCompiler:()=>U,astFormat:()=>_,checkHtmlUrlExists:()=>ut,checkUrlExists:()=>lt,htmlFormat:()=>I,htmlReadability:()=>it,htmlReadabilityPlugin:()=>nt,htmlReadabilityPlugins:()=>ot,jsonParser:()=>V,markdownFormat:()=>R,mdast:()=>W,restoreReadabilityMetaPlugin:()=>st}),module.exports=(t=u,a(r({},"__esModule",{value:!0}),t));var c=(t=>(t[t.parse=0]="parse",t[t.normalize=100]="normalize",t[t.compile=200]="compile",t[t.finalize=300]="finalize",t[t.stringify=400]="stringify",t))(c||{}),p=200,f=require("unified"),m=require("vfile"),h=l(require("remark-parse")),g=l(require("remark-stringify")),d=l(require("remark-gfm")),y=l(require("remark-directive")),b=l(require("remark-math")),v=l(require("remark-frontmatter")),k=require("unist-util-visit");function w(t,e){return{type:t,children:e,data:{hName:t}}}var q={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:"^"})+"^"},x={plugin:()=>t=>{!function(t){(0,k.visit)(t,"text",(t,e,r)=>{if(!r||void 0===e)return;const i=t.value;let n=0;const s=[];let o=!1;const a=/(==[^=]+==|~[^~]+~|\^[^^]+\^)/g;let l;for(;null!==(l=a.exec(i));){o=!0;const t=l[0],e=l.index;e>n&&s.push({type:"text",value:i.slice(n,e)});let r="mark",u="";t.startsWith("==")?(r="mark",u=t.slice(2,-2)):t.startsWith("~")?(r="sub",u=t.slice(1,-1)):t.startsWith("^")&&(r="sup",u=t.slice(1,-1)),s.push(w(r,[{type:"text",value:u}])),n=a.lastIndex}return o?(n<i.length&&s.push({type:"text",value:i.slice(n)}),r.children.splice(e,1,...s),e+s.length):void 0})}(t)},stage:100},j=require("unist-util-visit"),M={error:"danger",warn:"warning",success:"tip",important:"important",caution:"caution",note:"note"},P={plugin:()=>async t=>{(0,j.visit)(t,["containerDirective","leafDirective","textDirective"],t=>{const e=t,r=e.name.toLowerCase();if(e.name=M[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,j.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(" ")}})},stage:100,order:10},S=require("unist-util-visit"),N={plugin:()=>async t=>{(0,S.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)}})},stage:100,order:20},T=require("unist-util-visit"),F=require("shell-quote");var O={plugin:()=>async t=>{(0,T.visit)(t,"code",t=>{if(t.meta){const e=function(t){const e={},r=(0,F.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}}})},stage:100,order:30},A=require("unist-util-visit"),E={plugin:()=>async t=>{(0,A.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)})},stage:100,order:40},L=[{plugin:h.default,stage:0},{plugin:d.default,options:[{singleTilde:!1}],stage:0},{plugin:y.default,stage:0},{plugin:b.default,stage:0},{plugin:v.default,options:[["yaml","toml"]],stage:0},P,N,O,E,x],D=[{plugin:g.default,options:[{handlers:q}],stage:400},{plugin:d.default,options:[{singleTilde:!1}],stage:400},{plugin:y.default,stage:400},{plugin:b.default,stage:400},{plugin:v.default,options:[["yaml","toml"]],stage:400}];D.forEach(t=>{t.plugin===g.default?t.order=100:t.order=10});var R={id:"markdown",title:"Markdown (GFM + Directives)",extensions:["md","markdown","mdown","mkdn"],mediaTypes:["text/markdown"],input:L,output:D},z=l(require("rehype-parse")),$=l(require("rehype-remark")),C=l(require("remark-rehype")),H=l(require("rehype-sanitize")),B=l(require("rehype-stringify")),I={id:"html",title:"HTML",extensions:["html","htm"],mediaTypes:["text/html"],input:[{name:"rehype-parse",plugin:z.default,stage:0},{name:"rehype-remark",plugin:$.default,options:[{handlers:{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}}}],stage:0}],output:[{plugin:C.default,stage:300,order:10},{plugin:H.default,options:[{...H.defaultSchema,tagNames:[...H.defaultSchema.tagNames||[],"mark","sub","sup"],attributes:{...H.defaultSchema.attributes,"*":[...H.defaultSchema.attributes?.["*"]||[],"className","id","style"],td:[...H.defaultSchema.attributes?.td||[],"rowSpan","colSpan","rowspan","colspan"],th:[...H.defaultSchema.attributes?.th||[],"rowSpan","colSpan","rowspan","colspan"],img:[...H.defaultSchema.attributes?.img||[],"width","height"]}}],stage:300,order:20},{plugin:B.default,stage:400}]};function U(){this.Compiler=t=>t}function V(){this.Parser=t=>JSON.parse(t)}var _={id:"ast",title:"MDAST",input:[{plugin:V,stage:0},P,N,O,E,x],output:[{plugin:U,options:[],stage:400}]};function G(t){return"object"==typeof t&&null!==t&&"string"==typeof t.type}var J=class t{constructor(t){this.queue=[],this._data={},this.input=t}static register(t){this.registry.set(t.id,t)}static getFormat(t){return this.registry.get(t)}data(t,e){return"string"==typeof t?this._data[t]=e:Object.assign(this._data,t),this}getFormat(t){return this.constructor.getFormat(t)}resolveFormat(t){if("string"==typeof t){const e=this.getFormat(t);if(!e)throw new Error(`[MdastPlus] Format '${t}' is not registered.`);return e}return t}toRuntimeEntry(t,e,r){let i=e;void 0!==t.stage&&(i="string"==typeof t.stage?c[t.stage]??e:t.stage);let n=t.options||[];const s=t.name||t.plugin.name;if(r&&s&&s in r){const e=r[s];"object"!=typeof e||null===e||Array.isArray(e)?n=Array.isArray(e)?e:[e]:("main"in e&&(t.main=!!e.main),"before"in e&&(t.before=e.before),"after"in e&&(t.after=e.after),n=[e])}return{name:s,plugin:t.plugin,options:n,stage:i,order:t.order||0,main:t.main,before:t.before,after:t.after}}ensureInputPlugins(e,r,i=400){const n=e.some(t=>0===(t.stage??p)),s=G(this.input);if(!n){let n=[];if(s){const e=t.getFormat("ast");e&&e.input&&(n=e.input)}else{const e=t.getFormat("markdown");e&&e.input&&(n=e.input)}for(const t of n){const n=this.toRuntimeEntry(t,0,r);(n.stage??p)<=i&&e.push(n)}}}from(t,e){const r=this.resolveFormat(t);if(!r.input||0===r.input.length)throw new Error(`[MdastPlus] Format '${r.id}' does not support input.`);for(const t of r.input)this.queue.push(this.toRuntimeEntry(t,0,e));return this}resolveRunQueue(t,e,r,i){let n=[];if(n=e?this.queue.map(t=>this.toRuntimeEntry(t,t.stage??p,e)):[...this.queue],void 0!==r){const t=r;n=n.filter(e=>(e.stage??p)<=t);const s=n.findIndex(e=>(e.stage??p)===t),o=-1!==s?s+(i??0):n.length-1,a=n.slice(0,o+1),l=n.filter(t=>t.main&&!a.includes(t));n=a.concat(l),this.ensureInputPlugins(n,e,t),n.push({plugin:U,options:[],stage:400,order:0})}else if(this.ensureInputPlugins(n,e,400),t.output)for(const r of t.output)n.push(this.toRuntimeEntry(r,300,e));return n}async to(t,e){const r=this.resolveFormat(t);if(!r.output)throw new Error(`[MdastPlus] Format '${r.id}' does not support output.`);let i,n,s;if(e){const t=e;"overrides"in t||"stage"in t||"stopAtIndex"in t?(i=t.overrides,n="string"==typeof t.stage?c[t.stage]:t.stage,s=t.stopAtIndex):i=e}const o=this.resolveRunQueue(r,i,n,s),a=this.assembleProcessor(o);if(G(this.input)){const t=await a.run(this.input),e=a.stringify(t),r=new m.VFile;return"string"==typeof e||Buffer.isBuffer(e)?r.value=e:r.result=e,r}return a.process(this.input)}use(t,...e){return this.useAt("compile",t,...e)}normalizePluggable(t,e=[]){const r=[];if(Array.isArray(t)){let i=!1;if(t.length>0&&"function"==typeof t[0]){t.slice(1).some(t=>!function(t){if("function"==typeof t)return!0;if(Array.isArray(t))return!0;if("object"==typeof t&&null!==t){if("plugin"in t&&"function"==typeof t.plugin)return!0;if("plugins"in t)return!0}return!1}(t))&&(i=!0)}if(i){const[e,...i]=t;r.push({plugin:e,options:i})}else for(const i of t)r.push(...this.normalizePluggable(i,e))}else if("function"==typeof t)r.push({plugin:t,options:e});else if("object"==typeof t&&null!==t)if("plugin"in t&&"function"==typeof t.plugin){const i=t,n=e.length>0?e:i.options||[];r.push({...i,options:n})}else if("plugins"in t){const e=t;e.plugins&&r.push(...this.normalizePluggable(e.plugins))}return r}useAt(t,e,...r){let i,n,s;"string"==typeof t||"number"==typeof t?(i=("string"==typeof t?c[t]:t)??p,n=e,s=r):(i=void 0,n=t,s=[e,...r].filter(t=>void 0!==t));const o=this.normalizePluggable(n,s);for(const t of o){const e=i??p;this.queue.push(this.toRuntimeEntry(t,e))}return this}priority(t){const e=this.queue[this.queue.length-1];return e&&(e.order=t),this}configure(t,...e){for(let r=this.queue.length-1;r>=0;r--){const i=this.queue[r];if((i.name||i.plugin.name)===t){i.options=e;break}}return this}assembleProcessor(t){const e={};for(const r of t){const t=r.stage??p;e[t]||(e[t]=[]),e[t].push(r)}const r=[],i=Object.keys(e).map(Number).sort((t,e)=>t-e);for(const t of i){const i=e[t].sort((t,e)=>(t.order||0)-(e.order||0)),n=i.findIndex(t=>t.main);if(-1!==n){const t=i[n];!1===t.options?.[0]?console.warn(`Main Plugin "${t.name}" is disabled. Skipping.`):0!==n&&(i.splice(n,1),i[0]=t)}let s=!0,o=0;for(;s&&o<i.length;){s=!1,o++;for(let t=0;t<i.length;t++){const e=i[t];if(e.after){const r=i.findIndex(t=>t.name===e.after);if(-1!==r&&r>t){i.splice(t,1),i.splice(r,0,e),s=!0;break}}if(e.before){const r=i.findIndex(t=>t.name===e.before);if(-1!==r&&r<t){i.splice(t,1),i.splice(r,0,e),s=!0;break}}}}r.push(...i)}const n=(0,f.unified)();Object.keys(this._data).length>0&&n.data(this._data);for(const t of r)n.use(t.plugin,...t.options||[]);return n}};J.registry=new Map;var Q=J,K=class extends Q{async toMarkdown(t){const e=await this.to("markdown"),r=String(e);if(t?.attachMetadata&&e.data?.readability){const{length:t,...i}=e.data.readability,n=new String(r);return Object.assign(n,i),n}return r}toMarkdownVFile(){return this.to("markdown")}async toHtml(){const t=await this.to("html");return String(t)}toHtmlVFile(){return this.to("html")}async toAst(t){return(await this.to("ast",t)).result}toHTML(){return this.toHtml()}toAST(t){return this.toAst(t)}};function W(t){return new K(t)}K.register(R),K.register(I),K.register(_);var X=require("unist-util-visit"),Y=require("hast-util-from-html"),Z=require("hast-util-from-dom"),tt=require("yaml"),et=require("smol-toml"),rt=require("lodash-es"),it=function(t){const{readability:e,jsdom:r,hast:i,url:n,fields:s}=t||{};this.parser=function(o,a){if(!1===e)return(0,Y.fromHtml)(o,{fragment:!0,...i});let l,u;try{l=require("jsdom").JSDOM;u=require("@mozilla/readability").Readability}catch(t){throw new Error("[html-readability] Dependency missing. Please install 'jsdom' and '@mozilla/readability'.")}const c=new u(new l(o,{url:n,pretendToBeVisual:!0,...r,includeNodeLocations:!0}).window.document,{maxElemsToParse:1e5,nbTopCandidates:5,charThreshold:500,keepClasses:!0,...e,serializer:t=>t}).parse();if(!c||!c.content)return(0,Y.fromHtml)(o,{fragment:!0,...i});const p=c.content;let f=(0,Z.fromDom)(p,{afterTransform:i?.afterTransform});const m=!1!==i?.fragment,{smartExcerpt:h=!0,sourceLink:g}=t||{};let d=(0,rt.omitBy)(c,t=>null==t||""===t);const y=n||d.url,b=d.title;if(h&&d.excerpt&&d.textContent){const{threshold:t=.6,minContentLength:e=300}=!0===h?{}:h,r=d.excerpt.trim().toLowerCase().replace(/\s+/g," "),i=d.textContent.trim().toLowerCase().replace(/\s+/g," ");if(i.includes(r)){(r.length/i.length>t||i.length<e)&&delete d.excerpt}}if(n&&(d.url=n),delete d.content,delete d.textContent,s)if(Array.isArray(s))d=(0,rt.pick)(d,s);else{const t={};for(const[e,r]of Object.entries(s))void 0!==d[e]&&(t[r]=d[e]);d=t}if(t?.extraMetadata&&(d={...d,...t.extraMetadata}),a&&(a.data=a.data||{},a.data.readability=d),f){const t=[f];g&&y&&!ut(f,y)&&t.push({type:"element",tagName:"blockquote",properties:{},children:[{type:"element",tagName:"p",properties:{},children:[{type:"text",value:"Source: "},{type:"element",tagName:"a",properties:{href:y},children:[{type:"text",value:b||y}]}]}]}),f=m?{type:"root",children:t}:{type:"root",children:[{type:"element",tagName:"html",properties:{},children:[{type:"element",tagName:"head",properties:{},children:[]},{type:"element",tagName:"body",properties:{},children:t}]}]},f.data=f.data||{},f.data.readability=d}return f}},nt={name:"readability",plugin:it,stage:0,main:!0},st={name:"restore-readability-meta",plugin:t=>(e,r)=>{const{frontmatter:i,sourceLink:n,extraMetadata:s}=t||{};if(r.data?.readability||s){if(r.data=r.data||{},r.data.readability={...r.data.readability,...s},e.data=e.data||{},e.data.readability=r.data.readability,i){const t="toml"===i?"toml":"yaml",n=("toml"===t?(0,et.stringify)(r.data.readability).trim():(0,tt.stringify)(r.data.readability)).trim();e.children.unshift({type:t,value:n})}if(n&&r.data.readability.url){const{url:t,title:i}=r.data.readability;lt(e,t)||e.children.push({type:"blockquote",children:[{type:"paragraph",children:[{type:"text",value:"Source: "},{type:"link",url:t,children:[{type:"text",value:i||t}]}]}]})}}},stage:0,after:"rehype-remark"},ot=[nt,st];function at(t,e){if(!t||!e)return!1;if(t===e)return!0;try{const r=new URL(t),i=new URL(e);return r.href===i.href}catch{return t.replace(/\/$/,"")===e.replace(/\/$/,"")}}function lt(t,e){if(!e)return!1;let r=!1;return(0,X.visit)(t,"link",t=>{if(at(t.url,e))return r=!0,!1}),r}function ut(t,e){if(!e)return!1;let r=!1;return(0,X.visit)(t,"element",t=>{if("a"===t.tagName&&t.properties&&at(t.properties.href,e))return r=!0,!1}),r}
|
|
1
|
+
"use strict";var t,e=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,a=(t,e,s,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let l of n(e))o.call(t,l)||l===s||r(t,l,{get:()=>e[l],enumerable:!(a=i(e,l))||a.enumerable});return t},l=(t,i,n)=>(n=null!=t?e(s(t)):{},a(!i&&t&&t.__esModule?n:r(n,"default",{value:t,enumerable:!0}),t)),u={};((t,e)=>{for(var i in e)r(t,i,{get:e[i],enumerable:!0})})(u,{DefaultPipelineStage:()=>p,MdastBasePipeline:()=>Q,MdastPipeline:()=>K,PipelineStage:()=>c,astCompiler:()=>U,astFormat:()=>_,checkHtmlUrlExists:()=>ut,checkUrlExists:()=>lt,htmlFormat:()=>I,htmlReadability:()=>it,htmlReadabilityPlugin:()=>nt,htmlReadabilityPlugins:()=>ot,jsonParser:()=>V,markdownFormat:()=>R,mdast:()=>W,restoreReadabilityMetaPlugin:()=>st}),module.exports=(t=u,a(r({},"__esModule",{value:!0}),t));var c=(t=>(t[t.parse=0]="parse",t[t.normalize=100]="normalize",t[t.compile=200]="compile",t[t.finalize=300]="finalize",t[t.stringify=400]="stringify",t))(c||{}),p=200,f=require("unified"),m=require("vfile"),h=l(require("remark-parse")),g=l(require("remark-stringify")),d=l(require("remark-gfm")),y=l(require("remark-directive")),b=l(require("remark-math")),v=l(require("remark-frontmatter")),k=require("unist-util-visit");function w(t,e){return{type:t,children:e,data:{hName:t}}}var q={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:"^"})+"^"},x={plugin:()=>t=>{!function(t){(0,k.visit)(t,"text",(t,e,r)=>{if(!r||void 0===e)return;const i=t.value;let n=0;const s=[];let o=!1;const a=/(==[^=]+==|~[^~]+~|\^[^^]+\^)/g;let l;for(;null!==(l=a.exec(i));){o=!0;const t=l[0],e=l.index;e>n&&s.push({type:"text",value:i.slice(n,e)});let r="mark",u="";t.startsWith("==")?(r="mark",u=t.slice(2,-2)):t.startsWith("~")?(r="sub",u=t.slice(1,-1)):t.startsWith("^")&&(r="sup",u=t.slice(1,-1)),s.push(w(r,[{type:"text",value:u}])),n=a.lastIndex}return o?(n<i.length&&s.push({type:"text",value:i.slice(n)}),r.children.splice(e,1,...s),e+s.length):void 0})}(t)},stage:100},j=require("unist-util-visit"),M={error:"danger",warn:"warning",success:"tip",important:"important",caution:"caution",note:"note"},P={plugin:()=>async t=>{(0,j.visit)(t,["containerDirective","leafDirective","textDirective"],t=>{const e=t,r=e.name.toLowerCase();if(e.name=M[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,j.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(" ")}})},stage:100,order:10},S=require("unist-util-visit"),N={plugin:()=>async t=>{(0,S.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)}})},stage:100,order:20},O=require("unist-util-visit"),T=require("shell-quote");var F={plugin:()=>async t=>{(0,O.visit)(t,"code",t=>{if(t.meta){const e=function(t){const e={},r=(0,T.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}}})},stage:100,order:30},A=require("unist-util-visit"),E={plugin:()=>async t=>{(0,A.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)})},stage:100,order:40},L=[{plugin:h.default,stage:0},{plugin:d.default,options:[{singleTilde:!1}],stage:0},{plugin:y.default,stage:0},{plugin:b.default,stage:0},{plugin:v.default,options:[["yaml","toml"]],stage:0},P,N,F,E,x],D=[{plugin:g.default,options:[{handlers:q}],stage:400},{plugin:d.default,options:[{singleTilde:!1}],stage:400},{plugin:y.default,stage:400},{plugin:b.default,stage:400},{plugin:v.default,options:[["yaml","toml"]],stage:400}];D.forEach(t=>{t.plugin===g.default?t.order=100:t.order=10});var R={id:"markdown",title:"Markdown (GFM + Directives)",extensions:["md","markdown","mdown","mkdn"],mediaTypes:["text/markdown"],input:L,output:D},z=l(require("rehype-parse")),$=l(require("rehype-remark")),C=l(require("remark-rehype")),H=l(require("rehype-sanitize")),B=l(require("rehype-stringify")),I={id:"html",title:"HTML",extensions:["html","htm"],mediaTypes:["text/html"],input:[{name:"rehype-parse",plugin:z.default,stage:0},{name:"rehype-remark",plugin:$.default,options:[{handlers:{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}}}],stage:0}],output:[{plugin:C.default,stage:300,order:10},{plugin:H.default,options:[{...H.defaultSchema,tagNames:[...H.defaultSchema.tagNames||[],"mark","sub","sup"],attributes:{...H.defaultSchema.attributes,"*":[...H.defaultSchema.attributes?.["*"]||[],"className","id","style"],td:[...H.defaultSchema.attributes?.td||[],"rowSpan","colSpan","rowspan","colspan"],th:[...H.defaultSchema.attributes?.th||[],"rowSpan","colSpan","rowspan","colspan"],img:[...H.defaultSchema.attributes?.img||[],"width","height"]}}],stage:300,order:20},{plugin:B.default,stage:400}]};function U(){this.Compiler=t=>t}function V(){this.Parser=t=>JSON.parse(t)}var _={id:"ast",title:"MDAST",input:[{plugin:V,stage:0},P,N,F,E,x],output:[{plugin:U,options:[],stage:400}]};function G(t){return"object"==typeof t&&null!==t&&"string"==typeof t.type}var J=class t{constructor(t){this.queue=[],this._data={},this.input=t}static register(t){this.registry.set(t.id,t)}static getFormat(t){return this.registry.get(t)}data(t,e){return"string"==typeof t?this._data[t]=e:Object.assign(this._data,t),this}getFormat(t){return this.constructor.getFormat(t)}resolveFormat(t){if("string"==typeof t){const e=this.getFormat(t);if(!e)throw new Error(`[MdastPlus] Format '${t}' is not registered.`);return e}return t}toRuntimeEntry(t,e,r){let i=e;void 0!==t.stage&&(i="string"==typeof t.stage?c[t.stage]??e:t.stage);let n=t.options||[];const s=t.name||t.plugin.name;if(r&&s&&s in r){const e=r[s];"object"!=typeof e||null===e||Array.isArray(e)?n=Array.isArray(e)?e:[e]:("main"in e&&(t.main=!!e.main),"before"in e&&(t.before=e.before),"after"in e&&(t.after=e.after),n=[e])}return{name:s,plugin:t.plugin,options:n,stage:i,order:t.order||0,main:t.main,before:t.before,after:t.after}}ensureInputPlugins(e,r,i=400){const n=e.some(t=>0===(t.stage??p)),s=G(this.input);if(!n){let n=[];if(s){const e=t.getFormat("ast");e&&e.input&&(n=e.input)}else{const e=t.getFormat("markdown");e&&e.input&&(n=e.input)}for(const t of n){const n=this.toRuntimeEntry(t,0,r);(n.stage??p)<=i&&e.push(n)}}}from(t,e){const r=this.resolveFormat(t);if(!r.input||0===r.input.length)throw new Error(`[MdastPlus] Format '${r.id}' does not support input.`);for(const t of r.input)this.queue.push(this.toRuntimeEntry(t,0,e));return this}resolveRunQueue(t,e,r,i){let n=[];if(n=e?this.queue.map(t=>this.toRuntimeEntry(t,t.stage??p,e)):[...this.queue],void 0!==r){const t=r;n=n.filter(e=>(e.stage??p)<=t);const s=n.findIndex(e=>(e.stage??p)===t),o=-1!==s?s+(i??0):n.length-1,a=n.slice(0,o+1),l=n.filter(t=>t.main&&!a.includes(t));n=a.concat(l),this.ensureInputPlugins(n,e,t),n.push({plugin:U,options:[],stage:400,order:0})}else if(this.ensureInputPlugins(n,e,400),t.output)for(const r of t.output)n.push(this.toRuntimeEntry(r,300,e));return n}async to(t,e){const r=this.resolveFormat(t);if(!r.output)throw new Error(`[MdastPlus] Format '${r.id}' does not support output.`);let i,n,s;if(e){const t=e;"overrides"in t||"stage"in t||"stopAtIndex"in t?(i=t.overrides,n="string"==typeof t.stage?c[t.stage]:t.stage,s=t.stopAtIndex):i=e}const o=this.resolveRunQueue(r,i,n,s),a=this.assembleProcessor(o);if(G(this.input)){const t=await a.run(this.input),e=a.stringify(t),r=new m.VFile;return"string"==typeof e||Buffer.isBuffer(e)?r.value=e:r.result=e,r}return a.process(this.input)}use(t,...e){return this.useAt("compile",t,...e)}normalizePluggable(t,e=[]){const r=[];if(Array.isArray(t)){let i=!1;if(t.length>0&&"function"==typeof t[0]){t.slice(1).some(t=>!function(t){if("function"==typeof t)return!0;if(Array.isArray(t))return!0;if("object"==typeof t&&null!==t){if("plugin"in t&&"function"==typeof t.plugin)return!0;if("plugins"in t)return!0}return!1}(t))&&(i=!0)}if(i){const[e,...i]=t;r.push({plugin:e,options:i})}else for(const i of t)r.push(...this.normalizePluggable(i,e))}else if("function"==typeof t)r.push({plugin:t,options:e});else if("object"==typeof t&&null!==t)if("plugin"in t&&"function"==typeof t.plugin){const i=t,n=e.length>0?e:i.options||[];r.push({...i,options:n})}else if("plugins"in t){const e=t;e.plugins&&r.push(...this.normalizePluggable(e.plugins))}return r}useAt(t,e,...r){let i,n,s;"string"==typeof t||"number"==typeof t?(i=("string"==typeof t?c[t]:t)??p,n=e,s=r):(i=void 0,n=t,s=[e,...r].filter(t=>void 0!==t));const o=this.normalizePluggable(n,s);for(const t of o){const e=i??p;this.queue.push(this.toRuntimeEntry(t,e))}return this}priority(t){const e=this.queue[this.queue.length-1];return e&&(e.order=t),this}configure(t,...e){for(let r=this.queue.length-1;r>=0;r--){const i=this.queue[r];if((i.name||i.plugin.name)===t){i.options=e;break}}return this}assembleProcessor(t){const e={};for(const r of t){const t=r.stage??p;e[t]||(e[t]=[]),e[t].push(r)}const r=[],i=Object.keys(e).map(Number).sort((t,e)=>t-e);for(const t of i){const i=e[t].sort((t,e)=>(t.order||0)-(e.order||0)),n=i.findIndex(t=>t.main);if(-1!==n){const t=i[n];!1===t.options?.[0]?console.warn(`Main Plugin "${t.name}" is disabled. Skipping.`):0!==n&&(i.splice(n,1),i[0]=t)}let s=!0,o=0;for(;s&&o<i.length;){s=!1,o++;for(let t=0;t<i.length;t++){const e=i[t];if(e.after){const r=i.findIndex(t=>t.name===e.after);if(-1!==r&&r>t){i.splice(t,1),i.splice(r,0,e),s=!0;break}}if(e.before){const r=i.findIndex(t=>t.name===e.before);if(-1!==r&&r<t){i.splice(t,1),i.splice(r,0,e),s=!0;break}}}}r.push(...i)}const n=(0,f.unified)();Object.keys(this._data).length>0&&n.data(this._data);for(const t of r)n.use(t.plugin,...t.options||[]);return n}};J.registry=new Map;var Q=J,K=class extends Q{async toMarkdown(t){const e=await this.to("markdown"),r=String(e);if(t?.attachMetadata&&e.data?.readability){const{length:t,...i}=e.data.readability,n=new String(r);return Object.assign(n,i),n}return r}toMarkdownVFile(){return this.to("markdown")}async toHtml(){const t=await this.to("html");return String(t)}toHtmlVFile(){return this.to("html")}async toAst(t){return(await this.to("ast",t)).result}toHTML(){return this.toHtml()}toAST(t){return this.toAst(t)}};function W(t){return new K(t)}K.register(R),K.register(I),K.register(_);var X=require("unist-util-visit"),Y=require("hast-util-from-html"),Z=require("hast-util-from-dom"),tt=require("yaml"),et=require("smol-toml"),rt=require("lodash-es"),it=function(t){const{readability:e,jsdom:r,hast:i,url:n,fields:s}=t||{};this.parser=function(o,a){if(!1===e)return(0,Y.fromHtml)(o,{fragment:!0,...i});let l,u;try{l=require("jsdom").JSDOM;u=require("@mozilla/readability").Readability}catch(t){throw new Error("[html-readability] Dependency missing. Please install 'jsdom' and '@mozilla/readability'.")}const c=new u(new l(o,{url:n,pretendToBeVisual:!0,...r,includeNodeLocations:!0}).window.document,{maxElemsToParse:1e5,nbTopCandidates:5,charThreshold:500,keepClasses:!0,...e,serializer:t=>t}).parse();if(!c||!c.content)return(0,Y.fromHtml)(o,{fragment:!0,...i});const p=c.content;let f=(0,Z.fromDom)(p,{afterTransform:i?.afterTransform});const m=!1!==i?.fragment,{smartExcerpt:h=!0,sourceLink:g}=t||{};let d=(0,rt.omitBy)(c,t=>null==t||""===t);const y=n||d.url,b=d.title;if(h&&d.excerpt&&d.textContent){const{threshold:t=.6,minContentLength:e=300}=!0===h?{}:h,r=d.excerpt.trim().toLowerCase().replace(/\s+/g," "),i=d.textContent.trim().toLowerCase().replace(/\s+/g," ");if(i.includes(r)){(r.length/i.length>t||i.length<e)&&delete d.excerpt}}if(n&&(d.url=n),delete d.content,delete d.textContent,s)if(Array.isArray(s))d=(0,rt.pick)(d,s);else{const t={};for(const[e,r]of Object.entries(s))void 0!==d[e]&&(t[r]=d[e]);d=t}if(t?.extraMetadata&&(d={...d,...t.extraMetadata}),a&&(a.data=a.data||{},a.data.readability=d),f){const t=[f];g&&y&&!ut(f,y)&&t.push({type:"element",tagName:"blockquote",properties:{},children:[{type:"element",tagName:"p",properties:{},children:[{type:"text",value:"Source: "},{type:"element",tagName:"a",properties:{href:y},children:[{type:"text",value:b||y}]}]}]}),f=m?{type:"root",children:t}:{type:"root",children:[{type:"element",tagName:"html",properties:{},children:[{type:"element",tagName:"head",properties:{},children:[]},{type:"element",tagName:"body",properties:{},children:t}]}]},f.data=f.data||{},f.data.readability=d}return f}},nt={name:"readability",plugin:it,stage:0,main:!0},st={name:"restore-readability-meta",plugin:t=>(e,r)=>{const{frontmatter:i,sourceLink:n,extraMetadata:s}=t||{};if(r.data?.readability||s){if(r.data=r.data||{},r.data.readability={...r.data.readability,...s},e.data=e.data||{},e.data.readability=r.data.readability,i&&Object.keys(r.data.readability).length>0){const t="toml"===i?"toml":"yaml",n=("toml"===t?(0,et.stringify)(r.data.readability).trim():(0,tt.stringify)(r.data.readability)).trim();n&&e.children.unshift({type:t,value:n})}if(n&&r.data.readability.url){const{url:t,title:i}=r.data.readability;lt(e,t)||e.children.push({type:"blockquote",children:[{type:"paragraph",children:[{type:"text",value:"Source: "},{type:"link",url:t,children:[{type:"text",value:i||t}]}]}]})}}},stage:0,after:"rehype-remark"},ot=[nt,st];function at(t,e){if(!t||!e)return!1;if(t===e)return!0;try{const r=new URL(t),i=new URL(e);return r.href===i.href}catch{return t.replace(/\/$/,"")===e.replace(/\/$/,"")}}function lt(t,e){if(!e)return!1;let r=!1;return(0,X.visit)(t,"link",t=>{if(at(t.url,e))return r=!0,!1}),r}function ut(t,e){if(!e)return!1;let r=!1;return(0,X.visit)(t,"element",t=>{if("a"===t.tagName&&t.properties&&at(t.properties.href,e))return r=!0,!1}),r}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,e)=>("undefined"!=typeof require?require:t)[e]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),e=(t=>(t[t.parse=0]="parse",t[t.normalize=100]="normalize",t[t.compile=200]="compile",t[t.finalize=300]="finalize",t[t.stringify=400]="stringify",t))(e||{}),r=200;import{unified as i}from"unified";import{VFile as n}from"vfile";import o from"remark-parse";import s from"remark-stringify";import a from"remark-gfm";import l from"remark-directive";import u from"remark-math";import p from"remark-frontmatter";import{visit as f}from"unist-util-visit";function c(t,e){return{type:t,children:e,data:{hName:t}}}var m={plugin:()=>t=>{!function(t){f(t,"text",(t,e,r)=>{if(!r||void 0===e)return;const i=t.value;let n=0;const o=[];let s=!1;const a=/(==[^=]+==|~[^~]+~|\^[^^]+\^)/g;let l;for(;null!==(l=a.exec(i));){s=!0;const t=l[0],e=l.index;e>n&&o.push({type:"text",value:i.slice(n,e)});let r="mark",u="";t.startsWith("==")?(r="mark",u=t.slice(2,-2)):t.startsWith("~")?(r="sub",u=t.slice(1,-1)):t.startsWith("^")&&(r="sup",u=t.slice(1,-1)),o.push(c(r,[{type:"text",value:u}])),n=a.lastIndex}return s?(n<i.length&&o.push({type:"text",value:i.slice(n)}),r.children.splice(e,1,...o),e+o.length):void 0})}(t)},stage:100};import{visit as h}from"unist-util-visit";var d={error:"danger",warn:"warning",success:"tip",important:"important",caution:"caution",note:"note"},g={plugin:()=>async t=>{h(t,["containerDirective","leafDirective","textDirective"],t=>{const e=t,r=e.name.toLowerCase();if(e.name=d[r]||r,e.children&&e.children.length>0){const t=e.children[0];if(t.data?.directiveLabel||"directiveLabel"===t.type){let r="";h(t,"text",t=>{r+=t.value}),r&&!e.attributes?.title&&(e.attributes=e.attributes||{},e.attributes.title=r.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(" ")}})},stage:100,order:10};import{visit as y}from"unist-util-visit";var v={plugin:()=>async t=>{y(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)}})},stage:100,order:20};import{visit as w}from"unist-util-visit";import{parse as b}from"shell-quote";var k={plugin:()=>async t=>{w(t,"code",t=>{if(t.meta){const e=function(t){const e={},r=b(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}}})},stage:100,order:30};import{visit as x}from"unist-util-visit";var S={plugin:()=>async t=>{x(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],o=n[2]||n[4];e&&!r.width&&(r.width=parseInt(e,10)),o&&!r.height&&(r.height=parseInt(o,10)),t.url=t.url.replace(i,"")}e.width&&!r.width&&(r.width=e.width),e.height&&!r.height&&(r.height=e.height)})},stage:100,order:40},M=[{plugin:o,stage:0},{plugin:a,options:[{singleTilde:!1}],stage:0},{plugin:l,stage:0},{plugin:u,stage:0},{plugin:p,options:[["yaml","toml"]],stage:0},g,v,k,S,m],N=[{plugin:s,options:[{handlers:{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:"^"})+"^"}}],stage:400},{plugin:a,options:[{singleTilde:!1}],stage:400},{plugin:l,stage:400},{plugin:u,stage:400},{plugin:p,options:[["yaml","toml"]],stage:400}];N.forEach(t=>{t.plugin===s?t.order=100:t.order=10});var T={id:"markdown",title:"Markdown (GFM + Directives)",extensions:["md","markdown","mdown","mkdn"],mediaTypes:["text/markdown"],input:M,output:N};import j from"rehype-parse";import P from"rehype-remark";import q from"remark-rehype";import A,{defaultSchema as F}from"rehype-sanitize";import L from"rehype-stringify";var D={id:"html",title:"HTML",extensions:["html","htm"],mediaTypes:["text/html"],input:[{name:"rehype-parse",plugin:j,stage:0},{name:"rehype-remark",plugin:P,options:[{handlers:{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}}}],stage:0}],output:[{plugin:q,stage:300,order:10},{plugin:A,options:[{...F,tagNames:[...F.tagNames||[],"mark","sub","sup"],attributes:{...F.attributes,"*":[...F.attributes?.["*"]||[],"className","id","style"],td:[...F.attributes?.td||[],"rowSpan","colSpan","rowspan","colspan"],th:[...F.attributes?.th||[],"rowSpan","colSpan","rowspan","colspan"],img:[...F.attributes?.img||[],"width","height"]}}],stage:300,order:20},{plugin:L,stage:400}]};function E(){this.Compiler=t=>t}function z(){this.Parser=t=>JSON.parse(t)}var $={id:"ast",title:"MDAST",input:[{plugin:z,stage:0},g,v,k,S,m],output:[{plugin:E,options:[],stage:400}]};function O(t){return"object"==typeof t&&null!==t&&"string"==typeof t.type}var C=class t{constructor(t){this.queue=[],this._data={},this.input=t}static register(t){this.registry.set(t.id,t)}static getFormat(t){return this.registry.get(t)}data(t,e){return"string"==typeof t?this._data[t]=e:Object.assign(this._data,t),this}getFormat(t){return this.constructor.getFormat(t)}resolveFormat(t){if("string"==typeof t){const e=this.getFormat(t);if(!e)throw new Error(`[MdastPlus] Format '${t}' is not registered.`);return e}return t}toRuntimeEntry(t,r,i){let n=r;void 0!==t.stage&&(n="string"==typeof t.stage?e[t.stage]??r:t.stage);let o=t.options||[];const s=t.name||t.plugin.name;if(i&&s&&s in i){const e=i[s];"object"!=typeof e||null===e||Array.isArray(e)?o=Array.isArray(e)?e:[e]:("main"in e&&(t.main=!!e.main),"before"in e&&(t.before=e.before),"after"in e&&(t.after=e.after),o=[e])}return{name:s,plugin:t.plugin,options:o,stage:n,order:t.order||0,main:t.main,before:t.before,after:t.after}}ensureInputPlugins(e,i,n=400){const o=e.some(t=>0===(t.stage??r)),s=O(this.input);if(!o){let o=[];if(s){const e=t.getFormat("ast");e&&e.input&&(o=e.input)}else{const e=t.getFormat("markdown");e&&e.input&&(o=e.input)}for(const t of o){const o=this.toRuntimeEntry(t,0,i);(o.stage??r)<=n&&e.push(o)}}}from(t,e){const r=this.resolveFormat(t);if(!r.input||0===r.input.length)throw new Error(`[MdastPlus] Format '${r.id}' does not support input.`);for(const t of r.input)this.queue.push(this.toRuntimeEntry(t,0,e));return this}resolveRunQueue(t,e,i,n){let o=[];if(o=e?this.queue.map(t=>this.toRuntimeEntry(t,t.stage??r,e)):[...this.queue],void 0!==i){const t=i;o=o.filter(e=>(e.stage??r)<=t);const s=o.findIndex(e=>(e.stage??r)===t),a=-1!==s?s+(n??0):o.length-1,l=o.slice(0,a+1),u=o.filter(t=>t.main&&!l.includes(t));o=l.concat(u),this.ensureInputPlugins(o,e,t),o.push({plugin:E,options:[],stage:400,order:0})}else if(this.ensureInputPlugins(o,e,400),t.output)for(const r of t.output)o.push(this.toRuntimeEntry(r,300,e));return o}async to(t,r){const i=this.resolveFormat(t);if(!i.output)throw new Error(`[MdastPlus] Format '${i.id}' does not support output.`);let o,s,a;if(r){const t=r;"overrides"in t||"stage"in t||"stopAtIndex"in t?(o=t.overrides,s="string"==typeof t.stage?e[t.stage]:t.stage,a=t.stopAtIndex):o=r}const l=this.resolveRunQueue(i,o,s,a),u=this.assembleProcessor(l);if(O(this.input)){const t=await u.run(this.input),e=u.stringify(t),r=new n;return"string"==typeof e||Buffer.isBuffer(e)?r.value=e:r.result=e,r}return u.process(this.input)}use(t,...e){return this.useAt("compile",t,...e)}normalizePluggable(t,e=[]){const r=[];if(Array.isArray(t)){let i=!1;if(t.length>0&&"function"==typeof t[0]){t.slice(1).some(t=>!function(t){if("function"==typeof t)return!0;if(Array.isArray(t))return!0;if("object"==typeof t&&null!==t){if("plugin"in t&&"function"==typeof t.plugin)return!0;if("plugins"in t)return!0}return!1}(t))&&(i=!0)}if(i){const[e,...i]=t;r.push({plugin:e,options:i})}else for(const i of t)r.push(...this.normalizePluggable(i,e))}else if("function"==typeof t)r.push({plugin:t,options:e});else if("object"==typeof t&&null!==t)if("plugin"in t&&"function"==typeof t.plugin){const i=t,n=e.length>0?e:i.options||[];r.push({...i,options:n})}else if("plugins"in t){const e=t;e.plugins&&r.push(...this.normalizePluggable(e.plugins))}return r}useAt(t,i,...n){let o,s,a;"string"==typeof t||"number"==typeof t?(o=("string"==typeof t?e[t]:t)??r,s=i,a=n):(o=void 0,s=t,a=[i,...n].filter(t=>void 0!==t));const l=this.normalizePluggable(s,a);for(const t of l){const e=o??r;this.queue.push(this.toRuntimeEntry(t,e))}return this}priority(t){const e=this.queue[this.queue.length-1];return e&&(e.order=t),this}configure(t,...e){for(let r=this.queue.length-1;r>=0;r--){const i=this.queue[r];if((i.name||i.plugin.name)===t){i.options=e;break}}return this}assembleProcessor(t){const e={};for(const i of t){const t=i.stage??r;e[t]||(e[t]=[]),e[t].push(i)}const n=[],o=Object.keys(e).map(Number).sort((t,e)=>t-e);for(const t of o){const r=e[t].sort((t,e)=>(t.order||0)-(e.order||0)),i=r.findIndex(t=>t.main);if(-1!==i){const t=r[i];!1===t.options?.[0]?console.warn(`Main Plugin "${t.name}" is disabled. Skipping.`):0!==i&&(r.splice(i,1),r[0]=t)}let o=!0,s=0;for(;o&&s<r.length;){o=!1,s++;for(let t=0;t<r.length;t++){const e=r[t];if(e.after){const i=r.findIndex(t=>t.name===e.after);if(-1!==i&&i>t){r.splice(t,1),r.splice(i,0,e),o=!0;break}}if(e.before){const i=r.findIndex(t=>t.name===e.before);if(-1!==i&&i<t){r.splice(t,1),r.splice(i,0,e),o=!0;break}}}}n.push(...r)}const s=i();Object.keys(this._data).length>0&&s.data(this._data);for(const t of n)s.use(t.plugin,...t.options||[]);return s}};C.registry=new Map;var H=C,I=class extends H{async toMarkdown(t){const e=await this.to("markdown"),r=String(e);if(t?.attachMetadata&&e.data?.readability){const{length:t,...i}=e.data.readability,n=new String(r);return Object.assign(n,i),n}return r}toMarkdownVFile(){return this.to("markdown")}async toHtml(){const t=await this.to("html");return String(t)}toHtmlVFile(){return this.to("html")}async toAst(t){return(await this.to("ast",t)).result}toHTML(){return this.toHtml()}toAST(t){return this.toAst(t)}};function R(t){return new I(t)}I.register(T),I.register(D),I.register($);import{visit as B}from"unist-util-visit";import{fromHtml as V}from"hast-util-from-html";import{fromDom as U}from"hast-util-from-dom";import{stringify as G}from"yaml";import{stringify as J}from"smol-toml";import{omitBy as Q,pick as K}from"lodash-es";var W=function(e){const{readability:r,jsdom:i,hast:n,url:o,fields:s}=e||{};this.parser=function(a,l){if(!1===r)return V(a,{fragment:!0,...n});let u,p;try{u=t("jsdom").JSDOM;p=t("@mozilla/readability").Readability}catch(t){throw new Error("[html-readability] Dependency missing. Please install 'jsdom' and '@mozilla/readability'.")}const f=new p(new u(a,{url:o,pretendToBeVisual:!0,...i,includeNodeLocations:!0}).window.document,{maxElemsToParse:1e5,nbTopCandidates:5,charThreshold:500,keepClasses:!0,...r,serializer:t=>t}).parse();if(!f||!f.content)return V(a,{fragment:!0,...n});const c=f.content;let m=U(c,{afterTransform:n?.afterTransform});const h=!1!==n?.fragment,{smartExcerpt:d=!0,sourceLink:g}=e||{};let y=Q(f,t=>null==t||""===t);const v=o||y.url,w=y.title;if(d&&y.excerpt&&y.textContent){const{threshold:t=.6,minContentLength:e=300}=!0===d?{}:d,r=y.excerpt.trim().toLowerCase().replace(/\s+/g," "),i=y.textContent.trim().toLowerCase().replace(/\s+/g," ");if(i.includes(r)){(r.length/i.length>t||i.length<e)&&delete y.excerpt}}if(o&&(y.url=o),delete y.content,delete y.textContent,s)if(Array.isArray(s))y=K(y,s);else{const t={};for(const[e,r]of Object.entries(s))void 0!==y[e]&&(t[r]=y[e]);y=t}if(e?.extraMetadata&&(y={...y,...e.extraMetadata}),l&&(l.data=l.data||{},l.data.readability=y),m){const t=[m];g&&v&&!et(m,v)&&t.push({type:"element",tagName:"blockquote",properties:{},children:[{type:"element",tagName:"p",properties:{},children:[{type:"text",value:"Source: "},{type:"element",tagName:"a",properties:{href:v},children:[{type:"text",value:w||v}]}]}]}),m=h?{type:"root",children:t}:{type:"root",children:[{type:"element",tagName:"html",properties:{},children:[{type:"element",tagName:"head",properties:{},children:[]},{type:"element",tagName:"body",properties:{},children:t}]}]},m.data=m.data||{},m.data.readability=y}return m}},X={name:"readability",plugin:W,stage:0,main:!0},Y={name:"restore-readability-meta",plugin:t=>(e,r)=>{const{frontmatter:i,sourceLink:n,extraMetadata:o}=t||{};if(r.data?.readability||o){if(r.data=r.data||{},r.data.readability={...r.data.readability,...o},e.data=e.data||{},e.data.readability=r.data.readability,i){const t="toml"===i?"toml":"yaml",n=("toml"===t?J(r.data.readability).trim():G(r.data.readability)).trim();e.children.unshift({type:t,value:n})}if(n&&r.data.readability.url){const{url:t,title:i}=r.data.readability;tt(e,t)||e.children.push({type:"blockquote",children:[{type:"paragraph",children:[{type:"text",value:"Source: "},{type:"link",url:t,children:[{type:"text",value:i||t}]}]}]})}}},stage:0,after:"rehype-remark"},Z=[X,Y];function _(t,e){if(!t||!e)return!1;if(t===e)return!0;try{const r=new URL(t),i=new URL(e);return r.href===i.href}catch{return t.replace(/\/$/,"")===e.replace(/\/$/,"")}}function tt(t,e){if(!e)return!1;let r=!1;return B(t,"link",t=>{if(_(t.url,e))return r=!0,!1}),r}function et(t,e){if(!e)return!1;let r=!1;return B(t,"element",t=>{if("a"===t.tagName&&t.properties&&_(t.properties.href,e))return r=!0,!1}),r}export{r as DefaultPipelineStage,H as MdastBasePipeline,I as MdastPipeline,e as PipelineStage,E as astCompiler,$ as astFormat,et as checkHtmlUrlExists,tt as checkUrlExists,D as htmlFormat,W as htmlReadability,X as htmlReadabilityPlugin,Z as htmlReadabilityPlugins,z as jsonParser,T as markdownFormat,R as mdast,Y as restoreReadabilityMetaPlugin};
|
|
1
|
+
var t=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,e)=>("undefined"!=typeof require?require:t)[e]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),e=(t=>(t[t.parse=0]="parse",t[t.normalize=100]="normalize",t[t.compile=200]="compile",t[t.finalize=300]="finalize",t[t.stringify=400]="stringify",t))(e||{}),r=200;import{unified as i}from"unified";import{VFile as n}from"vfile";import o from"remark-parse";import s from"remark-stringify";import a from"remark-gfm";import l from"remark-directive";import u from"remark-math";import p from"remark-frontmatter";import{visit as f}from"unist-util-visit";function c(t,e){return{type:t,children:e,data:{hName:t}}}var m={plugin:()=>t=>{!function(t){f(t,"text",(t,e,r)=>{if(!r||void 0===e)return;const i=t.value;let n=0;const o=[];let s=!1;const a=/(==[^=]+==|~[^~]+~|\^[^^]+\^)/g;let l;for(;null!==(l=a.exec(i));){s=!0;const t=l[0],e=l.index;e>n&&o.push({type:"text",value:i.slice(n,e)});let r="mark",u="";t.startsWith("==")?(r="mark",u=t.slice(2,-2)):t.startsWith("~")?(r="sub",u=t.slice(1,-1)):t.startsWith("^")&&(r="sup",u=t.slice(1,-1)),o.push(c(r,[{type:"text",value:u}])),n=a.lastIndex}return s?(n<i.length&&o.push({type:"text",value:i.slice(n)}),r.children.splice(e,1,...o),e+o.length):void 0})}(t)},stage:100};import{visit as h}from"unist-util-visit";var d={error:"danger",warn:"warning",success:"tip",important:"important",caution:"caution",note:"note"},g={plugin:()=>async t=>{h(t,["containerDirective","leafDirective","textDirective"],t=>{const e=t,r=e.name.toLowerCase();if(e.name=d[r]||r,e.children&&e.children.length>0){const t=e.children[0];if(t.data?.directiveLabel||"directiveLabel"===t.type){let r="";h(t,"text",t=>{r+=t.value}),r&&!e.attributes?.title&&(e.attributes=e.attributes||{},e.attributes.title=r.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(" ")}})},stage:100,order:10};import{visit as y}from"unist-util-visit";var v={plugin:()=>async t=>{y(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)}})},stage:100,order:20};import{visit as b}from"unist-util-visit";import{parse as w}from"shell-quote";var k={plugin:()=>async t=>{b(t,"code",t=>{if(t.meta){const e=function(t){const e={},r=w(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}}})},stage:100,order:30};import{visit as x}from"unist-util-visit";var S={plugin:()=>async t=>{x(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],o=n[2]||n[4];e&&!r.width&&(r.width=parseInt(e,10)),o&&!r.height&&(r.height=parseInt(o,10)),t.url=t.url.replace(i,"")}e.width&&!r.width&&(r.width=e.width),e.height&&!r.height&&(r.height=e.height)})},stage:100,order:40},j=[{plugin:o,stage:0},{plugin:a,options:[{singleTilde:!1}],stage:0},{plugin:l,stage:0},{plugin:u,stage:0},{plugin:p,options:[["yaml","toml"]],stage:0},g,v,k,S,m],M=[{plugin:s,options:[{handlers:{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:"^"})+"^"}}],stage:400},{plugin:a,options:[{singleTilde:!1}],stage:400},{plugin:l,stage:400},{plugin:u,stage:400},{plugin:p,options:[["yaml","toml"]],stage:400}];M.forEach(t=>{t.plugin===s?t.order=100:t.order=10});var N={id:"markdown",title:"Markdown (GFM + Directives)",extensions:["md","markdown","mdown","mkdn"],mediaTypes:["text/markdown"],input:j,output:M};import T from"rehype-parse";import P from"rehype-remark";import q from"remark-rehype";import A,{defaultSchema as F}from"rehype-sanitize";import L from"rehype-stringify";var D={id:"html",title:"HTML",extensions:["html","htm"],mediaTypes:["text/html"],input:[{name:"rehype-parse",plugin:T,stage:0},{name:"rehype-remark",plugin:P,options:[{handlers:{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}}}],stage:0}],output:[{plugin:q,stage:300,order:10},{plugin:A,options:[{...F,tagNames:[...F.tagNames||[],"mark","sub","sup"],attributes:{...F.attributes,"*":[...F.attributes?.["*"]||[],"className","id","style"],td:[...F.attributes?.td||[],"rowSpan","colSpan","rowspan","colspan"],th:[...F.attributes?.th||[],"rowSpan","colSpan","rowspan","colspan"],img:[...F.attributes?.img||[],"width","height"]}}],stage:300,order:20},{plugin:L,stage:400}]};function E(){this.Compiler=t=>t}function z(){this.Parser=t=>JSON.parse(t)}var O={id:"ast",title:"MDAST",input:[{plugin:z,stage:0},g,v,k,S,m],output:[{plugin:E,options:[],stage:400}]};function $(t){return"object"==typeof t&&null!==t&&"string"==typeof t.type}var C=class t{constructor(t){this.queue=[],this._data={},this.input=t}static register(t){this.registry.set(t.id,t)}static getFormat(t){return this.registry.get(t)}data(t,e){return"string"==typeof t?this._data[t]=e:Object.assign(this._data,t),this}getFormat(t){return this.constructor.getFormat(t)}resolveFormat(t){if("string"==typeof t){const e=this.getFormat(t);if(!e)throw new Error(`[MdastPlus] Format '${t}' is not registered.`);return e}return t}toRuntimeEntry(t,r,i){let n=r;void 0!==t.stage&&(n="string"==typeof t.stage?e[t.stage]??r:t.stage);let o=t.options||[];const s=t.name||t.plugin.name;if(i&&s&&s in i){const e=i[s];"object"!=typeof e||null===e||Array.isArray(e)?o=Array.isArray(e)?e:[e]:("main"in e&&(t.main=!!e.main),"before"in e&&(t.before=e.before),"after"in e&&(t.after=e.after),o=[e])}return{name:s,plugin:t.plugin,options:o,stage:n,order:t.order||0,main:t.main,before:t.before,after:t.after}}ensureInputPlugins(e,i,n=400){const o=e.some(t=>0===(t.stage??r)),s=$(this.input);if(!o){let o=[];if(s){const e=t.getFormat("ast");e&&e.input&&(o=e.input)}else{const e=t.getFormat("markdown");e&&e.input&&(o=e.input)}for(const t of o){const o=this.toRuntimeEntry(t,0,i);(o.stage??r)<=n&&e.push(o)}}}from(t,e){const r=this.resolveFormat(t);if(!r.input||0===r.input.length)throw new Error(`[MdastPlus] Format '${r.id}' does not support input.`);for(const t of r.input)this.queue.push(this.toRuntimeEntry(t,0,e));return this}resolveRunQueue(t,e,i,n){let o=[];if(o=e?this.queue.map(t=>this.toRuntimeEntry(t,t.stage??r,e)):[...this.queue],void 0!==i){const t=i;o=o.filter(e=>(e.stage??r)<=t);const s=o.findIndex(e=>(e.stage??r)===t),a=-1!==s?s+(n??0):o.length-1,l=o.slice(0,a+1),u=o.filter(t=>t.main&&!l.includes(t));o=l.concat(u),this.ensureInputPlugins(o,e,t),o.push({plugin:E,options:[],stage:400,order:0})}else if(this.ensureInputPlugins(o,e,400),t.output)for(const r of t.output)o.push(this.toRuntimeEntry(r,300,e));return o}async to(t,r){const i=this.resolveFormat(t);if(!i.output)throw new Error(`[MdastPlus] Format '${i.id}' does not support output.`);let o,s,a;if(r){const t=r;"overrides"in t||"stage"in t||"stopAtIndex"in t?(o=t.overrides,s="string"==typeof t.stage?e[t.stage]:t.stage,a=t.stopAtIndex):o=r}const l=this.resolveRunQueue(i,o,s,a),u=this.assembleProcessor(l);if($(this.input)){const t=await u.run(this.input),e=u.stringify(t),r=new n;return"string"==typeof e||Buffer.isBuffer(e)?r.value=e:r.result=e,r}return u.process(this.input)}use(t,...e){return this.useAt("compile",t,...e)}normalizePluggable(t,e=[]){const r=[];if(Array.isArray(t)){let i=!1;if(t.length>0&&"function"==typeof t[0]){t.slice(1).some(t=>!function(t){if("function"==typeof t)return!0;if(Array.isArray(t))return!0;if("object"==typeof t&&null!==t){if("plugin"in t&&"function"==typeof t.plugin)return!0;if("plugins"in t)return!0}return!1}(t))&&(i=!0)}if(i){const[e,...i]=t;r.push({plugin:e,options:i})}else for(const i of t)r.push(...this.normalizePluggable(i,e))}else if("function"==typeof t)r.push({plugin:t,options:e});else if("object"==typeof t&&null!==t)if("plugin"in t&&"function"==typeof t.plugin){const i=t,n=e.length>0?e:i.options||[];r.push({...i,options:n})}else if("plugins"in t){const e=t;e.plugins&&r.push(...this.normalizePluggable(e.plugins))}return r}useAt(t,i,...n){let o,s,a;"string"==typeof t||"number"==typeof t?(o=("string"==typeof t?e[t]:t)??r,s=i,a=n):(o=void 0,s=t,a=[i,...n].filter(t=>void 0!==t));const l=this.normalizePluggable(s,a);for(const t of l){const e=o??r;this.queue.push(this.toRuntimeEntry(t,e))}return this}priority(t){const e=this.queue[this.queue.length-1];return e&&(e.order=t),this}configure(t,...e){for(let r=this.queue.length-1;r>=0;r--){const i=this.queue[r];if((i.name||i.plugin.name)===t){i.options=e;break}}return this}assembleProcessor(t){const e={};for(const i of t){const t=i.stage??r;e[t]||(e[t]=[]),e[t].push(i)}const n=[],o=Object.keys(e).map(Number).sort((t,e)=>t-e);for(const t of o){const r=e[t].sort((t,e)=>(t.order||0)-(e.order||0)),i=r.findIndex(t=>t.main);if(-1!==i){const t=r[i];!1===t.options?.[0]?console.warn(`Main Plugin "${t.name}" is disabled. Skipping.`):0!==i&&(r.splice(i,1),r[0]=t)}let o=!0,s=0;for(;o&&s<r.length;){o=!1,s++;for(let t=0;t<r.length;t++){const e=r[t];if(e.after){const i=r.findIndex(t=>t.name===e.after);if(-1!==i&&i>t){r.splice(t,1),r.splice(i,0,e),o=!0;break}}if(e.before){const i=r.findIndex(t=>t.name===e.before);if(-1!==i&&i<t){r.splice(t,1),r.splice(i,0,e),o=!0;break}}}}n.push(...r)}const s=i();Object.keys(this._data).length>0&&s.data(this._data);for(const t of n)s.use(t.plugin,...t.options||[]);return s}};C.registry=new Map;var H=C,I=class extends H{async toMarkdown(t){const e=await this.to("markdown"),r=String(e);if(t?.attachMetadata&&e.data?.readability){const{length:t,...i}=e.data.readability,n=new String(r);return Object.assign(n,i),n}return r}toMarkdownVFile(){return this.to("markdown")}async toHtml(){const t=await this.to("html");return String(t)}toHtmlVFile(){return this.to("html")}async toAst(t){return(await this.to("ast",t)).result}toHTML(){return this.toHtml()}toAST(t){return this.toAst(t)}};function R(t){return new I(t)}I.register(N),I.register(D),I.register(O);import{visit as B}from"unist-util-visit";import{fromHtml as V}from"hast-util-from-html";import{fromDom as U}from"hast-util-from-dom";import{stringify as G}from"yaml";import{stringify as J}from"smol-toml";import{omitBy as Q,pick as K}from"lodash-es";var W=function(e){const{readability:r,jsdom:i,hast:n,url:o,fields:s}=e||{};this.parser=function(a,l){if(!1===r)return V(a,{fragment:!0,...n});let u,p;try{u=t("jsdom").JSDOM;p=t("@mozilla/readability").Readability}catch(t){throw new Error("[html-readability] Dependency missing. Please install 'jsdom' and '@mozilla/readability'.")}const f=new p(new u(a,{url:o,pretendToBeVisual:!0,...i,includeNodeLocations:!0}).window.document,{maxElemsToParse:1e5,nbTopCandidates:5,charThreshold:500,keepClasses:!0,...r,serializer:t=>t}).parse();if(!f||!f.content)return V(a,{fragment:!0,...n});const c=f.content;let m=U(c,{afterTransform:n?.afterTransform});const h=!1!==n?.fragment,{smartExcerpt:d=!0,sourceLink:g}=e||{};let y=Q(f,t=>null==t||""===t);const v=o||y.url,b=y.title;if(d&&y.excerpt&&y.textContent){const{threshold:t=.6,minContentLength:e=300}=!0===d?{}:d,r=y.excerpt.trim().toLowerCase().replace(/\s+/g," "),i=y.textContent.trim().toLowerCase().replace(/\s+/g," ");if(i.includes(r)){(r.length/i.length>t||i.length<e)&&delete y.excerpt}}if(o&&(y.url=o),delete y.content,delete y.textContent,s)if(Array.isArray(s))y=K(y,s);else{const t={};for(const[e,r]of Object.entries(s))void 0!==y[e]&&(t[r]=y[e]);y=t}if(e?.extraMetadata&&(y={...y,...e.extraMetadata}),l&&(l.data=l.data||{},l.data.readability=y),m){const t=[m];g&&v&&!et(m,v)&&t.push({type:"element",tagName:"blockquote",properties:{},children:[{type:"element",tagName:"p",properties:{},children:[{type:"text",value:"Source: "},{type:"element",tagName:"a",properties:{href:v},children:[{type:"text",value:b||v}]}]}]}),m=h?{type:"root",children:t}:{type:"root",children:[{type:"element",tagName:"html",properties:{},children:[{type:"element",tagName:"head",properties:{},children:[]},{type:"element",tagName:"body",properties:{},children:t}]}]},m.data=m.data||{},m.data.readability=y}return m}},X={name:"readability",plugin:W,stage:0,main:!0},Y={name:"restore-readability-meta",plugin:t=>(e,r)=>{const{frontmatter:i,sourceLink:n,extraMetadata:o}=t||{};if(r.data?.readability||o){if(r.data=r.data||{},r.data.readability={...r.data.readability,...o},e.data=e.data||{},e.data.readability=r.data.readability,i&&Object.keys(r.data.readability).length>0){const t="toml"===i?"toml":"yaml",n=("toml"===t?J(r.data.readability).trim():G(r.data.readability)).trim();n&&e.children.unshift({type:t,value:n})}if(n&&r.data.readability.url){const{url:t,title:i}=r.data.readability;tt(e,t)||e.children.push({type:"blockquote",children:[{type:"paragraph",children:[{type:"text",value:"Source: "},{type:"link",url:t,children:[{type:"text",value:i||t}]}]}]})}}},stage:0,after:"rehype-remark"},Z=[X,Y];function _(t,e){if(!t||!e)return!1;if(t===e)return!0;try{const r=new URL(t),i=new URL(e);return r.href===i.href}catch{return t.replace(/\/$/,"")===e.replace(/\/$/,"")}}function tt(t,e){if(!e)return!1;let r=!1;return B(t,"link",t=>{if(_(t.url,e))return r=!0,!1}),r}function et(t,e){if(!e)return!1;let r=!1;return B(t,"element",t=>{if("a"===t.tagName&&t.properties&&_(t.properties.href,e))return r=!0,!1}),r}export{r as DefaultPipelineStage,H as MdastBasePipeline,I as MdastPipeline,e as PipelineStage,E as astCompiler,O as astFormat,et as checkHtmlUrlExists,tt as checkUrlExists,D as htmlFormat,W as htmlReadability,X as htmlReadabilityPlugin,Z as htmlReadabilityPlugins,z as jsonParser,N as markdownFormat,R as mdast,Y as restoreReadabilityMetaPlugin};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: MdastBasePipeline
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:42](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:42](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L42)
|
|
10
10
|
|
|
11
11
|
Base implementation of the fluent mdast processing pipeline.
|
|
12
12
|
Manages the plugin registry and the execution queue.
|
|
@@ -21,7 +21,7 @@ Manages the plugin registry and the execution queue.
|
|
|
21
21
|
|
|
22
22
|
> **new MdastBasePipeline**(`input`): `MdastBasePipeline`
|
|
23
23
|
|
|
24
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:70](https://github.com/isdk/mdast-plus.js/blob/
|
|
24
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:70](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L70)
|
|
25
25
|
|
|
26
26
|
Initializes a new pipeline instance with the given input.
|
|
27
27
|
|
|
@@ -43,7 +43,7 @@ Content to process (string, Buffer, VFile, or AST Node).
|
|
|
43
43
|
|
|
44
44
|
> `protected` **\_data**: `Record`\<`string`, `any`\> = `{}`
|
|
45
45
|
|
|
46
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:64](https://github.com/isdk/mdast-plus.js/blob/
|
|
46
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:64](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L64)
|
|
47
47
|
|
|
48
48
|
***
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ Defined in: [packages/mdast-plus/src/pipeline.ts:64](https://github.com/isdk/mda
|
|
|
51
51
|
|
|
52
52
|
> `protected` **input**: `Compatible`
|
|
53
53
|
|
|
54
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:62](https://github.com/isdk/mdast-plus.js/blob/
|
|
54
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:62](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L62)
|
|
55
55
|
|
|
56
56
|
***
|
|
57
57
|
|
|
@@ -59,7 +59,7 @@ Defined in: [packages/mdast-plus/src/pipeline.ts:62](https://github.com/isdk/mda
|
|
|
59
59
|
|
|
60
60
|
> `protected` **queue**: [`MdastPlugin`](../interfaces/MdastPlugin.md)[] = `[]`
|
|
61
61
|
|
|
62
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:63](https://github.com/isdk/mdast-plus.js/blob/
|
|
62
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:63](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L63)
|
|
63
63
|
|
|
64
64
|
## Methods
|
|
65
65
|
|
|
@@ -67,7 +67,7 @@ Defined in: [packages/mdast-plus/src/pipeline.ts:63](https://github.com/isdk/mda
|
|
|
67
67
|
|
|
68
68
|
> `protected` **assembleProcessor**(`queue`): `Processor`
|
|
69
69
|
|
|
70
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:494](https://github.com/isdk/mdast-plus.js/blob/
|
|
70
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:494](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L494)
|
|
71
71
|
|
|
72
72
|
Assembles a unified processor based on the sorted plugin queue.
|
|
73
73
|
|
|
@@ -87,7 +87,7 @@ Assembles a unified processor based on the sorted plugin queue.
|
|
|
87
87
|
|
|
88
88
|
> **configure**(`pluginName`, ...`options`): `this`
|
|
89
89
|
|
|
90
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:478](https://github.com/isdk/mdast-plus.js/blob/
|
|
90
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:478](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L478)
|
|
91
91
|
|
|
92
92
|
Modifies the options of a plugin that is already in the pipeline queue.
|
|
93
93
|
Searches from the end of the queue and updates the first match found.
|
|
@@ -119,7 +119,7 @@ The pipeline instance for chaining.
|
|
|
119
119
|
|
|
120
120
|
> **data**(`key`, `value?`): `this`
|
|
121
121
|
|
|
122
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:80](https://github.com/isdk/mdast-plus.js/blob/
|
|
122
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:80](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L80)
|
|
123
123
|
|
|
124
124
|
Configures global data for the pipeline, which will be available to all plugins via this.data().
|
|
125
125
|
|
|
@@ -149,7 +149,7 @@ The pipeline instance for chaining.
|
|
|
149
149
|
|
|
150
150
|
> `protected` **ensureInputPlugins**(`queue`, `overrides?`, `maxStage?`): `void`
|
|
151
151
|
|
|
152
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:165](https://github.com/isdk/mdast-plus.js/blob/
|
|
152
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:165](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L165)
|
|
153
153
|
|
|
154
154
|
Ensures that input plugins (parser, normalizers) are present in the queue.
|
|
155
155
|
Adds implicit plugins if no parser is detected.
|
|
@@ -178,7 +178,7 @@ Adds implicit plugins if no parser is detected.
|
|
|
178
178
|
|
|
179
179
|
> **from**(`fmt`, `overrides?`): `this`
|
|
180
180
|
|
|
181
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:194](https://github.com/isdk/mdast-plus.js/blob/
|
|
181
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:194](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L194)
|
|
182
182
|
|
|
183
183
|
Configures the input format and adds its associated plugins to the pipeline.
|
|
184
184
|
|
|
@@ -208,7 +208,7 @@ The pipeline instance for chaining.
|
|
|
208
208
|
|
|
209
209
|
> **getFormat**(`id`): `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
|
|
210
210
|
|
|
211
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:92](https://github.com/isdk/mdast-plus.js/blob/
|
|
211
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:92](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L92)
|
|
212
212
|
|
|
213
213
|
Instance-level access to the global format registry.
|
|
214
214
|
|
|
@@ -228,7 +228,7 @@ Instance-level access to the global format registry.
|
|
|
228
228
|
|
|
229
229
|
> **priority**(`order`): `this`
|
|
230
230
|
|
|
231
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:461](https://github.com/isdk/mdast-plus.js/blob/
|
|
231
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:461](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L461)
|
|
232
232
|
|
|
233
233
|
Sets the priority order for the most recently added plugin.
|
|
234
234
|
Plugins with lower order run earlier within the same stage.
|
|
@@ -253,7 +253,7 @@ The pipeline instance for chaining.
|
|
|
253
253
|
|
|
254
254
|
> `protected` **resolveRunQueue**(`format`, `overrides?`, `stage?`, `stopAtIndex?`): [`MdastPlugin`](../interfaces/MdastPlugin.md)[]
|
|
255
255
|
|
|
256
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:214](https://github.com/isdk/mdast-plus.js/blob/
|
|
256
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:214](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L214)
|
|
257
257
|
|
|
258
258
|
Resolves the final plugin queue for execution based on the target format and run options.
|
|
259
259
|
Calculates the effective plugin list by applying overrides, handling partial execution (stage/stopAtIndex),
|
|
@@ -287,7 +287,7 @@ and injecting necessary input/output plugins.
|
|
|
287
287
|
|
|
288
288
|
> **to**(`fmt`, `optionsOrOverrides?`): `Promise`\<`VFile`\>
|
|
289
289
|
|
|
290
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:290](https://github.com/isdk/mdast-plus.js/blob/
|
|
290
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:290](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L290)
|
|
291
291
|
|
|
292
292
|
Processes the pipeline and serializes the result into the specified format.
|
|
293
293
|
|
|
@@ -317,7 +317,7 @@ A promise resolving to a VFile containing the result.
|
|
|
317
317
|
|
|
318
318
|
> `protected` **toRuntimeEntry**(`entry`, `defaultStage`, `overrides?`): [`MdastPlugin`](../interfaces/MdastPlugin.md) & `object`
|
|
319
319
|
|
|
320
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:116](https://github.com/isdk/mdast-plus.js/blob/
|
|
320
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:116](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L116)
|
|
321
321
|
|
|
322
322
|
Normalizes a plugin entry for runtime execution.
|
|
323
323
|
|
|
@@ -345,7 +345,7 @@ Normalizes a plugin entry for runtime execution.
|
|
|
345
345
|
|
|
346
346
|
> **use**(`plugin`, ...`options`): `this`
|
|
347
347
|
|
|
348
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:336](https://github.com/isdk/mdast-plus.js/blob/
|
|
348
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:336](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L336)
|
|
349
349
|
|
|
350
350
|
Adds a plugin or an array of plugins to the pipeline's compile stage.
|
|
351
351
|
|
|
@@ -377,7 +377,7 @@ The pipeline instance for chaining.
|
|
|
377
377
|
|
|
378
378
|
> **useAt**(`stage`, `plugin`, ...`options`): `this`
|
|
379
379
|
|
|
380
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:418](https://github.com/isdk/mdast-plus.js/blob/
|
|
380
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:418](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L418)
|
|
381
381
|
|
|
382
382
|
Adds a plugin or an array of plugins to the pipeline at a specific stage.
|
|
383
383
|
|
|
@@ -411,7 +411,7 @@ The pipeline instance for chaining.
|
|
|
411
411
|
|
|
412
412
|
> **useAt**(`plugin`, ...`options`): `this`
|
|
413
413
|
|
|
414
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:425](https://github.com/isdk/mdast-plus.js/blob/
|
|
414
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:425](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L425)
|
|
415
415
|
|
|
416
416
|
Adds a plugin or an array of plugins to the pipeline. The stage is taken from the plugin object(s) or defaults to 'compile'.
|
|
417
417
|
|
|
@@ -441,7 +441,7 @@ The pipeline instance for chaining.
|
|
|
441
441
|
|
|
442
442
|
> `static` **getFormat**(`id`): `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
|
|
443
443
|
|
|
444
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:58](https://github.com/isdk/mdast-plus.js/blob/
|
|
444
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:58](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L58)
|
|
445
445
|
|
|
446
446
|
Retrieves a registered format by its ID.
|
|
447
447
|
|
|
@@ -465,7 +465,7 @@ The format definition or undefined if not found.
|
|
|
465
465
|
|
|
466
466
|
> `static` **register**(`format`): `void`
|
|
467
467
|
|
|
468
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:49](https://github.com/isdk/mdast-plus.js/blob/
|
|
468
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:49](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L49)
|
|
469
469
|
|
|
470
470
|
Registers a global document format.
|
|
471
471
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: MdastPipeline
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:575](https://github.com/isdk/mdast-plus.js/blob/
|
|
9
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:575](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L575)
|
|
10
10
|
|
|
11
11
|
Extended pipeline with convenience methods for common formats.
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ Extended pipeline with convenience methods for common formats.
|
|
|
20
20
|
|
|
21
21
|
> **new MdastPipeline**(`input`): `MdastPipeline`
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:70](https://github.com/isdk/mdast-plus.js/blob/
|
|
23
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:70](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L70)
|
|
24
24
|
|
|
25
25
|
Initializes a new pipeline instance with the given input.
|
|
26
26
|
|
|
@@ -46,7 +46,7 @@ Content to process (string, Buffer, VFile, or AST Node).
|
|
|
46
46
|
|
|
47
47
|
> `protected` **\_data**: `Record`\<`string`, `any`\> = `{}`
|
|
48
48
|
|
|
49
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:64](https://github.com/isdk/mdast-plus.js/blob/
|
|
49
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:64](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L64)
|
|
50
50
|
|
|
51
51
|
#### Inherited from
|
|
52
52
|
|
|
@@ -58,7 +58,7 @@ Defined in: [packages/mdast-plus/src/pipeline.ts:64](https://github.com/isdk/mda
|
|
|
58
58
|
|
|
59
59
|
> `protected` **input**: `Compatible`
|
|
60
60
|
|
|
61
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:62](https://github.com/isdk/mdast-plus.js/blob/
|
|
61
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:62](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L62)
|
|
62
62
|
|
|
63
63
|
#### Inherited from
|
|
64
64
|
|
|
@@ -70,7 +70,7 @@ Defined in: [packages/mdast-plus/src/pipeline.ts:62](https://github.com/isdk/mda
|
|
|
70
70
|
|
|
71
71
|
> `protected` **queue**: [`MdastPlugin`](../interfaces/MdastPlugin.md)[] = `[]`
|
|
72
72
|
|
|
73
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:63](https://github.com/isdk/mdast-plus.js/blob/
|
|
73
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:63](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L63)
|
|
74
74
|
|
|
75
75
|
#### Inherited from
|
|
76
76
|
|
|
@@ -82,7 +82,7 @@ Defined in: [packages/mdast-plus/src/pipeline.ts:63](https://github.com/isdk/mda
|
|
|
82
82
|
|
|
83
83
|
> `protected` **assembleProcessor**(`queue`): `Processor`
|
|
84
84
|
|
|
85
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:494](https://github.com/isdk/mdast-plus.js/blob/
|
|
85
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:494](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L494)
|
|
86
86
|
|
|
87
87
|
Assembles a unified processor based on the sorted plugin queue.
|
|
88
88
|
|
|
@@ -106,7 +106,7 @@ Assembles a unified processor based on the sorted plugin queue.
|
|
|
106
106
|
|
|
107
107
|
> **configure**(`pluginName`, ...`options`): `this`
|
|
108
108
|
|
|
109
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:478](https://github.com/isdk/mdast-plus.js/blob/
|
|
109
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:478](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L478)
|
|
110
110
|
|
|
111
111
|
Modifies the options of a plugin that is already in the pipeline queue.
|
|
112
112
|
Searches from the end of the queue and updates the first match found.
|
|
@@ -142,7 +142,7 @@ The pipeline instance for chaining.
|
|
|
142
142
|
|
|
143
143
|
> **data**(`key`, `value?`): `this`
|
|
144
144
|
|
|
145
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:80](https://github.com/isdk/mdast-plus.js/blob/
|
|
145
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:80](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L80)
|
|
146
146
|
|
|
147
147
|
Configures global data for the pipeline, which will be available to all plugins via this.data().
|
|
148
148
|
|
|
@@ -176,7 +176,7 @@ The pipeline instance for chaining.
|
|
|
176
176
|
|
|
177
177
|
> `protected` **ensureInputPlugins**(`queue`, `overrides?`, `maxStage?`): `void`
|
|
178
178
|
|
|
179
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:165](https://github.com/isdk/mdast-plus.js/blob/
|
|
179
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:165](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L165)
|
|
180
180
|
|
|
181
181
|
Ensures that input plugins (parser, normalizers) are present in the queue.
|
|
182
182
|
Adds implicit plugins if no parser is detected.
|
|
@@ -209,7 +209,7 @@ Adds implicit plugins if no parser is detected.
|
|
|
209
209
|
|
|
210
210
|
> **from**(`fmt`, `overrides?`): `this`
|
|
211
211
|
|
|
212
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:194](https://github.com/isdk/mdast-plus.js/blob/
|
|
212
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:194](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L194)
|
|
213
213
|
|
|
214
214
|
Configures the input format and adds its associated plugins to the pipeline.
|
|
215
215
|
|
|
@@ -243,7 +243,7 @@ The pipeline instance for chaining.
|
|
|
243
243
|
|
|
244
244
|
> **getFormat**(`id`): `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
|
|
245
245
|
|
|
246
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:92](https://github.com/isdk/mdast-plus.js/blob/
|
|
246
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:92](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L92)
|
|
247
247
|
|
|
248
248
|
Instance-level access to the global format registry.
|
|
249
249
|
|
|
@@ -267,7 +267,7 @@ Instance-level access to the global format registry.
|
|
|
267
267
|
|
|
268
268
|
> **priority**(`order`): `this`
|
|
269
269
|
|
|
270
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:461](https://github.com/isdk/mdast-plus.js/blob/
|
|
270
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:461](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L461)
|
|
271
271
|
|
|
272
272
|
Sets the priority order for the most recently added plugin.
|
|
273
273
|
Plugins with lower order run earlier within the same stage.
|
|
@@ -296,7 +296,7 @@ The pipeline instance for chaining.
|
|
|
296
296
|
|
|
297
297
|
> `protected` **resolveRunQueue**(`format`, `overrides?`, `stage?`, `stopAtIndex?`): [`MdastPlugin`](../interfaces/MdastPlugin.md)[]
|
|
298
298
|
|
|
299
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:214](https://github.com/isdk/mdast-plus.js/blob/
|
|
299
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:214](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L214)
|
|
300
300
|
|
|
301
301
|
Resolves the final plugin queue for execution based on the target format and run options.
|
|
302
302
|
Calculates the effective plugin list by applying overrides, handling partial execution (stage/stopAtIndex),
|
|
@@ -334,7 +334,7 @@ and injecting necessary input/output plugins.
|
|
|
334
334
|
|
|
335
335
|
> **to**(`fmt`, `optionsOrOverrides?`): `Promise`\<`VFile`\>
|
|
336
336
|
|
|
337
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:290](https://github.com/isdk/mdast-plus.js/blob/
|
|
337
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:290](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L290)
|
|
338
338
|
|
|
339
339
|
Processes the pipeline and serializes the result into the specified format.
|
|
340
340
|
|
|
@@ -368,7 +368,7 @@ A promise resolving to a VFile containing the result.
|
|
|
368
368
|
|
|
369
369
|
> **toAst**(`options?`): `Promise`\<`Root`\>
|
|
370
370
|
|
|
371
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:624](https://github.com/isdk/mdast-plus.js/blob/
|
|
371
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:624](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L624)
|
|
372
372
|
|
|
373
373
|
Finalizes the pipeline and returns the resulting AST (Root node).
|
|
374
374
|
|
|
@@ -390,7 +390,7 @@ Configuration for the extraction.
|
|
|
390
390
|
|
|
391
391
|
> **toAST**(`options?`): `Promise`\<`Root`\>
|
|
392
392
|
|
|
393
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:632](https://github.com/isdk/mdast-plus.js/blob/
|
|
393
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:632](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L632)
|
|
394
394
|
|
|
395
395
|
Alias for toAst()
|
|
396
396
|
|
|
@@ -420,7 +420,7 @@ Alias for toAst()
|
|
|
420
420
|
|
|
421
421
|
> **toHtml**(): `Promise`\<`string`\>
|
|
422
422
|
|
|
423
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:605](https://github.com/isdk/mdast-plus.js/blob/
|
|
423
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:605](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L605)
|
|
424
424
|
|
|
425
425
|
Finalizes the pipeline and returns the result as an HTML string.
|
|
426
426
|
|
|
@@ -434,7 +434,7 @@ Finalizes the pipeline and returns the result as an HTML string.
|
|
|
434
434
|
|
|
435
435
|
> **toHTML**(): `Promise`\<`string`\>
|
|
436
436
|
|
|
437
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:630](https://github.com/isdk/mdast-plus.js/blob/
|
|
437
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:630](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L630)
|
|
438
438
|
|
|
439
439
|
Alias for toHtml()
|
|
440
440
|
|
|
@@ -448,7 +448,7 @@ Alias for toHtml()
|
|
|
448
448
|
|
|
449
449
|
> **toHtmlVFile**(): `Promise`\<`VFile`\>
|
|
450
450
|
|
|
451
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:613](https://github.com/isdk/mdast-plus.js/blob/
|
|
451
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:613](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L613)
|
|
452
452
|
|
|
453
453
|
Finalizes the pipeline and returns a VFile containing the HTML result.
|
|
454
454
|
|
|
@@ -464,7 +464,7 @@ Finalizes the pipeline and returns a VFile containing the HTML result.
|
|
|
464
464
|
|
|
465
465
|
> **toMarkdown**(): `Promise`\<`string`\>
|
|
466
466
|
|
|
467
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:581](https://github.com/isdk/mdast-plus.js/blob/
|
|
467
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:581](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L581)
|
|
468
468
|
|
|
469
469
|
Finalizes the pipeline and returns the result as a Markdown string.
|
|
470
470
|
|
|
@@ -476,7 +476,7 @@ Finalizes the pipeline and returns the result as a Markdown string.
|
|
|
476
476
|
|
|
477
477
|
> **toMarkdown**(`options`): `Promise`\<`string` \| `String`\>
|
|
478
478
|
|
|
479
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:582](https://github.com/isdk/mdast-plus.js/blob/
|
|
479
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:582](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L582)
|
|
480
480
|
|
|
481
481
|
Finalizes the pipeline and returns the result as a Markdown string.
|
|
482
482
|
|
|
@@ -502,7 +502,7 @@ If true, returns a String object with metadata attached (if available).
|
|
|
502
502
|
|
|
503
503
|
> **toMarkdownVFile**(): `Promise`\<`VFile`\>
|
|
504
504
|
|
|
505
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:598](https://github.com/isdk/mdast-plus.js/blob/
|
|
505
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:598](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L598)
|
|
506
506
|
|
|
507
507
|
Finalizes the pipeline and returns a VFile containing the Markdown result.
|
|
508
508
|
|
|
@@ -516,7 +516,7 @@ Finalizes the pipeline and returns a VFile containing the Markdown result.
|
|
|
516
516
|
|
|
517
517
|
> `protected` **toRuntimeEntry**(`entry`, `defaultStage`, `overrides?`): [`MdastPlugin`](../interfaces/MdastPlugin.md) & `object`
|
|
518
518
|
|
|
519
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:116](https://github.com/isdk/mdast-plus.js/blob/
|
|
519
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:116](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L116)
|
|
520
520
|
|
|
521
521
|
Normalizes a plugin entry for runtime execution.
|
|
522
522
|
|
|
@@ -548,7 +548,7 @@ Normalizes a plugin entry for runtime execution.
|
|
|
548
548
|
|
|
549
549
|
> **use**(`plugin`, ...`options`): `this`
|
|
550
550
|
|
|
551
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:336](https://github.com/isdk/mdast-plus.js/blob/
|
|
551
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:336](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L336)
|
|
552
552
|
|
|
553
553
|
Adds a plugin or an array of plugins to the pipeline's compile stage.
|
|
554
554
|
|
|
@@ -584,7 +584,7 @@ The pipeline instance for chaining.
|
|
|
584
584
|
|
|
585
585
|
> **useAt**(`stage`, `plugin`, ...`options`): `this`
|
|
586
586
|
|
|
587
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:418](https://github.com/isdk/mdast-plus.js/blob/
|
|
587
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:418](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L418)
|
|
588
588
|
|
|
589
589
|
Adds a plugin or an array of plugins to the pipeline at a specific stage.
|
|
590
590
|
|
|
@@ -622,7 +622,7 @@ The pipeline instance for chaining.
|
|
|
622
622
|
|
|
623
623
|
> **useAt**(`plugin`, ...`options`): `this`
|
|
624
624
|
|
|
625
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:425](https://github.com/isdk/mdast-plus.js/blob/
|
|
625
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:425](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L425)
|
|
626
626
|
|
|
627
627
|
Adds a plugin or an array of plugins to the pipeline. The stage is taken from the plugin object(s) or defaults to 'compile'.
|
|
628
628
|
|
|
@@ -656,7 +656,7 @@ The pipeline instance for chaining.
|
|
|
656
656
|
|
|
657
657
|
> `static` **getFormat**(`id`): `undefined` \| [`MdastFormat`](../interfaces/MdastFormat.md)
|
|
658
658
|
|
|
659
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:58](https://github.com/isdk/mdast-plus.js/blob/
|
|
659
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:58](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L58)
|
|
660
660
|
|
|
661
661
|
Retrieves a registered format by its ID.
|
|
662
662
|
|
|
@@ -684,7 +684,7 @@ The format definition or undefined if not found.
|
|
|
684
684
|
|
|
685
685
|
> `static` **register**(`format`): `void`
|
|
686
686
|
|
|
687
|
-
Defined in: [packages/mdast-plus/src/pipeline.ts:49](https://github.com/isdk/mdast-plus.js/blob/
|
|
687
|
+
Defined in: [packages/mdast-plus/src/pipeline.ts:49](https://github.com/isdk/mdast-plus.js/blob/52d1ca889a60b0073e2ea9d89beea6e3ef7680a2/src/pipeline.ts#L49)
|
|
688
688
|
|
|
689
689
|
Registers a global document format.
|
|
690
690
|
|