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 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): RenderedResult;
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): RenderedResult;
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 x=Object.create;var r=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})},u=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of T(t))!O.call(e,i)&&i!==a&&r(e,i,{get:()=>t[i],enumerable:!(s=L(t,i))||s.enumerable});return e};var l=(e,t,a)=>(a=e!=null?x(M(e)):{},u(t||!e||!e.__esModule?r(a,"default",{value:e,enumerable:!0}):a,e)),A=e=>u(r({},"__esModule",{value:!0}),e);var q={};v(q,{MarkdownRenderer:()=>p});module.exports=A(q);var w=l(require("markdown-it")),b=l(require("markdown-it-anchor"));var f=e=>encodeURIComponent(e.toLowerCase().replace(/%20/g,"-").replace(/[^가-힣ㄱ-ㅎㅏ-ㅣa-z0-9-_]/g,"-").replace(/--+/g,"-").replace(/^-|-$/g,""));var c=l(require("highlight.js"));var g=l(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"],I={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"]},y=e=>(0,g.default)(e,{allowedTags:S,allowedAttributes:I,disallowedTagsMode:"discard",selfClosing:["img","br","hr","area","base","basefont","input","link","meta"]});function k(e){let t=e.attrGet("href");if(t){let a=`/safe-link?url=${t}`;e.attrSet("href",a),e.attrSet("target","_blank")}}var h=require("jsdom"),o=class o{constructor(t={}){if(this.options={...o.DEFAULT_OPTIONS,...t},this.client=new w.default(this.options),this.options.useMarkdownItAnchor&&this.client.use(b.default,{slugify:f}),this.options.useSafeLinkify){let a=this.client.renderer.rules.link_open??((s,i,n,m,d)=>d.renderToken(s,i,n));this.client.renderer.rules.link_open=(s,i,n,m,d)=>(k(s[i]),a(s,i,n,m,d))}}render(t){let a=this.client.render(t),s=this.options.useSanitize?y(a):a,i=new h.JSDOM(s),n=this.parseAnchors(i.window.document.body.innerHTML);return{html:s,anchors:n}}parseAnchors(t){let a=new h.JSDOM(t);return Array.from(a.window.document.querySelectorAll("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]")).map(s=>({level:parseInt(s.tagName[1],10),slug:s.id,text:s.textContent||""}))}};o.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 p=o;0&&(module.exports={MarkdownRenderer});
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 k from"markdown-it";import w from"markdown-it-anchor";var d=s=>encodeURIComponent(s.toLowerCase().replace(/%20/g,"-").replace(/[^가-힣ㄱ-ㅎㅏ-ㅣa-z0-9-_]/g,"-").replace(/--+/g,"-").replace(/^-|-$/g,""));import p from"highlight.js";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"],y={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=s=>f(s,{allowedTags:g,allowedAttributes:y,disallowedTagsMode:"discard",selfClosing:["img","br","hr","area","base","basefont","input","link","meta"]});function h(s){let a=s.attrGet("href");if(a){let e=`/safe-link?url=${a}`;s.attrSet("href",e),s.attrSet("target","_blank")}}import{JSDOM as m}from"jsdom";var r=class r{constructor(a={}){if(this.options={...r.DEFAULT_OPTIONS,...a},this.client=new k(this.options),this.options.useMarkdownItAnchor&&this.client.use(w,{slugify:d}),this.options.useSafeLinkify){let e=this.client.renderer.rules.link_open??((t,i,n,o,l)=>l.renderToken(t,i,n));this.client.renderer.rules.link_open=(t,i,n,o,l)=>(h(t[i]),e(t,i,n,o,l))}}render(a){let e=this.client.render(a),t=this.options.useSanitize?c(e):e,i=new m(t),n=this.parseAnchors(i.window.document.body.innerHTML);return{html:t,anchors:n}}parseAnchors(a){let e=new m(a);return Array.from(e.window.document.querySelectorAll("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]")).map(t=>({level:parseInt(t.tagName[1],10),slug:t.id,text:t.textContent||""}))}};r.DEFAULT_OPTIONS={html:!1,xhtmlOut:!1,langPrefix:"language-",linkify:!0,typographer:!1,highlight:(a,e)=>{if(e&&p.getLanguage(e))try{return p.highlight(a,{language:e}).value}catch{}return""},useMarkdownItAnchor:!0,useSafeLinkify:!0,useSanitize:!0};var u=r;export{u as MarkdownRenderer};
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.0",
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.0",
29
+ "tsup": "^8.5.1",
31
30
  "tsx": "^4.20.5",
32
31
  "typescript": "^5.8.3"
33
32
  },