0

On GitHub, use either the __ or ** to generate strong tag works:

我__愛__你

will generate:

<p>我<strong>愛</strong>你</p>.

But in my project (I'm using redcarpet 3.1.1) it's not recognized the strong tag, instead it generates:

<p>我__愛__你</p>

Which option do I need to set to turn this feature on Redcarpet 3? Thanks

Juanito Fatas
  • 9,419
  • 9
  • 46
  • 70

1 Answers1

1

By default Redcarpet will add <strong> or <em> tags when _ or * are used in a word like this:

I_love_you
我__愛__你

produces

I<em>love</em>you
我<strong>愛</strong>你

To turn this off you can use the :no_intra_emphasis parse option which leaves the above example unchanged.

If you aren’t getting the tags added then you probably already have this setting enabled and you need to turn it off.

Github uses their own fork of Redcarpet that behaves slightly differently. They have :no_intra_empahasis on, but only when the characters around the _ or * are ASCII, so the above example will produce:

I_love_you<br>
我<strong>愛</strong>你

(Github also adds <br> for newlines, which is why <br> appears in the result).

You can use the github-markdown gem if you want to reproduce Githb’s markdown behaviour exactly.

matt
  • 78,533
  • 8
  • 163
  • 197
  • Thanks for explanation! github-markdown is open source, somehow... I need to figure out how to make no_intra_empahasis only works with ASC-II. Thanks again. – Juanito Fatas Apr 12 '14 at 01:40