asterisks as bold or italic?

Ben Williams benw at
Mon Mar 22 10:43:57 EST 2004

Jason Clark wrote:

> I think consistancy is much more important than configurability here.  
> After all, anyone who really, _really_ cares is free to change the 
> source.

And in that spirit, here's a tiny patch to that changes 
*single asterisks* to <strong> instead of <em>. Everything else remains 
the same for backwards compatibility.

My motivation is to match the behavior of Mozilla Mail and Thunderbird 
(although they treat underscores as underline). I also think the single 
asterisks better match Markup's design goals of being more readable, 
more easy to type, and looking less like markup.

I wanted to make /slashes/ do emphasis as well but I couldn't figure out 
how to do that without ending up with slashes in end tags encoded to 
<em> or </em>. Maybe the regexp wizards can figure that one out.

-------------- next part --------------
---	2004-03-22 09:20:29.827032100 -0500
+++	2004-03-22 09:52:10.371660500 -0500
@@ -879,9 +879,9 @@
 	my $text = shift;
 	# <strong> must go first:
-	$text =~ s{ (\*\*|__) (?=\S) (.+?) (?<=\S) \1 }{<strong>$2</strong>}gsx;
+	$text =~ s{ (\*\*|\*|__) (?=\S) (.+?) (?<=\S) \1 }{<strong>$2</strong>}gsx;
 	# Then <em>:
-	$text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 }{<em>$2</em>}gsx;
+	$text =~ s{ (_) (?=\S) (.+?) (?<=\S) \1 }{<em>$2</em>}gsx;
 	return $text;

More information about the Markdown-discuss mailing list