coreyti/showdown — Issue #10: Incorrect parsing of underscore and asterisk
Author: waynew
Created: 2011-12-08 14:05:37+00:00
State: open

If you have text like this:

```
Hello.this\_is\_a\_variable
and.this.is.another_one
```

Showdown incorrectly parses it as:

```
Hello.thisisavariable
and.this.is.anotherone
```

To fix it, replace lines 984-988:

text = text.replace(/(?![\])(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
"$2");

text = text.replace(/(?![\])(\*|_)(?=\S)([^\r]*?\S)\1/g,
"$2");

I'm not a regex pro, but as far as I can tell adding the negative lookahead ```(?![\])``` before the groups works fine. This tells the regex to skip those characters if they're escaped with the backslash '\' character.

Thanks!