diff --git a/docs/USING_PRO.md b/docs/USING_PRO.md index 4c4b6609..63eca504 100644 --- a/docs/USING_PRO.md +++ b/docs/USING_PRO.md @@ -106,7 +106,7 @@ console.log(marked.parse('# heading+')); - **code**(*string* code, *string* infostring, *boolean* escaped) - **blockquote**(*string* quote) -- **html**(*string* html) +- **html**(*string* html, *boolean* block) - **heading**(*string* text, *number* level, *string* raw, *Slugger* slugger) - **hr**() - **list**(*string* body, *boolean* ordered, *number* start) diff --git a/src/Parser.js b/src/Parser.js index a22a2bcf..b1038aba 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -173,8 +173,7 @@ export class Parser { continue; } case 'html': { - // TODO parse inline content if parameter markdown=1 - out += this.renderer.html(token.text); + out += this.renderer.html(token.text, token.block); continue; } case 'paragraph': { diff --git a/src/Renderer.js b/src/Renderer.js index 5fe915dd..dccbb583 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -45,7 +45,7 @@ export class Renderer { return `
\n${quote}
\n`; } - html(html) { + html(html, block) { return html; } diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 9e2866f2..3468c2c8 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -362,6 +362,7 @@ export class Tokenizer { if (cap) { const token = { type: 'html', + block: true, raw: cap[0], pre: !this.options.sanitizer && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'), @@ -519,6 +520,7 @@ export class Tokenizer { raw: cap[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, + block: false, text: this.options.sanitize ? (this.options.sanitizer ? this.options.sanitizer(cap[0]) diff --git a/test/unit/Lexer-spec.js b/test/unit/Lexer-spec.js index e983c252..448f443e 100644 --- a/test/unit/Lexer-spec.js +++ b/test/unit/Lexer-spec.js @@ -773,6 +773,7 @@ paragraph type: 'html', raw: '
html
', pre: false, + block: true, text: '
html
' } ] @@ -787,6 +788,7 @@ paragraph type: 'html', raw: '
html
', pre: true, + block: true, text: '
html
' } ] @@ -802,6 +804,7 @@ paragraph type: 'paragraph', raw: '
html
', pre: false, + block: true, text: '<div>html</div>', tokens: [{ type: 'text', @@ -884,9 +887,9 @@ paragraph expectInlineTokens({ md: '
html
', tokens: [ - { type: 'html', raw: '
', inLink: false, inRawBlock: false, text: '
' }, + { type: 'html', raw: '
', inLink: false, inRawBlock: false, block: false, text: '
' }, { type: 'text', raw: 'html', text: 'html' }, - { type: 'html', raw: '
', inLink: false, inRawBlock: false, text: '
' } + { type: 'html', raw: '
', inLink: false, inRawBlock: false, block: false, text: '
' } ] }); }); @@ -896,7 +899,14 @@ paragraph md: '
html
', options: { sanitize: true }, tokens: [ - { type: 'text', raw: '
html
', inLink: false, inRawBlock: false, text: '<div>html</div>' } + { + type: 'text', + raw: '
html
', + inLink: false, + inRawBlock: false, + block: false, + text: '<div>html</div>' + } ] }); });