BlueCloth bold/italic problem.

L

Lloyd Zusman

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 ".*?")

Is there any reason for why this change shouldn't be made? If so, is
there another way to get BlueCloth to render 2-character words in bold
or italics?

Thanks in advance.
 
L

Lloyd Zusman

Lloyd Zusman said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top