Customize inline lexer #105

ForbesLindesay opened this Issue Jan 5, 2013 · 11 comments


None yet

ForbesLindesay commented Jan 5, 2013

I'd like to be able to customize the inline lexer with an additional type (specifically math). At the moment it's not extendable. There as an implementation of this in #71 but that request was closed by the OP for some reason.

I'd also like to see something along this line (plus a custom block lexer too).

I'm currently working on a documentation parser / generator for based on markdown formatted comments and I need to both filter out the parameter / type annotations from the token stream, as well as convert them to HTML later on.

Right now I'm using a custom patched version of marked which just utilizes a couple of callbacks and other small modifications (i.e. storing the raw text of a process nodes e.g. "storing the full "### heading title" for a heading).

adam-p commented Jun 27, 2013

I figured I'd throw my use cases into my +1 for this issue as well. (Ref: adam-p/markdown-here)

  1. I've hacked math support into my copy of marked.js. It's inline-only and looks like $...$. It translates TeX into an image that uses the Google Chart API. (MathJax and MathML don't work in email.)
  2. I need to add the scheme to URLs. Some email clients can't copy with links that don't provide a scheme (adam-p/markdown-here#57), so "http://" should be added at start of any such URL.
    • So... I implemented that by pre-parsing MD links and adding the scheme. But, of course, that introduced another bug -- I didn't exclude MD links inside code blocks (adam-p/markdown-here#83). I guess I'll have to hack into marked.js again.

I'm sure I could come up with more examples, but those are probably representative. Some things are extensions of MD, and some things are hacks to help people use MD in the weird environment of email better.

@adam-p adam-p referenced this issue in adam-p/markdown-here Jun 27, 2013


[a](b) links shouldn't expand inside of a code block #83


insanehong commented Aug 14, 2013


Ognian commented Mar 10, 2014

Any news on this? I would need the feature of #114 . I understand that it is not added to marked but it should be possible to add it as a custom extension.

grofit commented Dec 4, 2014

Any news on this? I am looking for something which does basic markdown but allows me to add some custom bindings on top.

nicbou commented Jan 13, 2015

I second the need for this. I patched the file to include my custom lexer, but it's far from ideal.

Any news on this topic? I'd like to see an option to take out "$...$" and "$$...$$" to pass it to MathJax. It's like two years since the issue was opened.

davitv commented Nov 13, 2015

@PeterBocan , i needed same future so i added way to optionally pass custom inline and block rules with parse functions. Look at this branch

I'll look at that! Thanks!

Any news?

davitv commented Nov 30, 2015

Look at this branch

@joshbruce joshbruce added the question label Dec 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment