const unified = require('unified');
const md = require('remark-parse');
const parser = unified().use(md);
console.log(parser.parse(`<a href="b">c</a>`).children[0]);
The whole <a href="b">c</a> should be parsed as an HTML node
{
type: 'paragraph',
children: [
{ type: 'html', value: '<a href="b">', position: [Position] },
{ type: 'text', value: 'c', position: [Position] },
{ type: 'html', value: '</a>', position: [Position] }
],
position: Position {
start: { line: 1, column: 1, offset: 0 },
end: { line: 1, column: 18, offset: 17 },
indent: []
}
}
This is expected, because inline HTML can contain Markdown again:
<a href="#">*emphasis works*</a>
@wooorm Get it, thanks for your quick response!
Another thing which made me confused is the result of <a href="b">\nc</a>:
{
type: 'html',
value: '<a href="b">\nc</a>',
position: Position {
start: { line: 1, column: 1, offset: 0 },
end: { line: 2, column: 6, offset: 18 },
indent: [ 1 ]
}
}
So the markdown in HTML only takes effects when there is no line break?
HTML in Markdown is weird. Because the line has only a complete opening tag, it turns into an HTML block.
<a href="b">
*emphasis doesn鈥檛 work*</a>
I m having the same problem as @pd4d10, with nested HTML tags and HTML tags in the markdown table cells. The styling of the texts are completed messed because it is rendered outside the HTML tags.
Markdown content:*
Something is not right!
<span>Are you sure?</span>
<span>Yes</span>
Rendered output in the browser:
<p>Something is not right!
<span></span>Are you sure?
<span></span><span></span>Yes
</p>
According to this article, markdown should not be allowed in the HTML.
@pd4d10 Please see support.md on how to ask questions.