mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add simple rendering of Markdown directive metadata to demo web page for easier diagnostics.
This commit is contained in:
parent
7c2391b021
commit
9640be90a4
2 changed files with 18 additions and 1 deletions
|
@ -33,6 +33,22 @@
|
|||
.replace(/>/g, ">");
|
||||
}
|
||||
|
||||
// Renders directive metadata
|
||||
function handleDirective(directive) {
|
||||
const content = directive.content;
|
||||
delete directive.content;
|
||||
if (content) {
|
||||
this.tag("<blockquote>");
|
||||
}
|
||||
this.tag("<code>");
|
||||
this.raw(this.encode(JSON.stringify(directive)));
|
||||
this.tag("</code>");
|
||||
this.raw(content);
|
||||
if (content) {
|
||||
this.tag("</blockquote>");
|
||||
}
|
||||
}
|
||||
|
||||
// Renders Markdown to HTML
|
||||
function render(markdown) {
|
||||
const match = /^\?renderer=([a-z-]+)$/.exec(window.location.search);
|
||||
|
@ -55,7 +71,7 @@
|
|||
const compileOptions = {
|
||||
"allowDangerousHtml": true,
|
||||
"htmlExtensions": [
|
||||
micromarkHtml.directiveHtml(),
|
||||
micromarkHtml.directiveHtml({ "*": handleDirective }),
|
||||
micromarkHtml.gfmAutolinkLiteralHtml(),
|
||||
micromarkHtml.gfmFootnoteHtml(),
|
||||
micromarkHtml.gfmTableHtml(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue