csl-clio/Filtres-Pandoc/suppress-column-label-patrologia.lua
2022-01-09 22:01:00 +01:00

53 lines
1.9 KiB
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.

--[[
************************************************************************
* Copyright 2021 by Bastien Dumont (bastien.dumont@posteo.net)
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file. If not, see <https://www.gnu.org/licenses/>.
*
************************************************************************
]]--
local function isPatrologiaReference(first, second, third, last)
return first.t == 'Emph'
and (
(
#first.content == 3
and string.match(first.content[1].text, '^Patrologi[ea]$')
and first.content[2].t == 'Space'
and first.content[3].t == 'Str'
and string.match('|grecque|Graeca|latine|Latina|orientale|orientalis|', '|' .. first.content[3].text .. '|')
)
or
(
#first.content == 1
and first.content[1].t == 'Str'
and string.match('|PG|PL|PO|', '|' .. first.content[1].text .. '|')
)
)
and (second.t == 'Str'
and string.match(second.text, '^ [0-9]+,$')
and third.t == 'Space'
and last.t == 'Str'
and string.match(last.text, '^col. $'))
end
function Inlines (inlines)
for i = #inlines, 6, -1 do
if isPatrologiaReference(inlines[i-3], inlines[i-2], inlines[i-1], inlines[i]) then
inlines:remove(i)
end
end
return inlines
end