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

Back ticks in titles (incorrectly?) converted to hypens #510

Closed
bduncanj opened this issue Nov 14, 2014 · 4 comments · Fixed by #456
Closed

Back ticks in titles (incorrectly?) converted to hypens #510

bduncanj opened this issue Nov 14, 2014 · 4 comments · Fixed by #456

Comments

@bduncanj
Copy link

Smashing library, much thanks!

I may be abusing markdown a little, but I'm using code back ticks in my titles:

## Messages
### `system-alarm-start`
### `system-alarm-end`

This however produces HTML in which the backtick is replaced with a hyphen in the id attribute of the resulting header element:

<h2 id="messages">Messages</h2>
<h3 id="-system-alarm-start-"><code>system-alarm-start</code></h3>
<h3 id="-system-alarm-end-"><code>system-alarm-end</code></h3>

The problem is that I'm using marked-toc to convert this into the following markdown TOC (and then HTML via marked) which of course is now incompatible as that package just ignores the back ticks in the headers:

* [Messages](#messages)
  * [`system-alarm-start`](#system-alarm-start)
  * [`system-alarm-end`](#system-alarm-end)

... and finally ...

<ul>
<li><a href="#messages">Messages</a><ul>
<li><a href="#system-alarm-start"><code>system-alarm-start</code></a></li>
<li><a href="#system-alarm-end"><code>system-alarm-end</code></a></li>
</ul>
</li>
</ul>
@Feder1co5oave
Copy link
Contributor

I, too, rely heavily on hashes.

The naive solution is to override the heading renderer and generate ids in the same way marked-toc does.

See related issues #432 #450. The problem extends far beyond leading/trailing slashes.
I think I proposed a reasonable solution in #456. Feel free to merge it. Notice that you can then override the heading renderer and possibly use uslug to generate id attributes.

@F1LT3R
Copy link

F1LT3R commented Mar 10, 2015

+1 to fixing this out of the box

@franciscop
Copy link

+1. I'd go a bit further and say that leading/trailing hyphens should be removed as well:

# Hello!
# How to fix X?
<h1 id="hello-">Hello!</h1>
<h1 id="how-to-fix-x-">How to fix X?</h1>

@joshbruce
Copy link
Member

#981

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

Successfully merging a pull request may close this issue.

5 participants