0

I want to know how does the stackoverflow parser works, and how to imitate it. That is, this or this or this or link.

I mean, it's pretty obvious but I would want a JavaScript function that turned this:

[Google](http://www.google.com)
*italic*
**bold**
`customStyle`

Into this:

<a href="http://www.google.com">Google</a>
<span style="font-style:italic">italic</span>
<span style="font-weight:bold">italic</span>
<span class="custom">customStyle</span>

I was going to use regex but aside from them being somewhat complicated, after going through a couple of "parsing html" (not exactly what I was looking for) posts, like The Answer I got discouraged.

So, how should I go about making a parser?

Community
  • 1
  • 1
undefined
  • 3,949
  • 4
  • 26
  • 38
  • 1
    That's _markdown_. You can use one of the available parsers instead of reinventing the wheel. – Ram Dec 30 '14 at 21:21
  • That's not really parsing, that's just replacing text with other text. – Aran-Fey Dec 30 '14 at 21:22
  • As @Vohuman noted, that is markdown, and as such you can just look up the code of any of the numerous markdown parsers to see how they work. – regdoug Dec 30 '14 at 21:23
  • Ah, sorry for the confusion, anyway I still don't know how to make one, or at least add rules over an existing one, can you help me with that? Thanks – undefined Dec 30 '14 at 21:25

0 Answers0