From 11d7fd5c3fd86756ca4113fb0a67c1b8c5ed3f78 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 3 Sep 2015 01:26:04 -0700 Subject: [PATCH] Markdown.pl: do not recognize '_' within words The '*' character can still be used for emphasis within a word, but '_' will remain unchanged unless it starts and ends a word. Signed-off-by: Kyle J. McKay --- Markdown.pl | 14 +++++++++----- syntax.text | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Markdown.pl b/Markdown.pl index 17ffce5..6e00d2c 100755 --- a/Markdown.pl +++ b/Markdown.pl @@ -1048,11 +1048,15 @@ sub _DoItalicsAndBold { my $text = shift; # must go first: - $text =~ s{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 } - {$2}gsx; - - $text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 } - {$2}gsx; + $text =~ s{ \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* } + {$1}gsx; + $text =~ s{ (?$1}gsx; + + $text =~ s{ \* (?=\S) (.+?) (?<=\S) \* } + {$1}gsx; + $text =~ s{ (?$1}gsx; return $text; } diff --git a/syntax.text b/syntax.text index d23a051..61a3885 100644 --- a/syntax.text +++ b/syntax.text @@ -740,8 +740,9 @@ will produce: You can use whichever style you prefer; the lone restriction is that the same character must be used to open and close an emphasis span. +Additionally `_` and double `_` are not recognized within words. -Emphasis can be used in the middle of a word: +Emphasis using `*` can be used in the middle of a word: un*frigging*believable