loghub-me-markdown-renderer 0.1.0 → 0.1.1
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 +1 -2
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 I=(e,t)=>{for(var a in t)l(e,a,{get:t[a],enumerable:!0})},f=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of L(t))!T.call(e,s)&&s!==a&&l(e,s,{get:()=>t[s],enumerable:!(i=x(t,s))||i.enumerable});return e};var n=(e,t,a)=>(a=e!=null?w(O(e)):{},f(t||!e||!e.__esModule?l(a,"default",{value:e,enumerable:!0}):a,e)),S=e=>f(l({},"__esModule",{value:!0}),e);var M={};I(M,{MarkdownRenderer:()=>h});module.exports=S(M);var c=n(require("highlight.js")),k=n(require("markdown-it")),b=n(require("markdown-it-anchor"));function m(e){let t=e.attrGet("href");if(t){let a=`/safe-link?url=${t}`;e.attrSet("href",a),e.attrSet("target","_blank")}}var u=n(require("sanitize-html")),v=["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"]},g=e=>(0,u.default)(e,{allowedTags:v,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 r=class r{constructor(t={}){if(this.options={...r.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??((i,s,o,p,d)=>d.renderToken(i,s,o));this.client.renderer.rules.link_open=(i,s,o,p,d)=>(m(i[s]),a(i,s,o,p,d))}}render(t){let a=this.client.render(t);return this.options.useSanitize?g(a):a}};r.DEFAULT_OPTIONS={html:!1,xhtmlOut:!1,langPrefix:"language-",linkify:!0,typographer:!1,highlight:(t,a)=>{if(a&&c.default.getLanguage(a))try{return c.default.highlight(t,{language:a}).value}catch{}return""},useMarkdownItAnchor:!0,useSafeLinkify:!0,useSanitize:!0};var h=r;0&&(module.exports={MarkdownRenderer});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p from"highlight.js";import y from"markdown-it";import k from"markdown-it-anchor";function d(a){let t=a.attrGet("href");if(t){let e=`/safe-link?url=${t}`;a.attrSet("href",e),a.attrSet("target","_blank")}}import m from"sanitize-html";var u=["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"],g={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"]},c=a=>m(a,{allowedTags:u,allowedAttributes:g,disallowedTagsMode:"discard",selfClosing:["img","br","hr","area","base","basefont","input","link","meta"]});var h=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:h}),this.options.useSafeLinkify){let e=this.client.renderer.rules.link_open??((s,i,n,o,r)=>r.renderToken(s,i,n));this.client.renderer.rules.link_open=(s,i,n,o,r)=>(d(s[i]),e(s,i,n,o,r))}}render(t){let e=this.client.render(t);return this.options.useSanitize?c(e):e}};l.DEFAULT_OPTIONS={html:!1,xhtmlOut:!1,langPrefix:"language-",linkify:!0,typographer:!1,highlight:(t,e)=>{if(e&&p.getLanguage(e))try{return p.highlight(t,{language:e}).value}catch{}return""},useMarkdownItAnchor:!0,useSafeLinkify:!0,useSanitize:!0};var f=l;export{f 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.1",
|
|
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"
|