Search code examples
markdownmiddleman

Stop ids being added to headings in output in Middleman?


I'm using Markdown partials in my Middleman project - and just noticed that all my headings are being output with ids generated from the heading markup.

So for example a linked heading:

Markdown:

### [Useful reference sites](/webdev/useful-reference "Links to other sites")

Output html:

<h3 id="useful-reference-siteswebdevuseful-reference-links-to-other-sites">...</h3>

It's concatenating everything including contents of the anchor tag title attribute, so some ids can get ridiculously long. I'd like to 'turn-off' this feature if possible.

I can't see anything in the core config list where I could do this, nor can I find info suggesting there's a helper for this kind of thing - but may be one exists?

In short, is there a way to do this without much ruby knowledge?

Any help would be much appreciated, Thanks.

Some info about the project set up:

  • Middleman (3.3.7)
  • extensions: middleman blog, nav-tree
  • templates in Haml
  • content partials in Markdown

Solution

  • By default, Middleman uses Kramdown for Markdown parsing.

    The option that Kramdown uses to generate ids, is auto_ids.

    So what you have to do is to set that option to false in Middleman's config.rb:

    set :markdown, auto_ids: false