Skip to content

Commit

Permalink
fix(subParsers/italicsAndBold): fix underscores not being correctly p…
Browse files Browse the repository at this point in the history
…arsed when used in conjunction with literalMidWordsUnderscores option
  • Loading branch information
tivie committed Jul 14, 2015
1 parent 542194e commit c9e85f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/subParsers/italicsAndBold.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ showdown.subParser('italicsAndBold', function (text, options) {
if (options.literalMidWordUnderscores) {
//underscores
// Since we are consuming a \s character, we need to add it
text = text.replace(/(^|\s)__(?=\S)([^]+?)__(?=\s|$)/gm, '$1<strong>$2</strong>');
text = text.replace(/(^|\s)_(?=\S)([^]+?)_(?=\s|$)/gm, '$1<em>$2</em>');
text = text.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm, '$1<strong>$2</strong>');
text = text.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm, '$1<em>$2</em>');
//asterisks
text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');
Expand Down

4 comments on commit c9e85f1

@butchmarshall
Copy link
Contributor

@butchmarshall butchmarshall commented on c9e85f1 Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IE8 is throwing "Expected ']' in regular expression" (both old and new expression - so this commit did not introduce the issue)

image

@tivie
Copy link
Member Author

@tivie tivie commented on c9e85f1 Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hummm...
Maybe changing [^] with [\s\S].

@butchmarshall I can't test on IE8 right now... do you mind testing it for me please?

@butchmarshall
Copy link
Contributor

@butchmarshall butchmarshall commented on c9e85f1 Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't crash anymore with that change @tivie! I don't know if the regexp is still performing the same operation though - does this function have tests?

image

@tivie
Copy link
Member Author

@tivie tivie commented on c9e85f1 Jun 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, all parsers and options have specific tests. You just need to run the test suite.

Those regexps should be interchangeable.

Please sign in to comment.