Transforme les divs de pandoc en admonition
Some checks failed
continuous-integration/drone/push Build is failing
Build and Push MkDocs Docker Image / build-and-push (push) Successful in 2m18s

This commit is contained in:
2025-06-30 23:36:44 +02:00
parent 95dadee345
commit 7a021838f1
7 changed files with 80 additions and 3 deletions

View File

@@ -0,0 +1,27 @@
-- admonition.lua
-- Filtre Pandoc : transforme les divs en admonitions type "!!! note"
function Div(div)
if div.classes ~= nil and #div.classes > 0 then
local class = div.classes[1]
-- Génère le préfixe admonition
local admonition_header = pandoc.Plain{pandoc.Str("!!! " .. class)}
local contents = {}
-- Pour chaque bloc de contenu, ajoute une indentation de 4 espaces à chaque ligne
for _, blk in ipairs(div.content) do
local s = pandoc.write(pandoc.Pandoc({blk}), "markdown")
-- Ajoute une indentation de 4 espaces sur chaque ligne non vide
s = s:gsub("([^\n]+)", " %1")
table.insert(contents, pandoc.RawBlock("markdown", s))
end
-- Construit la nouvelle sequence de blocs : en-tête + contenus
local blocks = {admonition_header}
for _, blk in ipairs(contents) do
table.insert(blocks, blk)
end
return blocks
end
end

View File

@@ -0,0 +1,11 @@
::: { .note }
Ceci est une note
:::
::: { .warning }
Ceci est un warning
:::