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

PrefixHeaderId does not accept forward slashes #409

Closed
baileyherbert opened this issue Jul 19, 2017 · 6 comments
Closed

PrefixHeaderId does not accept forward slashes #409

baileyherbert opened this issue Jul 19, 2017 · 6 comments
Assignees

Comments

@baileyherbert
Copy link

baileyherbert commented Jul 19, 2017

An id attribute value may, according to HTML5 and in browser practice, contain any characters except space characters.

In showdown, passing a forward slash in as an ID prefix, like this:

{
  prefixHeaderId: "/layout/"
}

Yields a very unexpected result. Instead of generated IDs looking like id="/layout/simplified-header-text" it looks instead like id="layoutsimplified-header-text".

Is there an easy workaround to this?

@tivie
Copy link
Member

tivie commented Jul 19, 2017

According to the HTML spec:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

@baileyherbert
Copy link
Author

baileyherbert commented Jul 19, 2017

Is showdown still living in HTML4, then? That link is HTML4.

Here's the direct quote from W3 HTML5 specification:

The value must not contain any space characters.

and

There are no other restrictions on what form an ID can take; in particular, IDs can consist of just digits, start with a digit, start with an underscore, consist of just punctuation, etc.

@tivie
Copy link
Member

tivie commented Jul 19, 2017

Showdown supports both HTML4 and HTML5 spec (with some restrictions).

@tivie tivie self-assigned this Jul 19, 2017
@tivie
Copy link
Member

tivie commented Jul 19, 2017

I don't know how we could make showdown compliant with HTML4 and HTML5, honestly

tivie added a commit that referenced this issue Aug 6, 2017
This option removes only spaces, ' and " from generated Header IDs,
replacing them with dashes. This might generate malformed IDs.

Closes #409
tivie added a commit that referenced this issue Aug 6, 2017
…g the prefix

Setting this option to true will prevent showdown from modifying the
prefix. This might result in malformed IDs (if, for instance, the " char is
used in the prefix). Has no effect if prefixHeaderId is set to false.

Closes #409
@tivie
Copy link
Member

tivie commented Aug 6, 2017

@baileyherbert You now have 2 options to fix this:

  • use option rawHeaderId which removes only spaces, ' and " from titles.
  • use option rawPrefixHeaderId which leaves the prefix alone (doesn't change any character from the prefix)

Keep in mind that both options might result in malformed IDs. For instance, when you use rawPrefixHeaderId and use a prefix with " or

@baileyherbert
Copy link
Author

Yup, working perfect now. Thanks!

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