Skip to content

Instantly share code, notes, and snippets.

@CLRafaelR
Last active September 12, 2021 08:04
Show Gist options
  • Save CLRafaelR/1258900ac8ae68c9e7d016900c086b5c to your computer and use it in GitHub Desktop.
Save CLRafaelR/1258900ac8ae68c9e7d016900c086b5c to your computer and use it in GitHub Desktop.
Pandoc lua-filter for `\alert{...}` in beamer presentation

You can use the following lua filter (say, alert.lua) when you produce a beamer presentation.

if FORMAT:match 'beamer' then
    function Span(el)
        if el.classes[1] == "alert" then
            table.insert(el.content, 1, pandoc.RawInline("latex", "\\alert{"))
            table.insert(el.content, pandoc.RawInline("latex", "}"))
        end
        return el
    end
    return { { Span = Span } }
end

In an md file, [what you want to highlight]{.alert} is the command to produce a text with an alert. Note that you need to enclose the text with square bracket [...], not (...).

## frame header

- This is important
- This is also important
- This is [the most important]{.alert} line

Then, your md is converted into a beamer presentation pdf with alerts.

pandoc --lua-filter=alert.lua -t beamer presentation.md -o presentation.pdf

This gist is originnaly posted as a reply to the issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment