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

Headers that are all numbers do not create ID attribute #29

Open
bulrush15 opened this issue Jan 8, 2016 · 4 comments
Open

Headers that are all numbers do not create ID attribute #29

bulrush15 opened this issue Jan 8, 2016 · 4 comments

Comments

@bulrush15
Copy link

When converting Markdown to XHTML, this Markdown header:

# 2012

Converts to this: <h1>2012</h1>

when it should convert to: <h1 id="2012">2012</h1>

Any other header that contains at least one letter work properly. I started using 4 digit years for some of my book headers and this bug popped up.

This MD header: # This is a header

Converts properly to: <h1 id="Thisisaheader">This is a header</h1>

The proper (and unique) IDs are required for XHTML when making EPUB books. I take care of the uniqueness.

@pdl
Copy link

pdl commented Jan 8, 2016

Since XHTML does not permit IDs which are wholly numeric, I don't think the behaviour you suggest will help you in the end. You might need some other workaround.

@bulrush15
Copy link
Author

That makes sense. I do have a workaround for this case. But the programmers could prefix or suffix the ID with a letter to make it compatible with XHML, or have an option to do this. As it stands right now, Text::MultiMarkdown is not totally compatible with XHTML.

@pdl
Copy link

pdl commented Jan 9, 2016

It is compatible with XHTML, at least in this respect.

The Text::Multimarkdown module simply recognises that trying to consistently implement the heading IDs feature of MMD would create invalid HTML under certain conditions, and chooses standards compliance over strict consistency, which I think is a reasonable decision given that markdowns are for writing HTML documents.

I don't think there's an obviously better solution here - whatever arbitrary prefix you choose (and it needs to be a prefix, as the restriction is that the ID must begin with a letter) could cause conflicting ids anyway. The MMD test suite doesn't indicate either way what the expected behaviour is. There is an option heading_ids which if false will simply not generate the heading ids, which leaves you free to make your own, and that's what I'd do in this case if I were you.

@bulrush15
Copy link
Author

What I meant was, this is not totally compatible with XHTML for EPUB books. In EPUB, every link destination from the table of contents, like headers, must have a unique ID. (I convert all headers in my MMD to be entries in the EPUB TOC.) To make sure of uniqueness in a whole EPUB book, I append a serial number to each header. So, I do have to do some processing of these all numeric headers after it's converted from MMD to XHTML, and then to EPUB. It's not a big deal, I fixed it on my own. Thanks for the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants