Ticket #17 (closed defect: duplicate)

Opened 4 years ago

Last modified 3 years ago

BlueCloth bold/italic problem.

Reported by: Lloyd Zusman <ljz@…> Owned by: deveiant
Priority: normal Milestone: Markdown 1.0.1
Component: MarkdownSyntax Version: 1.0.0
Severity: normal Keywords: double-character bold/italic
Cc:

Description

[via ruby-talk:120923]:

From: Lloyd Zusman <ljz@…>
Newsgroups: comp.lang.ruby
Subject: BlueCloth bold/italic problem.
Date: Sat, 20 Nov 2004 12:01:56 +0900
Message-ID: <m3is81tedi.fsf@…>

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.

--

Lloyd Zusman l...@… God bless you.

Change History

Changed 4 years ago by Lloyd Zusman <ljz@…>

[via ruby-talk:120926]:

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)

Changed 4 years ago by deveiant

  • status changed from new to assigned

I've added tests for this in changeset:73. Will be applying your suggested fixes in the near future.

Changed 3 years ago by deveiant

  • status changed from assigned to closed
  • resolution set to duplicate

All future work will be posted against the first report of this problem in #13.

Note: See TracTickets for help on using tickets.