About Social Code
summaryrefslogtreecommitdiff
path: root/tools/note.lua
blob: 0d3aff32c1af43ef0edf519ea6d44386d9740946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local stringify = (require 'pandoc.utils').stringify

local status_map = {"seadling", "budding", "evergreen"}

function Pandoc(doc)
    doc.meta["main_class"] = "html-note-page"
    doc.meta["main_container"] = "main-container"
    doc.meta["front_page"] = false

    local status = stringify(doc.meta["status"])
    local status_name = status_map[tonumber(status)]
    local text = pandoc.Para(status_name)
    local image = pandoc.RawBlock("html", string.format("<img src=\"/assets/%s.svg\">", status_name))

    local status_div = pandoc.Div({text})
    status_div.classes = {"plant-status-text"}
    local div = pandoc.Div({image, status_div})
    div.classes = {"plant-status"}

    local status_info = pandoc.MetaBlocks(div)
    doc.meta["note_status"] = status_info
    return pandoc.Pandoc(doc.blocks, doc.meta)
end