-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Ignore certain rules defined by markdown. #1302
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
Comments
You can create your own renderer and replace all other render functions to just return the text. const marked = require('marked');
const renderer = new marked.Renderer();
renderer.code =
renderer.blockquote =
renderer.html =
renderer.heading =
renderer.hr =
renderer.list =
renderer.listitem =
renderer.checkbox =
renderer.paragraph =
renderer.table =
renderer.tablerow =
renderer.tablecell =
renderer.codespan =
renderer.br =
renderer.del =
renderer.image = function (text) {
return text;
};
console.log(marked(markdownString, { renderer: renderer })); |
It could be really great to have an out-of-the-box solution for this scenario. For the time being, I settled on using the following approach: const enabled = ['list', 'listitem', 'strong', 'em', 'paragraph', 'br'];
const renderer = new marked.TextRenderer();
const realRenderer = new marked.Renderer();
enabled.forEach((option) => {
renderer[option] = realRenderer[option];
}); |
Related: #420 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I want to convert only bold, italic, underline and link to markdown and ignore other rules mentioned by the lexer.
How do i achieve this?
I could not find a example on the extensibility page.
Can someone help me with this?
I want to ignore all rules except above mentioned four conditions.
The text was updated successfully, but these errors were encountered: