26 lines
898 B
Lua
26 lines
898 B
Lua
|
local function isLineIndication(first, middle, last)
|
|||
|
return last.t == 'Str' and string.match(last.c, '^l. [^,]+,?$')
|
|||
|
and middle.t == 'Space'
|
|||
|
and first.t == 'Str' and string.match(first.c, '.+,$')
|
|||
|
end
|
|||
|
|
|||
|
local function isCommaAfterLineIndication(lineIndication)
|
|||
|
return string.match(lineIndication, '.+,$')
|
|||
|
end
|
|||
|
|
|||
|
function Inlines (inlines)
|
|||
|
for i = #inlines, 3, -1 do
|
|||
|
if isLineIndication(inlines[i-2], inlines[i-1], inlines[i]) then
|
|||
|
firstString = inlines[i-2].c
|
|||
|
inlines[i-2].text = string.match(firstString, '^[^,]+')
|
|||
|
if isCommaAfterLineIndication(inlines[i].c) then
|
|||
|
inlines[i].text = string.match(inlines[i].c, '^[^,]+')
|
|||
|
inlines:insert(i+1, pandoc.Str(','))
|
|||
|
end
|
|||
|
inlines[i] = pandoc.Superscript(pandoc.Str(string.sub(inlines[i].text, 5)))
|
|||
|
inlines:remove(i-1)
|
|||
|
end
|
|||
|
end
|
|||
|
return inlines
|
|||
|
end
|