aboutsummaryrefslogtreecommitdiffstats
path: root/warn-info_sections.lua
blob: 40abcc35f2d2e562f44a2bda51d06f34d2e483d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function Heading(lines, meta)
    local warningPattern = "%>% [!WARNING]"
    local infoPattern = "%>% [NOTE]"
    for i, line in ipairs(lines) do
        if line:match(warningPattern) then
            local warning = {}
            for j = 2, #lines do
                table.insert(warning, lines[j])
            end
            table.insert(meta.warning, {text = warning, color = "red"})
        elseif line:match(infoPattern) then
            local info = {}
            for j = 2, #lines do
                table.insert(info, lines[j])
            end
            table.insert(meta.info, {text = info, color = "blue"})
        end
    end
end

return {
    Heading = Heading,
}