aboutsummaryrefslogtreecommitdiff
path: root/Info/9/3/Planet/pandoc/center-img.lua
blob: 86fa288851a6116b6df6c3a9f3a68b158f3feb6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- Based on:
-- https://pandoc.org/lua-filters.html#center-images-in-latex-and-html-output
-- Licensed under MIT License found at:
-- https://github.com/TomBener/pandoc-templates/blob/05aba224519d8a2b037108948bde0d820860b786/LICENSE
-- Filter images with this function if the target format is HTML
if FORMAT:match 'html' then
  function Image (elem)
    if elem.classes[1] == 'center' then
      -- Use CSS style to center image
      elem.attributes.style = (elem.attributes.style or '') .. ';margin:auto; display: block;'
    end
    return elem
  end
end