@@ -9,7 +9,7 @@ Quikdown is a small, secure markdown parser with bidirectional conversion. Zero
99
1010For small and fast projects quikdown includes built-in inline styles for a "batteries included" rendering experience, but these can be overridden with themed css (see light and dark examples).
1111
12- - ** quikdown.js** (9.1KB ) - Markdown to HTML Parser
12+ - ** quikdown.js** (9.0KB ) - Markdown to HTML Parser
1313- ** quikdown_bd.js** (13.8KB) - Bidirectional (HTML ↔ Markdown) Parser
1414- ** quikdown_edit.js** (37.8KB) - Drop-in editor component (HTML ↔ Markdown) with md/split/html views
1515
@@ -21,7 +21,7 @@ For small and fast projects quikdown includes built-in inline styles for a "batt
2121
2222- 📦 ** Zero dependencies** - No external libraries required
2323- 🌐 ** Universal** - Works in browsers and Node.js
24- - 🚀 ** Lightweight** - 9.1KB (core), 13.8KB (bidirectional), 37.8KB (editor)
24+ - 🚀 ** Lightweight** - 9.0KB (core), 13.8KB (bidirectional), 37.8KB (editor)
2525- 🔒 ** Secure by default** - Built-in XSS protection with URL sanitization
2626- 🎨 ** Flexible styling** - Inline styles or CSS classes with theme support
2727- 🔌 ** Plugin system** - Extensible fence block handlers
@@ -108,7 +108,9 @@ quikdown supports built-in styles for a "batteries included" experience or you c
108108const html = quikdown (markdown, {
109109 lazy_linefeeds: true , // Single newlines become <br>
110110 inline_styles: false , // Use class based CSS instead of inline styles
111- fence_plugin: myHandler // Custom code block processor
111+ fence_plugin: { // Custom code block processor (v1.1.0+ API)
112+ render: myHandler // Function to render fence blocks
113+ }
112114});
113115```
114116
@@ -135,18 +137,19 @@ Quikdown provides a callback for all fenced text such as code blocks, math, svg
135137Handle code blocks with custom languages:
136138
137139``` javascript
138- function fencePlugin (code , language ) {
139- if (language === ' mermaid' ) {
140- // Process with mermaid library and return rendered diagram
141- const id = ' mermaid-' + Math .random ().toString (36 ).substr (2 , 9 );
142- setTimeout (() => mermaid .render (id + ' -svg' , code).then (result => {
143- document .getElementById (id).innerHTML = result .svg ;
144- }), 0 );
145- return ` <div id="${ id} " class="mermaid">Loading diagram...</div>` ;
140+ const fencePlugin = {
141+ render : (code , language ) => {
142+ if (language === ' mermaid' ) {
143+ // Process with mermaid library and return rendered diagram
144+ const id = ' mermaid-' + Math .random ().toString (36 ).substr (2 , 9 );
145+ setTimeout (() => mermaid .render (id + ' -svg' , code).then (result => {
146+ document .getElementById (id).innerHTML = result .svg ;
147+ }), 0 );
148+ return ` <div id="${ id} " class="mermaid">Loading diagram...</div>` ;
149+ }
150+ // Return undefined for default handling
146151 }
147- return ` <pre>${ code} </pre>` ;
148- // Return undefined for default handling
149- }
152+ };
150153
151154const html = quikdown (markdown, { fence_plugin: fencePlugin });
152155```
@@ -156,18 +159,21 @@ const html = quikdown(markdown, { fence_plugin: fencePlugin });
156159
157160quikdown includes TypeScript definitions for better IDE support and type safety:
158161
159- ``` javascript
160- import quikdown , { QuikdownOptions } from ' quikdown' ;
162+ ``` typescript
163+ import quikdown , { QuikdownOptions , FencePlugin } from ' quikdown' ;
164+
165+ const fencePlugin: FencePlugin = {
166+ render : (content : string , language : string ) => {
167+ return ` <pre class="hljs ${language }">${content }</pre> ` ;
168+ }
169+ };
161170
162171const options: QuikdownOptions = {
163- inline_styles: true ,
164- fence_plugin : (content : string , language : string ) => {
165- return ` <pre class="hljs ${ language} ">${ content} </pre>` ;
166- }
172+ inline_styles: true ,
173+ fence_plugin: fencePlugin
167174};
168175
169176const html: string = quikdown (markdown , options );
170-
171177```
172178
173179## Supported Markdown
0 commit comments