csl-clio/Filtres-Pandoc/lines-in-exponent.lua~
2021-04-15 23:02:49 +02:00

26 lines
898 B
Lua
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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