Currently, if a static ID contains special characters, such as ' " < >, these are passed through as-is to the resulting HTML output. This can cause errors when these interrupt the HTML syntax, as shown in the following example:
Markdown:
### A heading can't include apostrophes
{: #a-heading-can't-include-apostrophes}
Text
This transforms as below, and then it affects the spacing of attributes in following sections.
<section id="section-a-heading-can" t-include-apostrophes '><h3 id="a-heading-can't-include-apostrophes ">A heading can't include apostrophes</h3>
<p>Text</p>
</section>
In the auto-generated heading IDs (i.e., headings with no static IDs defined), these characters are simply skipped (not included in the output ID), and so do not result in these issues. One solution might be to take a similar approach when processing the static IDs.
Other test cases below:
# Testing out ID generation with special characters
## With static IDs
### What do I do if my heading has a question mark?
{: #what-do-I-do-if-my-heading-has-a-question-mark?}
Text
### A heading can't include apostrophes
{: #a-heading-can't-include-apostrophes}
Text
### A heading "supposedly" can contain quotes
{: #a-heading-"supposedly"-can-contain-quotes}
Text
### Let me tell you about the <section> element
{: #let-me-tell-you-about-the-<section>-element}
Text
### I <3 headings
{: #i-<3-headings}
Text
## Without static IDs
### What do I do if my heading has a question mark?
Text
### A heading can't include apostrophes
Text
### A heading "supposedly" can contain quotes
Text
### Let me tell you about the <section> element
Text
### I <3 headings
Text
Currently, if a static ID contains special characters, such as
' " < >, these are passed through as-is to the resulting HTML output. This can cause errors when these interrupt the HTML syntax, as shown in the following example:Markdown:
### A heading can't include apostrophes {: #a-heading-can't-include-apostrophes} TextThis transforms as below, and then it affects the spacing of attributes in following sections.
In the auto-generated heading IDs (i.e., headings with no static IDs defined), these characters are simply skipped (not included in the output ID), and so do not result in these issues. One solution might be to take a similar approach when processing the static IDs.
Other test cases below: