Lloyd Zusman
11/20/2004 6:37:00 AM
Lloyd Zusman <ljz@asfast.com> writes:
> I have discovered that in the latest release of BlueCloth, it's
> impossible to render 2-character words in either bold or italic.
>
> I looked through the source code, and I found the reason why:
>
> # Pattern to match strong emphasis in Markdown text
> BoldRegexp = %r{ (\*\*|__) (\S|\S.+?\S) \1 }x
>
> # Pattern to match normal emphasis in Markdown text
> ItalicRegexp = %r{ (\*|_) (\S|\S.+?\S) \1 }x
>
> Notice that the regexps only match strings that are either 1 character
> long or at least 3 characters long. To fix this, I believe that the
> code needs to be changed as follows:
>
> # Pattern to match strong emphasis in Markdown text
> BoldRegexp = %r{ (\*\*|__) (\S|\S.*?\S) \1 }x
>
> # Pattern to match normal emphasis in Markdown text
> ItalicRegexp = %r{ (\*|_) (\S|\S.*?\S) \1 }x
>
> (I replaced ".+?" with ".*?")
Also, the bold and italic conversions fail if the string spans more than
one line. For example ...
_BlueCloth will not turn this into
italics because it spans two lines_
Therefore, I suggest the following change, as well:
# Pattern to match strong emphasis in Markdown text
BoldRegexp = %r{ (\*\*|__) (\S|\S.*?\S) \1 }xm
# Pattern to match normal emphasis in Markdown text
ItalicRegexp = %r{ (\*|_) (\S|\S.*?\S) \1 }xm
(note the 'm' at the right side of the regexps)
--
Lloyd Zusman
ljz@asfast.com
God bless you.