-
Notifications
You must be signed in to change notification settings - Fork 14
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
Specifying a header ID that starts with a number is ignored #26
Comments
What I meant was: It is the expected behaviour when using the kramdown parser and the HTML converter. Since you are using the GFM parser and HTML converter, you might get different results. |
Indeed; I'm just saying I don't know why it's the expected behavior. What is the reason behind this behavior? It seems it must have been intentional. And then what's the reason for the difference in behavior between the binary and the GFM parser? |
The binary just uses whatever parser/converter pair you specify. If you specify GFM+HTML, you will get the same output as on Jekyll. The difference in behaviour might be because of differences between the kramdown syntax and the GFM syntax. Also see parser-gfm/lib/kramdown/parser/gfm.rb Line 111 in f1012be
|
When I say "reason", I'm asking about the human decision to have this behavior, not what code causes it to manifest this way, though I will definitely look more carefully through the file you linked to; thank you! Why did a human being decide that an ID can't start with a number? |
This is due to the way HTML4 specified the ID attribute. Also of interest: gettalong/kramdown@90954bc |
Please forgive me if this is intended behavior, perhaps following a spec somewhere, but it seems that kramdown will autogenerate IDs that start with a number, but it will not respect manually specifying IDs. I don't see my usecase disclaimed under Specifying a Header ID. I'm cross-posting from gettalong/kramdown#711, where @gettalong suggested that this was expected behavior using the kramdown binary, but I'm still not 100% sure why, particularly because of the automatic generation of header IDs and how that differs from the behavior using the binary.
Autogeneration of ID for headings starting with numbers works
For example:
yields
as expected. (The example remains true for header text that is purely numeric, such as
## 123
.)(Although, I didn't understand how to reconcile that with the HTML Converter documentation for "Automatic Generation of Header IDs", which suggested that I should expect a different result.)
Specifying a custom header ID works for headings starting with
[a-z]
And
and
both yield
also as expected.
Specifying a custom header ID starting with
[0-9]
does not workSo here's where I get the unexpected behavior:
yields
and
yields
Of course, I was expecting the following in both of the two examples immediately above:
I'm gathering that kramdown is ignoring manually specified header IDs when they start with numbers (since even adding
[a-z]
characters later in the ID doesn't help).Context
I'm using GitHub Pages, and my
Gemfile.lock
file specifies the following undergithub-pages (213)
:And under
jekyll (3.9.0)
:and then also
My
_config.yml
includes the following lines:I noticed that I didn't have a
markdown: kramdown
specified, but adding that in didn't change the behavior, so I'm thinking that maybe that becomes implicit if there's akramdown
object specified.FWIW, I've also confirmed the same behavior on this online kramdown editor/renderer, so it doesn't seem to be specific to a GitHub Pages or Jekyll implementation.
It's a lot easier to see effects immediately if you include a TOC block:
The text was updated successfully, but these errors were encountered: