loghub-me-markdown-renderer 0.1.0 → 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/dist/index.d.mts +1 -11
- package/dist/index.d.ts +1 -11
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -3
package/dist/index.d.mts
CHANGED
|
@@ -5,23 +5,13 @@ interface MarkdownRendererOptions extends MarkdownIt.Options {
|
|
|
5
5
|
useSafeLinkify?: boolean;
|
|
6
6
|
useSanitize?: boolean;
|
|
7
7
|
}
|
|
8
|
-
interface RenderedResult {
|
|
9
|
-
html: string;
|
|
10
|
-
anchors: Anchor[];
|
|
11
|
-
}
|
|
12
|
-
interface Anchor {
|
|
13
|
-
level: number;
|
|
14
|
-
slug: string;
|
|
15
|
-
text: string;
|
|
16
|
-
}
|
|
17
8
|
|
|
18
9
|
declare class MarkdownRenderer {
|
|
19
10
|
private static readonly DEFAULT_OPTIONS;
|
|
20
11
|
private readonly client;
|
|
21
12
|
private readonly options;
|
|
22
13
|
constructor(options?: MarkdownRendererOptions);
|
|
23
|
-
render(markdown: string):
|
|
24
|
-
private parseAnchors;
|
|
14
|
+
render(markdown: string): string;
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
export { MarkdownRenderer };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,23 +5,13 @@ interface MarkdownRendererOptions extends MarkdownIt.Options {
|
|
|
5
5
|
useSafeLinkify?: boolean;
|
|
6
6
|
useSanitize?: boolean;
|
|
7
7
|
}
|
|
8
|
-
interface RenderedResult {
|
|
9
|
-
html: string;
|
|
10
|
-
anchors: Anchor[];
|
|
11
|
-
}
|
|
12
|
-
interface Anchor {
|
|
13
|
-
level: number;
|
|
14
|
-
slug: string;
|
|
15
|
-
text: string;
|
|
16
|
-
}
|
|
17
8
|
|
|
18
9
|
declare class MarkdownRenderer {
|
|
19
10
|
private static readonly DEFAULT_OPTIONS;
|
|
20
11
|
private readonly client;
|
|
21
12
|
private readonly options;
|
|
22
13
|
constructor(options?: MarkdownRendererOptions);
|
|
23
|
-
render(markdown: string):
|
|
24
|
-
private parseAnchors;
|
|
14
|
+
render(markdown: string): string;
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
export { MarkdownRenderer };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var w=Object.create;var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var a in t)l(e,a,{get:t[a],enumerable:!0})},u=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of L(t))!T.call(e,i)&&i!==a&&l(e,i,{get:()=>t[i],enumerable:!(s=x(t,i))||s.enumerable});return e};var r=(e,t,a)=>(a=e!=null?w(O(e)):{},u(t||!e||!e.__esModule?l(a,"default",{value:e,enumerable:!0}):a,e)),I=e=>u(l({},"__esModule",{value:!0}),e);var A={};v(A,{MarkdownRenderer:()=>h});module.exports=I(A);var n=r(require("highlight.js")),k=r(require("markdown-it")),b=r(require("markdown-it-anchor"));function f(e){let t=e.attrGet("href");if(t){let a=`/safe-link?url=${t}`;e.attrSet("href",a),e.attrSet("target","_blank")}}var g=r(require("sanitize-html")),S=["a","aside","blockquote","br","circle","code","details","div","em","embed-katex","eq","eqn","h1","h2","h3","h4","h5","h6","hr","iframe","img","input","li","ol","p","pre","s","section","span","strong","summary","sup","table","tbody","td","text","th","thead","tr","ul"],z={a:["aria-hidden","class","href","id","rel","style","target","title"],aside:["class"],blockquote:["class","data-line"],br:["style"],circle:["cx","cy","fill","r"],code:["class","data-line"],details:[],div:["class"],em:[],"embed-katex":["display-mode"],eq:["class"],eqn:[],h1:["id","class","data-line"],h2:["id","class","data-line"],h3:["id","class","data-line"],h4:["id","class","data-line"],h5:["class","data-line"],h6:["class","data-line"],hr:["class","data-line"],iframe:["allow","allowfullscreen","allowtransparency","data-content","frameborder","id","loading","sandbox","scrolling","src","style","width"],img:["alt","class","height","loading","src","title","width"],input:["checked","class","type"],li:["class","id","data-line"],ol:["class","start","data-line"],p:["class","data-line"],pre:["class"],s:[],section:["class","data-line"],span:["class","title"],strong:[],summary:[],sup:["class"],table:["class","data-line"],tbody:["class","data-line"],td:["style"],text:["dominant-baseline","fill","font-size","font-weight","text-anchor","x","y"],th:["style"],thead:["class","data-line"],tr:["class","data-line"],ul:["class","data-line"]},m=e=>(0,g.default)(e,{allowedTags:S,allowedAttributes:z,disallowedTagsMode:"discard",selfClosing:["img","br","hr","area","base","basefont","input","link","meta"]});var y=e=>encodeURIComponent(e.toLowerCase().replace(/%20/g,"-").replace(/[^가-힣ㄱ-ㅎㅏ-ㅣa-z0-9-_]/g,"-").replace(/--+/g,"-").replace(/^-|-$/g,""));var o=class o{constructor(t={}){if(this.options={...o.DEFAULT_OPTIONS,...t},this.client=new k.default(this.options),this.options.useMarkdownItAnchor&&this.client.use(b.default,{slugify:y}),this.options.useSafeLinkify){let a=this.client.renderer.rules.link_open??((s,i,d,p,c)=>c.renderToken(s,i,d));this.client.renderer.rules.link_open=(s,i,d,p,c)=>(f(s[i]),a(s,i,d,p,c))}}render(t){let a=this.client.render(t);return this.options.useSanitize?m(a):a}};o.DEFAULT_OPTIONS={html:!1,xhtmlOut:!1,langPrefix:"language-",linkify:!0,typographer:!1,highlight:(t,a)=>{try{return a&&n.default.getLanguage(a)?n.default.highlight(t,{language:a}).value:n.default.highlightAuto(t).value}catch{return""}},useMarkdownItAnchor:!0,useSafeLinkify:!0,useSanitize:!0};var h=o;0&&(module.exports={MarkdownRenderer});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"highlight.js";import y from"markdown-it";import k from"markdown-it-anchor";function c(a){let t=a.attrGet("href");if(t){let e=`/safe-link?url=${t}`;a.attrSet("href",e),a.attrSet("target","_blank")}}import f from"sanitize-html";var g=["a","aside","blockquote","br","circle","code","details","div","em","embed-katex","eq","eqn","h1","h2","h3","h4","h5","h6","hr","iframe","img","input","li","ol","p","pre","s","section","span","strong","summary","sup","table","tbody","td","text","th","thead","tr","ul"],m={a:["aria-hidden","class","href","id","rel","style","target","title"],aside:["class"],blockquote:["class","data-line"],br:["style"],circle:["cx","cy","fill","r"],code:["class","data-line"],details:[],div:["class"],em:[],"embed-katex":["display-mode"],eq:["class"],eqn:[],h1:["id","class","data-line"],h2:["id","class","data-line"],h3:["id","class","data-line"],h4:["id","class","data-line"],h5:["class","data-line"],h6:["class","data-line"],hr:["class","data-line"],iframe:["allow","allowfullscreen","allowtransparency","data-content","frameborder","id","loading","sandbox","scrolling","src","style","width"],img:["alt","class","height","loading","src","title","width"],input:["checked","class","type"],li:["class","id","data-line"],ol:["class","start","data-line"],p:["class","data-line"],pre:["class"],s:[],section:["class","data-line"],span:["class","title"],strong:[],summary:[],sup:["class"],table:["class","data-line"],tbody:["class","data-line"],td:["style"],text:["dominant-baseline","fill","font-size","font-weight","text-anchor","x","y"],th:["style"],thead:["class","data-line"],tr:["class","data-line"],ul:["class","data-line"]},h=a=>f(a,{allowedTags:g,allowedAttributes:m,disallowedTagsMode:"discard",selfClosing:["img","br","hr","area","base","basefont","input","link","meta"]});var p=a=>encodeURIComponent(a.toLowerCase().replace(/%20/g,"-").replace(/[^가-힣ㄱ-ㅎㅏ-ㅣa-z0-9-_]/g,"-").replace(/--+/g,"-").replace(/^-|-$/g,""));var l=class l{constructor(t={}){if(this.options={...l.DEFAULT_OPTIONS,...t},this.client=new y(this.options),this.options.useMarkdownItAnchor&&this.client.use(k,{slugify:p}),this.options.useSafeLinkify){let e=this.client.renderer.rules.link_open??((i,s,r,d,n)=>n.renderToken(i,s,r));this.client.renderer.rules.link_open=(i,s,r,d,n)=>(c(i[s]),e(i,s,r,d,n))}}render(t){let e=this.client.render(t);return this.options.useSanitize?h(e):e}};l.DEFAULT_OPTIONS={html:!1,xhtmlOut:!1,langPrefix:"language-",linkify:!0,typographer:!1,highlight:(t,e)=>{try{return e&&o.getLanguage(e)?o.highlight(t,{language:e}).value:o.highlightAuto(t).value}catch{return""}},useMarkdownItAnchor:!0,useSafeLinkify:!0,useSanitize:!0};var u=l;export{u as MarkdownRenderer};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loghub-me-markdown-renderer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A markdown renderer for LogHub",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"packageManager": "pnpm@10.13.1",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"highlight.js": "^11.11.1",
|
|
19
|
-
"jsdom": "^26.1.0",
|
|
20
19
|
"markdown-it": "^14.1.0",
|
|
21
20
|
"markdown-it-anchor": "^9.2.0",
|
|
22
21
|
"sanitize-html": "^2.17.0"
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
"@types/node": "^24.3.1",
|
|
28
27
|
"@types/sanitize-html": "^2.16.0",
|
|
29
28
|
"prettier": "^3.6.2",
|
|
30
|
-
"tsup": "^8.5.
|
|
29
|
+
"tsup": "^8.5.1",
|
|
31
30
|
"tsx": "^4.20.5",
|
|
32
31
|
"typescript": "^5.8.3"
|
|
33
32
|
},
|