Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GFM] wrong ID generation for headers containing -- #459

Closed
kolyshkin opened this issue Oct 11, 2017 · 3 comments
Closed

[GFM] wrong ID generation for headers containing -- #459

kolyshkin opened this issue Oct 11, 2017 · 3 comments

Comments

@kolyshkin
Copy link
Contributor

kolyshkin commented Oct 11, 2017

Consider the following fragment of an .md file on github:

...
see [--foobar](#option---foobar) option below.
...
## Option --foobar

The above gets rendered by GitHub to the following:

...
see --foobar option below.
...

Option --foobar

Now, if we use kramdown GFM to convert this .md, we'll have the following two problems:

  1. Double dash gets replaced by ndash, which is bad at least in this particular case, and maybe in general, as GitHub's own parser doesn't do it.
  2. The link to "Option --foobar" will not work, as ID for the intralink will be option-foobar rather than github's option---foobar. The reason is the above double-dash -> ndash conversion.

While the first issue is only bad in some specific cases, the second one is really bad as it breaks some intralinks in the resulting document. Perhaps it makes sense to disable double-dash and triple-dash conversion for GFM (say, another option to gfm_quirks)?

@gettalong
Copy link
Owner

gettalong commented Oct 11, 2017

If we change the way link generation works for the GFM parser, it might break existing documents. However, since it is GFM we are talking about and the implementation in kramdown is not quite complete, I would consider such a change a bug fix and not a feature change.

A pull request for this is welcome.

kolyshkin added a commit to kolyshkin/kramdown that referenced this issue Oct 17, 2017
With GFM, we want to be as close as possible to GitHub Flavored
Markdown. In particular, GitHub does not replace -- with en-dash,
--- with em-dash et cetera, and doing this not only breaks
HTML rendering (resulting in, say, –option instead of --option),
but also makes header IDs incompatible with those generated by
GitHub. So, let's turn automatic typographic symbol conversion
by default, and add an option to enable it back.

For more details on the issue and examples, see
gettalong#459

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin added a commit to kolyshkin/kramdown that referenced this issue Oct 17, 2017
With GFM, we want to be as close as possible to GitHub Flavored
Markdown. In particular, GitHub does not replace -- with en-dash,
--- with em-dash et cetera, and doing this not only breaks
HTML rendering (resulting in, say, –option instead of --option),
but also makes header IDs incompatible with those generated by
GitHub. So, let's turn automatic typographic symbol conversion
by default, and add an option to enable it back.

For more details on the issue and examples, see
gettalong#459

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

OK, I have a PR with a patch that apparently works. I'm just not sure about it as my Ruby knowledge is totally non-existent, to say at least.

kolyshkin added a commit to kolyshkin/kramdown that referenced this issue Oct 18, 2017
With GFM, we want to be as close as possible to GitHub Flavored
Markdown. In particular, GitHub does not replace -- with en-dash,
--- with em-dash et cetera, and doing this not only breaks
HTML rendering (resulting in, say, –option instead of --option).

This replacement also makes header IDs incompatible with those
generated by GitHub, making it way harder to create a document
with intralinks that work both on GitHub and kramdown-generated
HTML.

So, let's introduce another GFM quirk to turn off automatic
typographic symbol conversion. NOTE it needs to be explicitly
enabled.

For more details on the issue and examples, see
gettalong#459

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin added a commit to kolyshkin/kramdown that referenced this issue Oct 18, 2017
With GFM, we want to be as close as possible to GitHub Flavored
Markdown. In particular, GitHub does not replace -- with en-dash,
--- with em-dash et cetera, and doing this not only breaks
HTML rendering (resulting in, say, –option instead of --option).

The above replacement also makes header IDs incompatible with those
generated by GitHub, making it way harder to create a document
with intralinks that work both on GitHub and kramdown-generated
HTML.

So, let's introduce another GFM quirk to turn off automatic
typographic symbol conversion. NOTE it is off by default, i.e.
needs to be explicitly enabled.

For more details on the issue and examples, see
gettalong#459

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@gettalong
Copy link
Owner

Pull request #462 is applied.

gettalong pushed a commit that referenced this issue Nov 5, 2017
With GFM, we want to be as close as possible to GitHub Flavored
Markdown. In particular, GitHub does not replace -- with en-dash,
--- with em-dash et cetera, and doing this not only breaks
HTML rendering (resulting in, say, –option instead of --option).

The above replacement also makes header IDs incompatible with those
generated by GitHub, making it way harder to create a document
with intralinks that work both on GitHub and kramdown-generated
HTML.

So, let's introduce another GFM quirk to turn off automatic
typographic symbol conversion. NOTE it is off by default, i.e.
needs to be explicitly enabled.

For more details on the issue and examples, see
#459

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin added a commit to kolyshkin/pages-gem that referenced this issue Dec 9, 2017
Kramdown 1.16 includes GFM quirk `no_auto_typographic
for disabling typographic conversions, which is usable to
fix issues like gettalong/kramdown#459

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants