Implementation of “position”
This commit is contained in:
parent
6f8bfeabdf
commit
c4c2526643
|
@ -130,3 +130,5 @@ 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,6 +21,8 @@ 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'
|
||||
|
@ -89,7 +91,7 @@ function add_rendering(config, class,
|
|||
body_text, note_text,
|
||||
docx_body_text, docx_note_text,
|
||||
odt_body_text, odt_note_text,
|
||||
csname)
|
||||
csname, position)
|
||||
-- The values are plain strings (not the empty string!) or nil.
|
||||
config[class] = {
|
||||
body_text = body_text,
|
||||
|
@ -98,7 +100,8 @@ 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
|
||||
csname = csname,
|
||||
position = position
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -125,7 +128,8 @@ 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['csname']),
|
||||
meta_to_str(this_value['position']) or POS_DEFAULT
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -526,6 +530,7 @@ 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
|
||||
|
@ -536,7 +541,19 @@ local function render_margin_notes(span)
|
|||
body = render_body(span.content, span.attributes)
|
||||
end
|
||||
span.content = body
|
||||
return { span, unpack_table(margin_note) }
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user