csl-clio/Filtres-Pandoc/lines-in-exponent.lua~

26 lines
898 B
Lua
Raw Normal View History

2021-04-15 22:02:49 +01:00
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