The span id is attached to the note whenever possible
This commit is contained in:
@ -29,6 +29,7 @@ The preceding configuration can be applied to the following sample:
|
||||
[BibTeX]{.term
|
||||
lem=BibTeX
|
||||
def="A program designed to format bibliographical entries"
|
||||
#bibtex
|
||||
} citations. Note that in LaTeX environments,
|
||||
the material between the begin and end tags will be interpreted
|
||||
as [raw LaTeX]{.term
|
||||
@ -37,6 +38,8 @@ as [raw LaTeX]{.term
|
||||
}, not as Markdown.
|
||||
```
|
||||
|
||||
In LaTeX and ConTeXt, if the span has an identifier (like `#bibtex` above), it will be used as the label of the note.
|
||||
|
||||
For DOCX output, the note is set as the content of a tooltip attached to an asterisk following the body text. Since this does not always produce good results, notably because tooltips only display plain strings, DOCX output is deactivated by default. However, you can activate it for individual classes by setting the variables `docx-body-text` and `docx-note-text`:
|
||||
|
||||
``` yaml
|
||||
|
||||
@ -491,13 +491,22 @@ end
|
||||
|
||||
local i_invocation = 0
|
||||
|
||||
local function wrap_in_raw_note_code(content, class_name)
|
||||
local function wrap_in_raw_note_code(content, class_name, id)
|
||||
-- content is a List of Inlines (output of replace_placeholders)
|
||||
local margin_note = content
|
||||
if FORMAT == 'context' or FORMAT == 'latex' then
|
||||
local csname = config[class_name].csname or 'mrgnn'
|
||||
insert_in_table(margin_note, 1, pandoc.RawInline(FORMAT, '\\' .. csname .. '{'))
|
||||
insert_in_table(margin_note, pandoc.RawInline(FORMAT, '}'))
|
||||
local before = '\\' .. csname
|
||||
if id ~= '' and FORMAT == 'context' then
|
||||
before = before .. '[' .. id .. ']'
|
||||
end
|
||||
before = before .. '{'
|
||||
if id ~= '' and FORMAT == 'latex' then
|
||||
before = before .. '\\label{' .. id .. '}'
|
||||
end
|
||||
local after = '}'
|
||||
insert_in_table(margin_note, 1, pandoc.RawInline(FORMAT, before))
|
||||
insert_in_table(margin_note, pandoc.RawInline(FORMAT, after))
|
||||
elseif FORMAT == 'openxml' then
|
||||
i_invocation = i_invocation + 1
|
||||
local bookmark_id = 'mrgnn_' .. i_invocation
|
||||
@ -531,11 +540,12 @@ local function render_margin_notes(span)
|
||||
local render_note = config[class_name].render.note
|
||||
local render_body = config[class_name].render.body
|
||||
local note_position = config[class_name].position
|
||||
local note_id = span.identifier
|
||||
local margin_note = {}
|
||||
local body = {}
|
||||
if render_note then
|
||||
margin_note = wrap_in_raw_note_code(
|
||||
render_note(span.content, span.attributes), class_name)
|
||||
render_note(span.content, span.attributes), class_name, note_id)
|
||||
end
|
||||
if render_body then
|
||||
body = render_body(span.content, span.attributes)
|
||||
@ -553,6 +563,9 @@ local function render_margin_notes(span)
|
||||
'the margin-note class "' .. class_name '". ' ..
|
||||
'Expected "before" or "after".')
|
||||
end
|
||||
if FORMAT == 'context' or FORMAT == 'latex' then
|
||||
span.identifier = '' -- The id is attached to the note.
|
||||
end
|
||||
return span_with_note
|
||||
end
|
||||
end
|
||||
|
||||
@ -14,6 +14,7 @@ mrgnn-define-renderings:
|
||||
[BibTeX]{.term
|
||||
lem=BibTeX
|
||||
def="A program designed to format bibliographical entries"
|
||||
#bibtex
|
||||
} citations. Note that in LaTeX environments,
|
||||
the material between the begin and end tags will be interpreted
|
||||
as [raw LaTeX]{.term
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
, Str "include"
|
||||
, SoftBreak
|
||||
, Span
|
||||
( ""
|
||||
( "bibtex"
|
||||
, [ "term" ]
|
||||
, [ ( "lem" , "BibTeX" )
|
||||
, ( "def"
|
||||
|
||||
Reference in New Issue
Block a user