Browse Source

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 <mackyle@gmail.com>
master
Kyle J. McKay 9 years ago
parent
commit
11d7fd5c3f
  1. 14
      Markdown.pl
  2. 3
      syntax.text

14
Markdown.pl

@ -1048,11 +1048,15 @@ sub _DoItalicsAndBold {
my $text = shift;
# <strong> must go first:
$text =~ s{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 }
{<strong>$2</strong>}gsx;
$text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 }
{<em>$2</em>}gsx;
$text =~ s{ \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }
{<strong>$1</strong>}gsx;
$text =~ s{ (?<!\w) __ (?=\S) (.+?[*_]*) (?<=\S) __ (?!\w) }
{<strong>$1</strong>}gsx;
$text =~ s{ \* (?=\S) (.+?) (?<=\S) \* }
{<em>$1</em>}gsx;
$text =~ s{ (?<!\w) _ (?=\S) (.+?) (?<=\S) _ (?!\w) }
{<em>$1</em>}gsx;
return $text;
}

3
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

Loading…
Cancel
Save