sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 218 forks source link

Emphasis and strong cannot be used in the middle of a word #100

Open ganta opened 11 years ago

ganta commented 11 years ago

I want to use emphasis and strong in the middle of a word.

Example:

abc*def*ghi

abc**def**ghi

Expected Output:

<p>abc<em>def</em>ghi</p>

<p>abc<strong>def</strong>ghi</p>

Actual Output:

<p>abc*def*ghi</p>

<p>abc**def**ghi</p>

This syntax seems to be approved. (Official Markdown project at Daring Fireball: Syntax - Emphasis)

To tell the truth, I expect a side effect. The Japanese language does not have the space between words. If this feature will be supported, we can describe it as follows:

単語を*強調*する。
Elmervc commented 11 years ago

I've been working on improving emph/strong parsing (which caused exponential parse times in certain cases). Currently I'm busy finishing other stuff, so here is some hint for implementing this. It's actually an easy-to-implement extension if it works out as expected.

I think we should make this an extension ALLOW_INWORD_EMPH_STRONG (or better name?) , by making the following 2 checks optional, depending on the extension:

checks that look back for whitespace

I think this will work without causing exponential parse times again. related test files

ganta commented 11 years ago

Thank you for your kind reply:relieved: I am glad that I could know about your improvement. My intention is not to influence performance.

I think that your idea is good. I consider how to implement it. And I will suggest the way or pull request.