New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delimiters in link and image title attributes #308

Closed
wooorm opened this Issue Mar 5, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@wooorm

wooorm commented Mar 5, 2015

Hey all, I鈥檓 currently in the process creating a markdown parser/stringifier (no, not another one, rather, one that focusses on Markdown itself, not HTML 馃槈).

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鈥檚 delimiter, which works in Markdown.pl, GitHub, and CommonMark.

For example:

  • [Hello](./world.html "and "matching delimiters"") works in Markdown.pl and on GitHub, but not in CommonMark;
  • [Hello](./world.html "and \"escapes\"") works in CommonMark, but not in Markdown.pl or on GitHub;
  • [Hello](./world.html "and "named entities"") works in CommonMark and Markdown.pl, but not on GitHub.

(The same goes for images.)

I understand CommonMark鈥檚 stand: it supports escapes and entities, to me the most logical ways to nest delimiters.

However, as those are not (universally) supported on other major systems, and because CommonMark is not yet at 1.0.0, I want to propose added support for nested (both matching and non-matching) delimiters, at least for double and single quotes.

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
GitHub " Yes Yes No No No
CommonMark " No No Yes Yes Yes
Markdown.pl ' Yes Yes No Yes Yes
GitHub ' Yes Yes No No No
CommonMark ' No No Yes Yes Yes
Markdown.pl () - - - - -
GitHub () - - - - -
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)))
@wooorm

This comment has been minimized.

Show comment
Hide comment
@wooorm

wooorm Mar 5, 2015

Note! I just posted this on vmg/redcarpet#473 too, in the hope that one of these two projects would update their title rendering to have at least one method in common.

wooorm commented Mar 5, 2015

Note! I just posted this on vmg/redcarpet#473 too, in the hope that one of these two projects would update their title rendering to have at least one method in common.

@jgm

This comment has been minimized.

Show comment
Hide comment
@jgm

jgm Mar 5, 2015

Member

I trust you saw this rationale in the spec:

(Note: Markdown.pl did allow double quotes inside a double-quoted title, and its test suite included a test demonstrating this. But it is hard to see a good rationale for the extra complexity this brings, since there are already many ways鈥攂ackslash escaping, entities, or using a different quote type for the enclosing title鈥攖o write titles containing double quotes. Markdown.pl鈥檚 handling of titles has a number of other strange features. For example, it allows single-quoted titles in inline links, but not reference links. And, in reference links but not inline links, it allows a title to begin with " and end with ). Markdown.pl 1.0.1 even allows titles with no closing quotation mark, though 1.0.2b8 does not. It seems preferable to adopt a simple, rational rule that works the same way in inline links and link reference definitions.)

Specifying a syntax that allows indefinitely nested paired quotes, and implementing this in an efficient way, doesn't seem to me to be worth it, given how rarely this is needed and given the availability of several alternative methods for including quotes in titles.

If you're just looking for a way to render a title containing a quotation mark into Markdown in a way that will work with multiple Markdown implementations, may I suggest using "?

Member

jgm commented Mar 5, 2015

I trust you saw this rationale in the spec:

(Note: Markdown.pl did allow double quotes inside a double-quoted title, and its test suite included a test demonstrating this. But it is hard to see a good rationale for the extra complexity this brings, since there are already many ways鈥攂ackslash escaping, entities, or using a different quote type for the enclosing title鈥攖o write titles containing double quotes. Markdown.pl鈥檚 handling of titles has a number of other strange features. For example, it allows single-quoted titles in inline links, but not reference links. And, in reference links but not inline links, it allows a title to begin with " and end with ). Markdown.pl 1.0.1 even allows titles with no closing quotation mark, though 1.0.2b8 does not. It seems preferable to adopt a simple, rational rule that works the same way in inline links and link reference definitions.)

Specifying a syntax that allows indefinitely nested paired quotes, and implementing this in an efficient way, doesn't seem to me to be worth it, given how rarely this is needed and given the availability of several alternative methods for including quotes in titles.

If you're just looking for a way to render a title containing a quotation mark into Markdown in a way that will work with multiple Markdown implementations, may I suggest using "?

@jgm

This comment has been minimized.

Show comment
Hide comment
@jgm

jgm Mar 5, 2015

Member

Oh, I see from your table that github's renderer doesn't like entities in titles. Well, that seems a clear bug in redcarpet (one of many) and should be fixed there.

Member

jgm commented Mar 5, 2015

Oh, I see from your table that github's renderer doesn't like entities in titles. Well, that seems a clear bug in redcarpet (one of many) and should be fixed there.

@wooorm

This comment has been minimized.

Show comment
Hide comment
@wooorm

wooorm Mar 5, 2015

I completely agree! TBH, I hope RedCarpet will fix entities, like what you suggest, and stated above in Support table, rather than adding support for nested literal entities鈥攕ee the referenced issue on vmg/redcarpet. However, I鈥檓 not sure they will do so quickly.

wooorm commented Mar 5, 2015

I completely agree! TBH, I hope RedCarpet will fix entities, like what you suggest, and stated above in Support table, rather than adding support for nested literal entities鈥攕ee the referenced issue on vmg/redcarpet. However, I鈥檓 not sure they will do so quickly.

@wooorm

This comment has been minimized.

Show comment
Hide comment
@wooorm

wooorm Mar 5, 2015

Just saw your comment, great you saw it. Again, I hope RedCarpet will fix this!

wooorm commented Mar 5, 2015

Just saw your comment, great you saw it. Again, I hope RedCarpet will fix this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment