Compare commits
No commits in common. "2f93c19908d9cd337d29642ee2ce0405b41f7d98" and "6f8bfeabdf586d67db9c9f138c9a56e91564a353" have entirely different histories.
2f93c19908
...
6f8bfeabdf
|
@ -3,7 +3,6 @@
|
|||
A collection of Lua filters for [Pandoc](https://pandoc.org/), mainly
|
||||
targeting academic wrinting in social sciences and the humanities.
|
||||
|
||||
All filters are under the MIT License, except those under `/misc`,
|
||||
which are trivial scripts in the public domain.
|
||||
Issues and pull requests are wellcome: you can register via
|
||||
All filters are under the MIT License. Issues and pull requests are
|
||||
wellcome: you can register via
|
||||
[OpenID](https://en.wikipedia.org/wiki/OpenID).
|
||||
|
|
|
@ -130,5 +130,3 @@ mrgnn-define-renderings:
|
|||
|
||||
In that case, you will have to define `\mrgnnTerm` in your LaTeX or ConTeXt template. This macro takes one argument, which is the result of the processing of `note-text`.
|
||||
|
||||
The position of the instructions about the marginal note in the output file can be set _via_ the variable `position`. They can be placed `after` (default) or `before` the in-text content.
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ local PLACEHOLDER_REGEX = PLACEHOLDER_BEGIN ..
|
|||
PLACEHOLDER_LABEL .. PLACEHOLDER_END
|
||||
-- String indicating an indefined value in the output
|
||||
local UNDEFINED = '??'
|
||||
-- Default value for "position" ("before" or "after").
|
||||
local POS_DEFAULT = 'after'
|
||||
|
||||
local DOCX_TOOLTIP_ANCHOR = '*'
|
||||
local DOCX_TOOLTIP_ANCHOR_SYTLE = 'Tooltip anchor'
|
||||
|
@ -91,7 +89,7 @@ function add_rendering(config, class,
|
|||
body_text, note_text,
|
||||
docx_body_text, docx_note_text,
|
||||
odt_body_text, odt_note_text,
|
||||
csname, position)
|
||||
csname)
|
||||
-- The values are plain strings (not the empty string!) or nil.
|
||||
config[class] = {
|
||||
body_text = body_text,
|
||||
|
@ -100,8 +98,7 @@ function add_rendering(config, class,
|
|||
docx_note_text = docx_note_text,
|
||||
odt_body_text = odt_body_text,
|
||||
odt_note_text = odt_note_text,
|
||||
csname = csname,
|
||||
position = position
|
||||
csname = csname
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -128,8 +125,7 @@ local function get_renderings_config(meta)
|
|||
or this_value['body-text']),
|
||||
meta_to_str(this_value['odt-note-text']
|
||||
or this_value['note-text']),
|
||||
meta_to_str(this_value['csname']),
|
||||
meta_to_str(this_value['position']) or POS_DEFAULT
|
||||
meta_to_str(this_value['csname'])
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -530,7 +526,6 @@ local function render_margin_notes(span)
|
|||
if span.classes:includes(class_name) then
|
||||
local render_note = config[class_name].render.note
|
||||
local render_body = config[class_name].render.body
|
||||
local note_position = config[class_name].position
|
||||
local margin_note = {}
|
||||
local body = {}
|
||||
if render_note then
|
||||
|
@ -541,19 +536,7 @@ local function render_margin_notes(span)
|
|||
body = render_body(span.content, span.attributes)
|
||||
end
|
||||
span.content = body
|
||||
local span_with_note = {}
|
||||
if note_position == 'before' then
|
||||
span_with_note = margin_note
|
||||
insert_in_table(span_with_note, span)
|
||||
elseif note_position == 'after' then
|
||||
span_with_note = { span, unpack_table(margin_note) }
|
||||
else
|
||||
error('Invalid value "' .. note_position .. '" ' ..
|
||||
'for "position" in the definition of ' ..
|
||||
'the margin-note class "' .. class_name '". ' ..
|
||||
'Expected "before" or "after".')
|
||||
end
|
||||
return span_with_note
|
||||
return { span, unpack_table(margin_note) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
function Str (s)
|
||||
if string.match(s.text, '[0-9mdclxviA-C]+–[0-9mdclxviB-D]+') then
|
||||
return pandoc.Str(string.gsub(s.text, '–', '-'))
|
||||
end
|
||||
end
|
|
@ -1,31 +0,0 @@
|
|||
-- Transforme une espace insécable normale en espace fine insécable
|
||||
-- selon les conventions de la typographie française.
|
||||
|
||||
-- Lorsqu'un point-virgule est protégé dans une citation, il est représenté
|
||||
-- comme un objet Str à lui tout seul dans l'AST. La fonction Inlines sert
|
||||
-- à normaliser cette séquence avant le traitement par la fonction Str et
|
||||
-- prévient d'autres anomalies de ce type.
|
||||
|
||||
function Inlines(inlines)
|
||||
for i = #inlines-1, 2, -1 do
|
||||
if inlines[i].t == "Str" and string.match(inlines[i].text, "^[;!?]$")
|
||||
and inlines[i-1].t == "Str" and string.match(inlines[i-1].text, ".* $")
|
||||
then
|
||||
inlines[i-1].text = inlines[i-1].text .. inlines[i].text
|
||||
inlines:remove(i)
|
||||
end
|
||||
end
|
||||
return inlines
|
||||
end
|
||||
|
||||
function Str(elem)
|
||||
if string.match(elem.text, ".* [;!?]$") then
|
||||
new, _ = string.gsub(elem.text, " ([;!?])", utf8.char(8239) .. "%1")
|
||||
return pandoc.Str(new)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{ Inlines = Inlines },
|
||||
{ Str = Str }
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
--[[
|
||||
When a long footnote is inserted like this^[
|
||||
Here is my footnote.
|
||||
It spans several lines!
|
||||
], Pandoc retains the initial line break in the AST,
|
||||
causing the insertion of a space
|
||||
at the beginning of the footnote in the output.
|
||||
This filter removes any line break
|
||||
at the beginning of a footnote.
|
||||
]]--
|
||||
|
||||
function Note(note)
|
||||
local content = note.content[1].content
|
||||
if content[1].t == 'SoftBreak' then table.remove(content, 1) end
|
||||
return note
|
||||
end
|
Loading…
Reference in New Issue
Block a user