Skip to content
Discussion options

You must be logged in to vote

Here's a Pandoc filter that does this:

-- Shift header levels within a marked container div
-- Usage: ::: {.shift-headings by=1}
--        {{< include file.md >}}
--        :::

function Div(el)
  if el.classes:includes("shift-headings") then
    local shift = tonumber(el.attributes["by"]) or 1
    return el:walk({
      Header = function(h)
        h.level = h.level + shift
        return h
      end
    })
  end
end

Usage:

::: {.shift-headings by=1}
{{< include _foo.md >}}
:::

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@rben01
Comment options

@cscheid
Comment options

@gadenbuie
Comment options

@rben01
Comment options

Comment options

You must be logged in to vote
1 reply
@cscheid
Comment options

Comment options

You must be logged in to vote
1 reply
@mcanouil
Comment options

Answer selected by mcanouil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
includes lua Issues related to the lua codebase, filter chain, etc
7 participants