Closed clark-97 closed 3 years ago
You have to set the breaks
option to true.
const markdown = "*Write a sentence using the given vocabulary word in each of the specified parts of speech.*\n\n> **Example:**\ntarget\n Noun: *The arrow hit the **target**.*\n Verb: *The bully **targeted** the new student.*\n\ndismay\n";
marked(markdown, {breaks: true});
I used marked on browser, not on node environment. I did put {breaks: true}
option as second argument in marked
function, but it doesn't seem to be working as I expected. Did I miss something?
const markdownStr = "# I'm header\n\n\n\n## hello\n[I'm a link](https://github.com)\n- unordered list item\n1. ordered item list\n\n![](react.png)\n> That's what they said...\n\nI'm **bold**\n```\nfunction() {\n\tconsole.log('I'm inside code block')\n}\n```\nI'm `inline code`"
const preview = document.getElementById("preview")
preview.innerHTML = marked(markdownStr, {breaks: true})
console.log(preview.innerHTML)
I expect three <br />
after I'm header, but neither on console nor on browser it is rendered correctly.
On console
<h1 id="im-header">I'm header</h1>
<h2 id="hello">hello</h2>
<p><a href="https://github.com">I'm a link</a></p>
<ul>
<li>unordered list item</li>
</ul>
<ol>
<li>ordered item list</li>
</ol>
<p><img src="react.png" alt=""></p>
<blockquote>
<p>That's what they said...</p>
</blockquote>
<p>I'm <strong>bold</strong></p>
<pre><code>function() {
console.log('I'm inside code block')
}
</code></pre>
<p>I'm <code>inline code</code></p>
On browser
I used marked on browser, not on node environment. I did put
{breaks: true}
option as second argument inmarked
function, but it doesn't seem to be working as I expected. Did I miss something?const markdownStr = "# I'm header\n\n\n\n## hello\n[I'm a link](https://github.com)\n- unordered list item\n1. ordered item list\n\n![](react.png)\n> That's what they said...\n\nI'm **bold**\n```\nfunction() {\n\tconsole.log('I'm inside code block')\n}\n```\nI'm `inline code`" const preview = document.getElementById("preview") preview.innerHTML = marked(markdownStr, {breaks: true}) console.log(preview.innerHTML)
I expect three
<br />
after I'm header, but neither on console nor on browser it is rendered correctly.On console
<h1 id="im-header">I'm header</h1> <h2 id="hello">hello</h2> <p><a href="https://github.com">I'm a link</a></p> <ul> <li>unordered list item</li> </ul> <ol> <li>ordered item list</li> </ol> <p><img src="react.png" alt=""></p> <blockquote> <p>That's what they said...</p> </blockquote> <p>I'm <strong>bold</strong></p> <pre><code>function() { console.log('I'm inside code block') } </code></pre> <p>I'm <code>inline code</code></p>
On browser
Looks like I didn't understand the concept of \n
in markdown. No matter how many \n
is inputted, I realised that it will only generate one <br>
. Sorry to bother.
Marked version: 1.2.5
Markdown flavor: i am not sure
Expectation
Result