mirror of https://github.com/markedjs/marked
feat: add block param to html renderer (#2768)
parent
5d59ae0f5d
commit
fa21b9f60a
|
@ -106,7 +106,7 @@ console.log(marked.parse('# heading+'));
|
||||||
|
|
||||||
- <code>**code**(*string* code, *string* infostring, *boolean* escaped)</code>
|
- <code>**code**(*string* code, *string* infostring, *boolean* escaped)</code>
|
||||||
- <code>**blockquote**(*string* quote)</code>
|
- <code>**blockquote**(*string* quote)</code>
|
||||||
- <code>**html**(*string* html)</code>
|
- <code>**html**(*string* html, *boolean* block)</code>
|
||||||
- <code>**heading**(*string* text, *number* level, *string* raw, *Slugger* slugger)</code>
|
- <code>**heading**(*string* text, *number* level, *string* raw, *Slugger* slugger)</code>
|
||||||
- <code>**hr**()</code>
|
- <code>**hr**()</code>
|
||||||
- <code>**list**(*string* body, *boolean* ordered, *number* start)</code>
|
- <code>**list**(*string* body, *boolean* ordered, *number* start)</code>
|
||||||
|
|
|
@ -173,8 +173,7 @@ export class Parser {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case 'html': {
|
case 'html': {
|
||||||
// TODO parse inline content if parameter markdown=1
|
out += this.renderer.html(token.text, token.block);
|
||||||
out += this.renderer.html(token.text);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case 'paragraph': {
|
case 'paragraph': {
|
||||||
|
|
|
@ -45,7 +45,7 @@ export class Renderer {
|
||||||
return `<blockquote>\n${quote}</blockquote>\n`;
|
return `<blockquote>\n${quote}</blockquote>\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
html(html) {
|
html(html, block) {
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,6 +362,7 @@ export class Tokenizer {
|
||||||
if (cap) {
|
if (cap) {
|
||||||
const token = {
|
const token = {
|
||||||
type: 'html',
|
type: 'html',
|
||||||
|
block: true,
|
||||||
raw: cap[0],
|
raw: cap[0],
|
||||||
pre: !this.options.sanitizer
|
pre: !this.options.sanitizer
|
||||||
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
||||||
|
@ -519,6 +520,7 @@ export class Tokenizer {
|
||||||
raw: cap[0],
|
raw: cap[0],
|
||||||
inLink: this.lexer.state.inLink,
|
inLink: this.lexer.state.inLink,
|
||||||
inRawBlock: this.lexer.state.inRawBlock,
|
inRawBlock: this.lexer.state.inRawBlock,
|
||||||
|
block: false,
|
||||||
text: this.options.sanitize
|
text: this.options.sanitize
|
||||||
? (this.options.sanitizer
|
? (this.options.sanitizer
|
||||||
? this.options.sanitizer(cap[0])
|
? this.options.sanitizer(cap[0])
|
||||||
|
|
|
@ -773,6 +773,7 @@ paragraph
|
||||||
type: 'html',
|
type: 'html',
|
||||||
raw: '<div>html</div>',
|
raw: '<div>html</div>',
|
||||||
pre: false,
|
pre: false,
|
||||||
|
block: true,
|
||||||
text: '<div>html</div>'
|
text: '<div>html</div>'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -787,6 +788,7 @@ paragraph
|
||||||
type: 'html',
|
type: 'html',
|
||||||
raw: '<pre>html</pre>',
|
raw: '<pre>html</pre>',
|
||||||
pre: true,
|
pre: true,
|
||||||
|
block: true,
|
||||||
text: '<pre>html</pre>'
|
text: '<pre>html</pre>'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -802,6 +804,7 @@ paragraph
|
||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
raw: '<div>html</div>',
|
raw: '<div>html</div>',
|
||||||
pre: false,
|
pre: false,
|
||||||
|
block: true,
|
||||||
text: '<div>html</div>',
|
text: '<div>html</div>',
|
||||||
tokens: [{
|
tokens: [{
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
@ -884,9 +887,9 @@ paragraph
|
||||||
expectInlineTokens({
|
expectInlineTokens({
|
||||||
md: '<div>html</div>',
|
md: '<div>html</div>',
|
||||||
tokens: [
|
tokens: [
|
||||||
{ type: 'html', raw: '<div>', inLink: false, inRawBlock: false, text: '<div>' },
|
{ type: 'html', raw: '<div>', inLink: false, inRawBlock: false, block: false, text: '<div>' },
|
||||||
{ type: 'text', raw: 'html', text: 'html' },
|
{ type: 'text', raw: 'html', text: 'html' },
|
||||||
{ type: 'html', raw: '</div>', inLink: false, inRawBlock: false, text: '</div>' }
|
{ type: 'html', raw: '</div>', inLink: false, inRawBlock: false, block: false, text: '</div>' }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -896,7 +899,14 @@ paragraph
|
||||||
md: '<div>html</div>',
|
md: '<div>html</div>',
|
||||||
options: { sanitize: true },
|
options: { sanitize: true },
|
||||||
tokens: [
|
tokens: [
|
||||||
{ type: 'text', raw: '<div>html</div>', inLink: false, inRawBlock: false, text: '<div>html</div>' }
|
{
|
||||||
|
type: 'text',
|
||||||
|
raw: '<div>html</div>',
|
||||||
|
inLink: false,
|
||||||
|
inRawBlock: false,
|
||||||
|
block: false,
|
||||||
|
text: '<div>html</div>'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue