-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code block ignores newlines #2741
Comments
Are you using If you want to share your extension code so far we can take a look and provide tips to get you unstuck. |
I am using parseInline(). |
Could you provide the entire code you have tried for your extension so far? |
just used parseInline ;) |
As @calculuschild said parseInline is for inline content only. Fenced code block are block content. This looks like it is working as expected. |
ok, how can get output with only specified tags? |
You can create a tokenizer that is a noop for any tokens you don't want. Something like: const tokenizer = {
heading() {},
hr() {},
blockquote() {},
list() {},
table() {},
lheading() {}
};
marked.use({tokenizer}); |
I passed like that
this helped, but how to remove the <p> at the beginning and end? |
If you are parsing as block tokens every token has to be in a block token. The easiest way to remove them is just to remove them after running through marked. let html = marked.parse(markdown);
html = html.replace(/^\s*<p>([^]*)<\/p>\s*$/, "$1"); Keep in mind that html is valid markdown so if you actually do not want to allow someone to output |
Marked version: 4.2.12
Describe the bug
Line break is ignored in code block.
with parseInline()
To Reproduce
```
// Example of code
console.log("Hello world!");
```
converted to
<code>// Example of code console.log("Hello world!");</code>
Expected behavior
<code>// Example of code
console.log("Hello world!");</code>
The text was updated successfully, but these errors were encountered: