hamdown icon indicating copy to clipboard operation
hamdown copied to clipboard

Define usage of ambiguous symbols (eg. #, -)

Open joallard opened this issue 7 years ago • 4 comments

From the Readme:

An example of conflict is "#" symbol. It is used in Haml for id attribute, and in Markdown as headers.

A quick solution might be to prohibit ids in Haml part of Hamdown. A smarter solution would be to treat #person_233 Max as Haml, and # Max as Markdown

My suggestion below.

joallard avatar Jun 14 '18 19:06 joallard

Number sign (#)

If a line starts with #, it is treated as a Markdown header. Hence #person_233.person would be treated as an h1.

If one wants to use the Haml id shorthand, explicitly name the %div tag, as in %div#person_233.

Hyphen-minus (-)

If a line starts with -, it is treated as embedded code (Haml), not as a list (Markdown).

If you need to make a list, use the asterisk (*) character.

joallard avatar Jun 14 '18 19:06 joallard

Thanks! I was thinking about it and came to the same conclusions!

inem avatar Jun 14 '18 19:06 inem

Re: the heading sign, I'm not sure how Markdown parsers in Ruby implements this, but both CommonMark and GitHub Flavored Markdown needs a space between the hash signs and the content of the heading.

So the original solution is achieved without compromising either language: #person_233 Max would be picked up by Haml but rejected by Markdown, and # heading 1 would be picked up by Markdown but rejected by Haml.

miyuchina avatar Jun 14 '18 21:06 miyuchina

I feel like we'll need to attack paragraph semantics next

joallard avatar Jun 15 '18 18:06 joallard