summaryrefslogtreecommitdiff
path: root/_extensions
diff options
context:
space:
mode:
Diffstat (limited to '_extensions')
-rw-r--r--_extensions/js/ingress/_extension.yml6
-rw-r--r--_extensions/js/ingress/ingress.lua29
-rw-r--r--_extensions/js/multicol-nohead/multicol-nohead.lua23
-rw-r--r--_extensions/js/stylish-issue/_extension.yaml17
-rw-r--r--_extensions/js/stylish-issue/doc-class.tex68
5 files changed, 143 insertions, 0 deletions
diff --git a/_extensions/js/ingress/_extension.yml b/_extensions/js/ingress/_extension.yml
new file mode 100644
index 0000000..4655adc
--- /dev/null
+++ b/_extensions/js/ingress/_extension.yml
@@ -0,0 +1,6 @@
+title: Ingress
+author: Jonas Smedegaard
+version: 0.0.1
+contributes:
+ filters:
+ - ingress.lua
diff --git a/_extensions/js/ingress/ingress.lua b/_extensions/js/ingress/ingress.lua
new file mode 100644
index 0000000..3c2c429
--- /dev/null
+++ b/_extensions/js/ingress/ingress.lua
@@ -0,0 +1,29 @@
+-- Translate div class .lead to custo LaTeX environment \ingress{}
+
+local function escape_latex(str)
+ local replacements = {
+ ["\\"] = "\\textbackslash{}",
+ ["{"] = "\\{",
+ ["}"] = "\\}",
+ ["$"] = "\\$",
+ ["&"] = "\\&",
+ ["#"] = "\\#",
+ ["_"] = "\\_",
+ ["%"] = "\\%",
+ ["^"] = "\\textasciicircum{}",
+ ["~"] = "\\textasciitilde{}"
+ }
+ return (str:gsub(".", function(c)
+ return replacements[c] or c
+ end))
+end
+
+function Div(el)
+ if FORMAT:match 'latex' then
+ if el.classes:includes('lead') then
+ local content = pandoc.utils.stringify(el.content)
+ local escaped_content = escape_latex(content)
+ return pandoc.RawBlock('latex', '\\ingress{' .. escaped_content .. '}')
+ end
+ end
+end
diff --git a/_extensions/js/multicol-nohead/multicol-nohead.lua b/_extensions/js/multicol-nohead/multicol-nohead.lua
index 85e0dd8..f190db8 100644
--- a/_extensions/js/multicol-nohead/multicol-nohead.lua
+++ b/_extensions/js/multicol-nohead/multicol-nohead.lua
@@ -31,6 +31,21 @@ local function is_columnar_header(elem)
return elem.t == "Header" and elem.level == 1
end
+local function is_multicols_begin(elem)
+ return elem.t == "RawBlock" and elem.text == "\\begin{multicols}{3}\\raggedcolumns"
+end
+
+local function is_multicols_end(elem)
+ return elem.t == "RawBlock" and elem.text == "\\end{multicols}"
+end
+
+-- a standalone image with optional caption that has class .wide
+-- TODO: detect pre-quarto-filter pattern too
+local function is_wide(elem)
+ return ((elem.t == "Para" and has_class(elem.content[1], "wide"))
+ or (elem.t == "Figure" and has_class(elem.content[1].content[1], "wide")))
+end
+
-- TODO: detect pre-quarto-filter pattern too
local function is_newpage_command(elem)
return (elem.t == "RawBlock" and elem.text == "\\newpage{}")
@@ -100,6 +115,10 @@ function Pandoc(doc)
if is_columnar_header(elem) then
multicol_places[i] = multicol_now and "renew" or "begin"
multicol_now = true
+ elseif is_wide(elem) then
+ if multicol_now then
+ multicol_places[i] = "renew"
+ end
elseif is_advertising(elem) then
doc.blocks[i] = ad(elem)
if multicol_now then
@@ -115,6 +134,10 @@ function Pandoc(doc)
multicol_places[i] = "end"
multicol_now = false
end
+ elseif is_multicols_begin(elem) then
+ multicol_now = true
+ elseif is_multicols_end(elem) then
+ multicol_now = false
end
end
if multicol_now then
diff --git a/_extensions/js/stylish-issue/_extension.yaml b/_extensions/js/stylish-issue/_extension.yaml
index 0af14b6..0f3aeac 100644
--- a/_extensions/js/stylish-issue/_extension.yaml
+++ b/_extensions/js/stylish-issue/_extension.yaml
@@ -18,6 +18,7 @@ contributes:
template-partials:
- before-title.tex
+ - doc-class.tex
include-in-header:
# borrow microtype tunings from somewhat similar EB Garamond
@@ -83,3 +84,19 @@ contributes:
}
}
\makeatother
+# define format for ingress text
+ - text: |
+ \makeatletter
+ \newcommand{\ingress}[1]{%
+ {\Large #1}\par
+ \@afterindentfalse
+ \@afterheading
+ \vspace{.5\baselineskip}%
+ }
+ \makeatother
+# refine hyphenation
+ - text: |
+ \hyphenation{
+ skulp-tur skulp-tur-en skulp-tur-ens
+ skulp-tur-er skulp-tur-ers
+ skulp-tur-er-ne skulp-tur-er-nes}
diff --git a/_extensions/js/stylish-issue/doc-class.tex b/_extensions/js/stylish-issue/doc-class.tex
new file mode 100644
index 0000000..a9dbfaa
--- /dev/null
+++ b/_extensions/js/stylish-issue/doc-class.tex
@@ -0,0 +1,68 @@
+\DocumentMetadata{
+% modern PDF rendering: <https://tex.stackexchange.com/a/686905/309738>
+$if(lang)$
+ lang={$lang$},
+$endif$
+$if(pdfversion)$
+ pdfversion=$pdfversion$,
+$endif$
+$for(pdfstandard)$
+ pdfstandard=$pdfstandard$,
+$endfor$
+$if(pdftestphase)$
+testphase=
+ {
+$for(pdftestphase)$
+ $pdftestphase$,
+$endfor$
+ },
+$endif$
+$if(pdfdebug)$
+debug=
+ {
+$for(pdfdebug)$
+ $pdfdebug$,
+$endfor$
+ },
+$endif$
+$if(pdfdebugfirstaidoff)$
+debug=
+ {
+firstaidoff=
+ {
+$for(pdfdebugfirstaidoff)$
+ $pdfdebugfirstaidoff$,
+$endfor$
+ },
+ },
+$endif$
+}
+$if(copyright)$
+% flag as rights protected <https://tex.stackexchange.com/a/712443/309738>
+\ExplSyntaxOn
+\pdfmeta_xmp_add:n{<xmpRights:Marked>True</xmpRights:Marked>}
+\ExplSyntaxOff
+$endif$
+$if(pdftestphasestrict)$
+% fatalize tagging warnings
+\ExplSyntaxOn
+ \msg_redirect_module:nnn { tag } { warning } { error }
+\ExplSyntaxOff
+$endif$
+\documentclass[
+$for(babel-otherlangs)$
+ $babel-otherlangs$,
+$endfor$
+$if(babel-lang)$
+ $babel-lang$,
+$endif$
+$if(fontsize)$
+ $fontsize$,
+$endif$
+$if(papersize)$
+ $papersize$paper,
+$endif$
+$for(classoption)$
+ $classoption$$sep$,
+$endfor$
+]{$documentclass$}