1

I'm building a static website with Hakyll and I'm using the PandocCompiler to compile markdown to html. This works perfectly, but the compiler takes this:

# Heading 1

and compiles it to

<h1>Heading 1</h1>

This is the expected result. However, I'd like to start at a lower heading, say, <h3>, so that:

# Heading 1

compiles to

<h3>Heading 1</h3>

and this:

## Heading 2

compiles to

<h4>Heading 2</h4>

and so on.

I could of course change the markdown itself, but I have many files and it would be a lot of work, and it would make the markdown a bit uglier.

Any ideas on how to do this?

Ben
  • 1,561
  • 4
  • 21
  • 33
  • 2
    Whoever voted to close as "about general computing hardware and software" doesn't know what Hakyll is and didn't bother to check. – duplode Oct 06 '15 at 20:40
  • Possible alternative: instead of translating `# Heading 1` to `

    `, you might consider changing your CSS to make `h1`'s less pronounced. (Though I recognize there can also be legitimate reasons to avoid `h1` entirely.)

    – Daniel Wagner Oct 06 '15 at 23:07
  • 1
    @DanielWagner I use h1 in the templates as a more general header title, and then want my markdown to generate the body. In other words, I do need the h1 too. – Ben Oct 06 '15 at 23:08

1 Answers1

1

The Hakyll.Web.Html module includes some useful functions for HTML manipulation, including a demoteHeaders which should be enough for your needs. It is also worth noting that the withTags function there allows convenient usage of tagsoup for arbitrary manipulation of HTML tags.

duplode
  • 33,731
  • 7
  • 79
  • 150