evilstreak / markdown-js

A Markdown parser for javascript
7.69k stars 863 forks source link

Support specific sections that are not processed by markdown #152

Open kasperpeulen opened 10 years ago

kasperpeulen commented 10 years ago

I would like to see support for specific sections that are not processed by markdown. This would solve the mathjax issue: https://github.com/evilstreak/markdown-js/issues/129, but this may also be usefull for other extensions.

For the mathjax example, I would like to tell markdown to not process anything between $...$, \(... \), $$ ... $$, \[...\], \begin ... \end. Would this be possible ?

kasperpeulen commented 10 years ago
Discourse.Dialect.registerBlock('math', function(block, next) {
    if (block.match(/\$|\\begin|\\end|\\[|\\]|\\(|\\)/) ) {
    return [ block.toString() ];
  }
});

I'm not sure what the right syntax is for markdown-js. But this work at the discourse software. This makes sure that if a paragraph contains math, then markdown is disabled. This is the direction that I would like it, but not optimal yet. It would be better if only the math itself is not parsed by markdown, now the whole paragraph is not parsed.