-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeamer-spans.lua
734 lines (711 loc) · 25.7 KB
/
beamer-spans.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
--
--------------------------------------------------------------------------------
-- File: beamer-spans.lua
--
-- Usage: pandoc --lua-filter=beamer-spans.lua
--
-- Description: map spans in Pandoc markdown to beamer LaTeX commands
--
-- Author: Bernhard Fisseni (teoric), <[email protected]>
-- Version: 0.5
-- Created: 2019-07-20
-- Last Changed: 2025-02-06, 11:06:53 (CET)
--------------------------------------------------------------------------------
--
-- local inspect = require('inspect')
local text = require 'text'
local List = require 'pandoc.List'
local utils = require 'pandoc.utils'
local utilPath = string.match(PANDOC_SCRIPT_FILE, '.*[/\\]')
if PANDOC_VERSION >= {2,12} then
local path = require 'pandoc.path'
utilPath = path.directory(PANDOC_SCRIPT_FILE) .. path.separator
end
local loc_utils = dofile ((utilPath or '') .. 'utils.lua')
-- box types
local boxes = {
"block",
"goodbox", "badbox", "acceptbox",
"claimbox",
"yellowbox", "bluebox",
"exbox", "exxbox"
}
local boxes_optional = {
"definition", "theorem", "claim", "remark", "anm"
}
local comments = {
"Comment",
"comment",
"Bemerkung",
"Bewertung",
"Kommentar",
"Erläuterung",
"Beispiel"
}
local remarks = {
"Remark",
"Anmerkung",
"Frage",
"Antwort",
"Frage/Bewertung",
"Frage/Anregung",
"Bewertung/Frage"
}
local skips = pandoc.List({
"big", "med", "small"
})
local name_caps
local sec_start = nil
local sec_finish = nil
local slide_level = 3
local remark_color = "\\color{blue}\\sffamily"
local color_comments
local to_omit
local to_highlight
function check_comment(div)
return check_classes(div, comments)
end
function check_remark(div)
return check_classes(div, remarks)
end
function check_classes(div, classes)
local ret = false
for i, typ in pairs(classes) do
if div.classes:includes(typ) then
ret = true
break
end
end
return ret
end
function add_style(el, style, value)
if el.attributes['style'] == nil then
el.attributes['style'] = ""
end
-- TODO: proof against missing semicolon?
el.attributes['style'] = el.attributes['style'] .. style .. ': ' .. value .. ';'
end
function eval_md(code)
local md_text = pandoc.read(code, "markdown")
return md_text.blocks[1].c
end
local remove_break = {
LineBreak = function()
return pandoc.Space()
end
}
return {
{
Meta = function(meta)
if meta.supertitle ~= nil then
meta["supertitle-lined"] = meta.supertitle:walk(remove_break)
end
if meta.title ~= nil then
meta["title-lined"] = meta.title:walk(remove_break)
end
if meta.subtitle ~= nil then
meta["subtitle-lined"] = meta.subtitle:walk(remove_break)
end
if meta.subsubtitle ~= nil then
meta["subsubtitle-lined"] = meta.subsubtitle:walk(remove_break)
end
name_caps = meta["name-small-caps"]
color_comments = meta["color-remarks"]
local omitted = meta["omit"]
if (meta["classoption"] ~= nil and meta["classoptions"] ~= nil) then
meta["classoption"] = loc_utils.listify(meta["classoption"])
meta["classoption"]:extend(loc_utils.listify(meta["classoptions"]))
end
local highlighted = meta["highlight"]
to_omit = loc_utils.listify(omitted):map(function(o)
return utils.stringify(o)
end)
to_highlight = loc_utils.listify(highlighted):map(function(o)
return utils.stringify(o)
end)
if (meta["slide-level"]) then
local meta_level = meta["slide-level"]
slide_level = tonumber(utils.stringify(meta_level)) + 1
end
-- force different default document class
if FORMAT:match 'latex' and meta.documentclass ~= "article" then
meta["documentclass"] = "scrartcl"
end
return meta
end
},
{
Header = function(el)
if FORMAT:match 'latex' then
if utils.stringify(el) == "Anlagen" then
local ret = pandoc.RawBlock(FORMAT, "\\Anlagen{}")
return ret
elseif utils.stringify(el) == "Unterschriften" then
local ret = pandoc.RawBlock(FORMAT, "\\bigskip\\unterschrift{Torsten Zesch}{r}{Annemarie Friedrich}{}")
return ret
else
-- local typ = el.attributes["type"]
if loc_utils.startswith(el.identifier, "anlage:") then
local scale = (el.attributes["scale"] ~= nil) and ("[".. el.attributes["scale"] .. "]") or ""
local file = el.attributes["file"]
if file == nil then
if el.level == 2 then
local ret = List:new({pandoc.RawInline(FORMAT, "\\secanlage{" .. utils.stringify(el.content) .. "}{"
.. el.identifier .. "}")})
return ret
else error(string.format("No file for %s [#%s]", utils.stringify(el), el.identifier))
end
else
local subtype = (el.level > 2) and "sub" or ""
local ret = List:new({pandoc.RawInline(FORMAT, "\\".. subtype .. "anlage" .. scale .. "{".. utils.stringify(el.content) .. "}{"
.. el.identifier .. "}{" .. file .. "}"
)})
return ret
end
end
end
end
end
},
{
Span = function(el)
if FORMAT:match 'latex' or FORMAT:match 'beamer' then
if el.classes:includes("voccom") then
local ret = List:new()
table.insert(ret, pandoc.RawInline(FORMAT, "\\voclemCom"))
if el.attributes["remark"] ~= nil then
-- optional remark
table.insert(ret, pandoc.RawInline(FORMAT, "["))
table.insert(ret, pandoc.Span(eval_md(el.attributes["remark"])))
table.insert(ret, pandoc.RawInline(FORMAT, "]"))
end
table.insert(ret, pandoc.RawInline(FORMAT, "{"))
table.insert(ret, pandoc.Span(el.c, el.attr))
table.insert(ret, pandoc.RawInline(FORMAT, "}"))
-- insert lemma
if el.attributes["lemma"] ~= nil then
table.insert(ret, eval_md(el.attributes["lemma"]))
else
table.insert(ret, pandoc.Span(el.c))
end
-- insert meaning
if el.attributes["comment"] ~= nil then
table.insert(ret, pandoc.Span(eval_md(el.attributes["comment"])))
else
table.insert(ret, pandoc.RawInline(FORMAT, "{}"))
end
return ret
end
if el.classes:includes("vocnote") then
local ret = List:new()
table.insert(ret, pandoc.RawInline(FORMAT, "\\voclemnote"))
if el.attributes["remark"] ~= nil then
-- optional remark
table.insert(ret, pandoc.RawInline(FORMAT, "["))
table.insert(ret, pandoc.Span(eval_md(el.attributes["remark"])))
table.insert(ret, pandoc.RawInline(FORMAT, "]"))
end
table.insert(ret, pandoc.RawInline(FORMAT, "{"))
table.insert(ret, pandoc.Span(el.c, el.attr))
table.insert(ret, pandoc.RawInline(FORMAT, "}"))
-- insert lemma
if el.attributes["lemma"] ~= nil then
table.insert(ret, eval_md(el.attributes["lemma"]))
else
table.insert(ret, pandoc.Span(el.c))
end
-- insert meaning
if el.attributes["meaning"] ~= nil then
table.insert(ret, pandoc.Span(eval_md(el.attributes["meaning"])))
else
table.insert(ret, pandoc.RawInline(FORMAT, "{}"))
end
return ret
end
end
end
},
{
Link = function(el)
local typ = el.attributes["type"]
if typ ~= nil then
local typ = text.lower(typ)
end
-- print (utils.stringify(el.content))
-- print(typ)
if el.attributes["type"] == "doi" then
local base = "http://doi.org/"
local hdl = loc_utils.trim(utils.stringify(el))
el.target = base .. hdl
return el
elseif el.attributes["type"] == "hdl" then
local base = "http://hdl.handle.net/"
local hdl = loc_utils.trim(utils.stringify(el))
el.target = base .. hdl
return el
elseif el.attributes["type"] == "konde" then
local base = "https://gams.uni-graz.at/"
local hdl = loc_utils.trim(utils.stringify(el))
el.target = base .. hdl
return el
elseif el.attributes["type"] == "urn" then
local base = "https://mdz-nbn-resolving.de/"
local hdl = loc_utils.trim(utils.stringify(el))
el.target = base .. hdl
return el
elseif string.find(utils.stringify(el.content), "mdz.nbn.resolving.de") then
local target = el.target:gsub("^http[^:]*://[^/]+/", "")
-- print(target)
el.content = target
local ret = List:new({pandoc.RawInline(FORMAT, "\\textsc{urn}: "), pandoc.Link(target, "https://mdz-nbn-resolving.de/" .. target)})
return ret
elseif string.find(utils.stringify(el.content), "doi.org") then
local target = el.target:gsub("^http[^:]*://[^/]+/", "")
-- print(target)
el.content = target
local ret = List:new({pandoc.RawInline(FORMAT, "\\textsc{doi}: "), pandoc.Link(target, "https://doi.org/" .. target)})
return ret
end
if FORMAT:match 'latex' then
if el.attributes["type"] == "anlage" then
local ret = pandoc.RawInline(FORMAT, "\\emnameref{anlage:".. utils.stringify(el) .. "}")
return ret
end
end
end
},
{
Span = function(el)
local color = el.attributes['color']
local bgcolor = el.attributes['bgcolor']
if color ~= nil or bgcolor ~= nil then
-- if no color attribute, return unchanged -- redundant!
-- transform to <span style="color: red;"></span>
if FORMAT:match 'html' or FORMAT:match 'html5' then
-- remove color attributes
if color ~= nil then
el.attributes['color'] = nil
-- use style attribute instead
add_style(el, "color", color)
end
if bgcolor ~= nil then
el.attributes['bgcolor'] = nil
-- use style attribute instead
add_style(el, "background-color", bgcolor)
add_style(el, "padding", ".5ex")
end
-- return full span element
-- return el
elseif FORMAT:match 'latex' or FORMAT:match 'beamer' then
local start = ""
local finish = ""
if color ~= nil then
-- remove color attributes
el.attributes['color'] = nil
start = start .. '\\textcolor{'..color..'}{'
finish = "}" .. finish
end
if bgcolor ~= nil then
-- remove color attributes
el.attributes['bgcolor'] = nil
start = start .. '\\colorbox{'..bgcolor..'}{'
finish = "}" .. finish
end
-- encapsulate in latex code
table.insert(
el.content, 1,
pandoc.RawInline('latex', start)
)
table.insert(
el.content,
pandoc.RawInline('latex', finish)
)
-- returns only span content
-- return el.content
else
-- for other format return unchanged
-- return el
end
end
if el.classes:includes("menu") then
if FORMAT:match 'latex' or FORMAT:match 'beamer' then
table.insert(
el.content, 1,
pandoc.RawInline('latex', '\\textsf{\\bfseries{}')
)
table.insert(
el.content,
pandoc.RawInline('latex', '}')
)
-- returns only span content
-- return el.content
else
-- for other format return unchanged
-- return el
end
end
if el.classes:includes("serif") then
if FORMAT:match 'latex' or FORMAT:match 'beamer' then
table.insert(
el.content, 1,
pandoc.RawInline('latex', '\\textrm{')
)
table.insert(
el.content,
pandoc.RawInline('latex', '}')
)
-- returns only span content
-- return el.content
else
-- for other format return unchanged
-- return el
end
end
return el
end
},
{
Div = function(div)
for i, class in ipairs(div.classes) do
if to_omit:includes(class) then
return pandoc.List:new()
end
if to_highlight:includes(class) then
table.insert(
div.content, 1,
pandoc.Para(pandoc.Strong("⇓ " .. text.upper(class) .. " ⇓"))
)
table.insert(
div.content,
pandoc.Para(pandoc.Strong("⇑ " .. text.upper(class) .. " ⇑"))
)
end
-- return div
end
local color = div.attributes['color']
local bgcolor = div.attributes['bgcolor']
if color ~= nil or bgcolor ~= nil then
-- if no color attribute, return unchanged -- redundant!
-- transform to <span style="color: red;"></span>
if FORMAT:match 'html' or FORMAT:match 'html5' then
-- remove color attributes
if color ~= nil then
div.attributes['color'] = nil
-- use style attribute instead
add_style(div, "color", color)
end
if bgcolor ~= nil then
div.attributes['bgcolor'] = nil
-- use style attribute instead
add_style(div, "background-color", bgcolor)
end
end
elseif FORMAT == "beamer" then
-- TODO: make start and finish lists of RawBlock, pandoc.RawInline and others
-- like vocnote above
-- local start = List:new({})
-- local finish = List:new({})
local start = ""
local finish = ""
-- wrap div in box containers
if div.classes:includes("only") then
local scope = div.attributes["scope"] or "+-"
start = "\\only<" .. scope ..
">{" .. start
finish = "}" .. finish
end
if div.classes:includes("uncover") then
local scope = div.attributes["scope"] or "+-"
start = "\\uncover<" .. scope ..
">{" .. start
finish = "}" .. finish
end
if div.classes:includes("on_next") then
local scope = div.attributes["scope"] or "+"
start = "\\only<" .. scope .. ">{" .. start
finish = finish .. "}"
end
if div.classes:includes("sideways") then
-- io.stderr:write(title .. "\n")
start = start .. "\\begin{sideways}"
finish = "\\end{sideways}" .. finish
-- break -- allow only first box!
end
for i, b in pairs(boxes) do
if div.classes:includes(b) then
local title = div.attributes["title"] or ""
local scope = div.attributes["scope"]
if scope ~= nil and not(div.classes:includes("uncover")) and not(div.classes:includes("only")) and not(div.classes:includes("on_next")) then
scope = "<" .. scope .. ">"
else
scope = ""
end
-- io.stderr:write(title .. "\n")
start = start .. "\\begin{" .. b .. "}" .. scope ..
"{" .. title
if div.attributes["rechts"] then
start = start .. "\\rechtsanm{" .. div.attributes["rechts"] .. "}"
end
start = start .. "}"
finish = "\\end{" .. b .. "}" .. finish
-- break -- allow only first box!
end
end
for i, b in pairs(boxes_optional) do
if div.classes:includes(b) then
local title = div.attributes["title"] or ""
-- io.stderr:write(title .. "\n")
start = start .. "\\begin{" .. b .. "}" ..
"[" .. title
if div.attributes["rechts"] then
start = start .. "\\rechtsanm{" .. div.attributes["rechts"] .. "}"
end
start = start .. "]"
finish = "\\end{" .. b .. "}" .. finish
-- break -- allow only first box!
end
end
if div.classes:includes("lineno") then
-- io.stderr:write(title .. "\n")
local start_no = div.attributes["start"] or "1"
start = start .. "\\begin{linenumbers}[" .. start_no .. "]"
finish = "\\end{linenumbers}" .. finish
-- break -- allow only first box!
end
if div.classes:includes("verse") then
-- io.stderr:write(title .. "\n")
start = start .. "\\begin{verse}"
finish = "\\end{verse}" .. finish
-- break -- allow only first box!
end
-- same code below for LATEX
local skip = div.attributes["skip"]
if skip ~= nil and skips:includes(skip) then
start = '\\' .. skip .. "skip{}" .. start
end
if start ~= "" then
local ret = List:new({pandoc.RawBlock(FORMAT, start)})
ret:extend(div.content)
ret:extend({pandoc.RawBlock(FORMAT, finish)})
div.content = ret
end
return div
elseif FORMAT == "latex" then
local start = ""
local finish = ""
if div.classes:includes("sideways") then
-- io.stderr:write(title .. "\n")
start = start .. "\\begin{sideways}"
finish = "\\end{sideways}" .. finish
-- break -- allow only first box!
end
if div.classes:includes("multicols") then
local number = div.attributes["columns"] or "2"
start = "\\begin{multicols}{" .. number .. "}" .. start
finish = finish .. "\\end{multicols}"
end
-- wrap div in box containers
for i, b in pairs(boxes) do
if div.classes:includes(b) then
local title=div.attributes["title"] or ""
-- io.stderr:write(title .. "\n")
start = "\\begin{description}" ..
"\\item[".. title .. "] ~"
if div.attributes["rechts"] then
start = start .. "\\rechtsanm{" .. div.attributes["rechts"] .. "}"
end
finish = "\\end{description}"
end
end
local is_remark = check_remark(div)
local is_comment = check_comment(div)
-- io.stderr:write(table.concat(div.classes, ";;"), "\n")
if div.attributes["color"] ~= nil then
color = '\\color{'.. div.attributes["color"] ..'}'
end
if div.attributes["resolved"] then
return List:new()
elseif (is_remark or is_comment) then
local color = ""
if is_comment and color_comments then
color = remark_color
elseif is_remark then
color = remark_color
end
start = "\\begin{addmargin}[1cm]{1cm}" .. color .."\\vskip1ex\\begingroup\\textbf{" .. table.concat(div.classes, ";;") .. "}" .. start
-- start = "\\medskip\\begin{addmargin}[1cm]{1cm}" .. color .."\\vskip1ex\\begingroup\\textbf{" .. table.concat(div.classes, ";;") .. "}"
finish = finish .. "\\endgroup\\vskip1ex\\end{addmargin}"
elseif (color ~= nil) then
start = '{' .. color .. start
finish = finish .. '}'
end
if div.attributes["linestretch"] then
start = '\\bgroup\\setstretch{' .. div.attributes["linestretch"] ..'}' .. start
finish = '\\egroup{}' .. finish
end
if div.attributes["bgcolor"] then
start = '\\begin{tcolorbox}[colback='.. div.attributes["bgcolor"] ..'!20, colframe=' .. div.attributes["bgcolor"] .. '!80!black]' .. start
finish = finish .. '\\end{tcolorbox}'
end
if div.classes:includes("xml") then
start = "\\paragraph{XML}\\begingroup\\sffamily{}".. start
finish = finish .. "\\endgroup{}"
end
if div.classes:includes("xml_details") then
start = "\\begin{addmargin}{1em}\\sffamily{}\\relsize{-1}\\color{darkgray}".. start
finish = finish .. "\\end{addmargin}"
end
if div.classes:includes("transcription") then
start = "\\begin{aeettranscription}".. start
finish = finish .. "\\end{aeettranscription}"
end
if div.classes:includes("references") then
start = "\\begin{aeetreferences}".. start
finish = finish .. "\\end{aeetreferences}"
end
if div.classes:includes("figure_text") then
start = "\\begin{figureText}".. start
finish = finish .. "\\end{figureText}"
end
if div.classes:includes("lineno") then
-- io.stderr:write(title .. "\n")
local start_no = div.attributes["start"] or "1"
start = start .. "\\begin{linenumbers}[" .. start_no .. "]"
finish = "\\end{linenumbers}" .. finish
-- break -- allow only first box!
end
if div.classes:includes("verse") then
-- io.stderr:write(title .. "\n")
start = start .. "\\begin{poem}"
local title = div.attributes["title"]
local author = div.attributes["author"]
local prefix = div.attributes["prefix"] or ""
if title ~= nil then
if author ~= nil then
start = start .. "\\titleauthorpoem[" .. prefix .."]{" .. title .. "}{" .. author .."}"
else
start = start .. "\\titlepoem{" .. title .. "}"
end
elseif author ~= nil then
start = start .. "\\titleauthorpoem[" .. prefix .."]{\\poemblanktitle}{" .. author .."}"
end
finish = "\\\\-\\end{poem}" .. finish
-- break -- allow only first box!
end
local skip = div.attributes["skip"]
if skip ~= nil and skips:includes(skip) then
start = '\\' .. skip .. "skip{}" .. start
end
if start ~= nil and start ~= "" then
local ret = List:new({pandoc.RawBlock(FORMAT, start)})
ret:extend(div.content)
ret:extend({pandoc.RawBlock(FORMAT, finish)})
div.content = ret
return div
end
end
end,
Span = function(span)
if FORMAT == "beamer" or FORMAT == "latex" then
local start = ""
local finish = ""
if span.classes:includes("key") then
start = "\\fbox{\\small{}" .. start
finish = finish .. "}"
elseif span.classes:includes("rechts") then
-- if FORMAT == "beamer" then
start = "\\rechts{" .. start
finish = "}"
-- nonsense: only for paragraphs!
-- else
-- start = "\\begin{flushright}" .. start
-- finish = finish .. "\\end{flushright}"
-- end
end
if span.classes:includes("rkomment") then
start = "\\rechts{\\emph{" .. start
finish = finish .. "}}"
end
if span.classes:includes("emph") then
-- start = "\\oldemph{"
start = "\\emph{" .. start
finish = finish .. "}"
end
if span.classes:includes("icon") then
start = "\\icontext{" .. start
finish = finish .. "}"
end
if span.classes:includes("lig") then
start = "\\ligtext{\\unemph{" .. start
finish = finish .. "}}"
end
if span.classes:includes("uni") then
start = "\\unitext{\\unemph{" .. start
finish = finish .. "}}"
end
if span.classes:includes("emoji") then
start = "\\emojiText{" .. start
finish = finish .. "}"
end
if span.classes:includes("underline")
or span.classes:includes("ul") then
start = "\\underline{" .. start
finish = finish .. "}"
end
if span.classes:includes("unemph") then
start = "\\unemph{" .. start
finish = finish .. "}"
end
if span.classes:includes("fnhd_text") then
start = "{\\normalfont\\unifont{}" .. start
finish = finish .. "}"
end
if span.classes:includes("so") or span.classes:includes("ls") or span.classes:includes("gesperrt") then
start = "\\textso{" .. start
finish = finish .. "}"
end
if span.classes:includes("name") then
start = "\\textsc{" .. start
finish = finish .. "}"
end
if span.classes:includes("sl") or span.classes:includes("slanted") or span.classes:includes("schraeg") then
start = "\\textsl{" .. start
finish = finish .. "}"
end
if span.classes:includes("transl") then
start = "\\transl{" .. start
finish = finish .. "}"
end
if span.classes:includes("kbd") then
start = "\\fbox{\\small{}\\bfseries{}" .. start
finish = finish .. "}"
end
if span.classes:includes("comment") then
local typ = "Highlight"
if span.attributes["type"] ~= nil then
typ = span.attributes["type"]
end
-- start = "\\pdftooltip[markup=".. typ .. ",color=Yellow]{" .. "\\pdfmarkupcomment[markup=".. typ .. ",color=Yellow]{" .. start
-- finish = finish .. "}{".. span.attributes["text"] .."}" .. "}{".. span.attributes["text"] .."}"
start = "\\pdfmarkupcomment[markup=".. typ .. ",color=Yellow]{" .. start
finish = finish .. "}{".. span.attributes["text"] .."}"
end
if span.classes:includes("margincomment") then
start = "\\pdfmargincomment[color=Yellow]{" .. span.attributes["text"] .. "}" .. start
print("START: ".. start)
end
if span.classes:includes("endstanza") then
finish = finish .. "\\\\!"
end
if start or finish then
local ret = List:new({pandoc.RawInline(FORMAT, start)})
ret:extend(span.content)
ret:extend({pandoc.RawInline(FORMAT, finish)})
return {
pandoc.Span(ret, span.attr)
}
end
end
end
}
}