Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion pandoc-ling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ local latexPackage = "linguex"
local topDivision = "section"
local noFormat = false
local documentclass = "article"
local abbreviations = {} -- default abbreviations

function getUserSettings (meta)
if meta.formatGloss ~= nil then
formatGloss = meta.formatGloss
end
-- Load user provided glossing abbreviations, overriding any default abbreviations
if meta.pandocLingAbbreviations ~= nil then
for k, v in pairs(meta.pandocLingAbbreviations) do
abbreviations[k] = pandoc.utils.stringify(v)
end
end
if meta.samePage ~= nil then
samePage = meta.samePage
end
Expand Down Expand Up @@ -451,6 +458,15 @@ end
-- helper functions for (lists of) inlines
------------------------------------------

local abbreviationFormatter = {
html = function(gloss, full)
return pandoc.RawInline("html", string.format(
'<abbr title="%s">%s</abbr>',
full,
pandoc.text.lower(gloss)))
end,
}

function formatGlossLine (s)
-- turn uppercase in gloss into small caps
local split = {}
Expand All @@ -459,7 +475,11 @@ function formatGlossLine (s)
lower = pandoc.Str(lower)
table.insert(split, lower)
end
upper = pandoc.SmallCaps(pandoc.text.lower(upper))
if abbreviations[upper] ~= nil and abbreviationFormatter[FORMAT] ~= nil then
upper = pandoc.SmallCaps(abbreviationFormatter[FORMAT](upper, abbreviations[upper]))
else
upper = pandoc.SmallCaps(pandoc.text.lower(upper))
end
table.insert(split, upper)
end
for leftover in string.gmatch(s, "[%u%d]+([‑%-][^‑%-]-%l+)$") do
Expand Down