Repository navigation
Conversation
test new functionality with node test --ignore-html
|
I'm really uneasy about something like this. I would prefer to make marked modifiable and hookable from the outside, as opposed to adding options. That would allow many different extensions and anything the user wanted really. Although your code should work, there's also the performance issue. v8 might be smart enough to optimize those boolean checks out, but it still feels like the wrong way of going about it, which is why I haven't implemented anything like that yet. Ideally, what I would like for a user to be able to do is something like: var html = marked.rules.html;
marked.rules.html = function() {
if (opt.ignoreHtml) return;
return html.apply(this, arguments);
};I have 2 different (local) branches where I've implemented this, but it's not quite the way I want it. I really appreciate the interest though. If you want this kind of capability right now, you can still alter it from the outside, it will just be more hack-like. |
|
Ok. I think that would be more convenient, but it would also require more overhead. So I'll stick with my fork for the moment until you add such functionality. |
|
@matsko What do you mean with "blocks of HTML data". Only selected blocks? Comment them out: Some text.
<!--div>
<figure><img src="pic.jpg"></figure>
</div-->
More text. |
I added the possibility to ignore HTML markup by applying a second argument to the function call.
This will print
You can test the behavior via
This change should not impair marked's performance. If you don't use the second argument, everything remains the same as before. Then there's only one additional condition for each call of the function.
This comes in handy when you want to use markdown for user input on your website as it prevents users from doing XSS.
I hope you find this usable. At least, I do. ;-)