Question

I'm using Maruku as a markdown filter in HAML, and it creates huge useless (for me) IDs on every single header.

So if I have something like this

## This is a header

It'll make

<h2 id="this_is_a_header">This is a header</h2>

Which at a certain point starts to become ridiculous, and populates my HTML with a bunch of IDs I do not need, nor want, since Maruku provides me with a way to provide my own IDs,

## {#id} This is a header

Is there any way to prevent it's behaviour?

Was it helpful?

Solution

Maruku is obsolete and instead you should consider switching over to kramdown (now MIT-licensed).

kramdown allows you to switch off auto-generation of header IDs like so:

puts Kramdown::Document.new("# Header with spaces #", :auto_ids => false).to_html

Also in kramdown, if you want to set your own ID attribute on the header, you can do the following:

raw_text = "# Header with spaces #
  {: #pumice-stone}"

puts Kramdown::Document.new(raw_text, :auto_ids => false).to_html

Output:

<h1 id="pumice-stone">Header with spaces</h1>

Keep in mind the custom attribute ({: #pumice-stone}) follows on the line directly under the block level element you wish to apply it to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top