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

Short syntax for number identifier doesn't work ([span]{#1010}) #5415

Open
hason opened this issue Apr 1, 2019 · 8 comments
Open

Short syntax for number identifier doesn't work ([span]{#1010}) #5415

hason opened this issue Apr 1, 2019 · 8 comments

Comments

@hason
Copy link

hason commented Apr 1, 2019

Doesn't work (try):

# Header {#101}

[Span]{#1011}

This works (try):

# Header {id=101}

[Span]{id=1011}
@agusmba
Copy link
Contributor

agusmba commented Apr 1, 2019

Note that the header case does not work completely either.

it seems that the number identifier is being mixed with auto identifiers

@mb21
Copy link
Collaborator

mb21 commented Apr 1, 2019

This was implemented like this on purpose, probably since in HTML4 ids couldn't start with a number.

We could change this now, at the risk of increasing the chance of false positives slightly, and potentially breaking a few old documents... given the fact that you can use the mentioned workaround, I'm not sure it's worth it, but why not.

@agusmba The link URLs are a different case... but the attributes are simply not recognised as attributes...

@jgm
Copy link
Owner

jgm commented Apr 2, 2019

It was intentional. If we want to keep this behavior, we should at least document it. A case could be made for allowing identifiers that don't start with letters, but there may be reasons besides HTML4 for requiring the letter. (For example, what about labels in LaTeX?) On the other hand, one could argue that this should be handled by the writer.

@ousia
Copy link
Contributor

ousia commented May 31, 2019

@cactrot
Copy link

cactrot commented Feb 12, 2020

I encountered this and prefixed all div IDs with a letter to produce usable output. Even with the workaround it is still loses the "data-" prefix. There is "--id-prefix=STRING" for "md-->html". I propose making a similar option available for "html-->md".
My motivation is this Elementor example encountered in the field:
<section class="elementor-element elementor-element-91cf889 elementor-section-boxed elementor-section-height-default elementor-section-height-default elementor-section elementor-top-section" data-id="91cf889" data-element_type="section">
pandoc http://www.eminitec.com -o emini.md
::: {#91cf889 .section .elementor-element .elementor-element-91cf889 .elementor-section-boxed .elementor-section-height-default .elementor-section-height-default .elementor-section .elementor-top-section element_type="section"}
pandoc emini.md -o emini.html
<div class="elementor-section-wrap"><p>::: {#91cf889 .section .elementor-element .elementor-element-91cf889 .elementor-section-boxed .elementor-section-height-default .elementor-section-height-default .elementor-section .elementor-top-section element_type=“section”} ::: {.elementor-container .elementor-column-gap-default} ::: {.elementor-row} ::: {#207e3c1 .elementor-element .elementor-element-207e3c1 .elementor-column .elementor-col-100 .elementor-top-column element_type=“column”} ::: {.elementor-column-wrap .elementor-element-populated} ::: {.elementor-widget-wrap} ::: {#c927e60 .elementor-element .elementor-element-c927e60 .elementor-widget .elementor-widget-heading element_type=“widget” widget_type=“heading.default”} ::: {.elementor-widget-container} eMiniTec Hearing Aid Programmer {#eminitec-hearing-aid-programmer .elementor-heading-title .elementor-size-default} ===============================</p></div>

@jgm
Copy link
Owner

jgm commented Feb 12, 2020

We want to produce HTML5 that is also valid XML (for EPUB3 among other things), so that is a good reason to keep the first-letter restriction.

@cactrot your issue is different. Apparently pandoc is converting data-id to id, which it shouldn't do. You should submit a different issue for this. (It's okay for data-foo to go to foo, because pandoc's internal representation of attributes allows anything; but data-X should never go to X when X is a recognized HTML attribute.)

@jgm
Copy link
Owner

jgm commented Feb 12, 2020

Never mind @cactrot, I'll just fix that issue now.

jgm added a commit that referenced this issue Feb 12, 2020
And similarly don't parse any `data-X` as `X` when `X`
is a valid HTML attribute.

Reported in comment on #5415.
@cactrot
Copy link

cactrot commented Feb 12, 2020

Thank you kind sir! Just saw the commit land in the main repo.

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

6 participants