vmg / redcarpet

The safe Markdown parser, reloaded.
MIT License
4.99k stars 527 forks source link

Delimiters in link and image title attributes #473

Open wooorm opened 9 years ago

wooorm commented 9 years ago

Note: I posted this on jgm/CommonMark#308 too, in the hope that one of these two projects would update their title rendering to have at least one method in common.

Hey all, I’m currently in the process creating a markdown parser/stringifier (no, not another one, rather, one that focusses on Markdown itself, not HTML :wink:).

During the process of adding CommonMark support, I came across the fact that it is not possible to generate a title attribute, which contains it’s delimiter, which works in Markdown.pl, RedCarpet/GitHub, and CommonMark.

For example:

(The same goes for images.)

I would like entity support to be added to RedCarpet, as that seems to be the most simple addition.

Is there any interest in adding this support?


Support table:

Implementation Characters Nested Mismatched Escaped Named Entities Numbered Entities
Markdown.pl " Yes Yes No Yes Yes
RedCarpet " Yes Yes No No No
CommonMark " No No Yes Yes Yes
Markdown.pl ' Yes Yes No Yes Yes
RedCarpet ' Yes Yes No No No
CommonMark ' No No Yes Yes Yes
Markdown.pl () - - - - -
RedCarpet () - - - - -
CommonMark () No Yes Yes Yes Yes

Fixtures

# Links

## Double quotes

[Hello](./world.html "and text")

[Hello](./world.html "and "matching delimiters"")

[Hello](./world.html "and "mismatched delimiters")

[Hello](./world.html "and \"escapes\"")

[Hello](./world.html "and "named entities"")

[Hello](./world.html "and "numbered entities"")

## Single quotes

[Hello](./world.html 'and text')

[Hello](./world.html 'and 'matching delimiters'')

[Hello](./world.html 'and 'mismatched delimiters')

[Hello](./world.html 'and \'escapes\'')

[Hello](./world.html 'and 'named entities'')

[Hello](./world.html 'and 'numbered entities'')

## Parentheses

[Hello](./world.html (and text))

[Hello](./world.html (and (matching delimiters)))

[Hello](./world.html (and (mismatched delimiters))

[Hello](./world.html (and \(escapes\)))

[Hello](./world.html (and (named entities)))

[Hello](./world.html (and (numbered entities)))

# Images

## Double quotes

![Hello](./world.png "and text")

![Hello](./world.png "and "matching delimiters"")

![Hello](./world.png "and "mismatched delimiters")

![Hello](./world.png "and \"escapes\"")

![Hello](./world.png "and "named entities"")

![Hello](./world.png "and "numbered entities"")

## Single quotes

![Hello](./world.png 'and text')

![Hello](./world.png 'and 'matching delimiters'')

![Hello](./world.png 'and 'mismatched delimiters')

![Hello](./world.png 'and \'escapes\'')

![Hello](./world.png 'and 'named entities'')

![Hello](./world.png 'and 'numbered entities'')

## Parentheses

![Hello](./world.png (and text))

![Hello](./world.png (and (matching delimiters)))

![Hello](./world.png (and (mismatched delimiters))

![Hello](./world.png (and \(escapes\)))

![Hello](./world.png (and (named entities)))

![Hello](./world.png (and (numbered entities)))
victor-homyakov commented 9 years ago

What do dashes in support table mean? I see that nested parentheses are supported by GitHub (RedCarpet), e.g. [example](http://example.com?q=(())): example

wooorm commented 9 years ago

Common mark supports parentheses as delimiters for a title-attribute (see the last section of the examples). RedCarpet/GitHub/Markdown.pl do not. I’m not talking about parentheses in the URL, rather, in or surrounding the title. Sorry for the confusion.