Skip to content

Create a customised environment #7864

Answered by cscheid
ChrisJefferson asked this question in Q&A
Discussion options

You must be logged in to vote

The easiest way will be for you to write a Lua filter that catches a div with certain classes and attributes.

The syntax you attempted is not valid Markdown. You'll need something like this instead:

---
title: test
filters:
  - alert.lua
---

::: {.alert name="teacher.png"}

content

:::
-- alert.lua
function Div(div)
  if not div.classes:includes("alert") then
    return nil
  end
  local result = pandoc.Div({})
  result.classes = pandoc.List({"alert", "alert-primary", "d-flex", "align-items-center"})
  local inner = pandoc.Div({})
  inner.classes = pandoc.List({"bi", "flex-shrink-0", "me-2"})
  inner.attributes.width = "24px"
  inner.attributes.height = "24px"
  result.content:insert(inner

Replies: 1 comment 1 reply

Comment options

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

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