Created
November 13, 2017 13:24
-
-
Save greut/a2db2e0b4f1b3149ac2ae2aefcd1c223 to your computer and use it in GitHub Desktop.
advanced pandoc2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- read metadata file into string | |
local metafile = io.open('metadata.yaml', 'r') | |
local content = metafile:read("*a") | |
metafile:close() | |
-- new elements | |
local before = pandoc.RawInline('tex', '\\begin{otherlanguage}{english}') | |
local after = pandoc.RawInline('tex', '\\end{otherlanguage}') | |
-- get metadata | |
local default_meta = pandoc.read(content, 'markdown').meta | |
return { | |
{ | |
Meta = function(meta) | |
-- use default metadata field if it hasn't been defined yet. | |
for k, v in pairs(default_meta) do | |
if meta[k] == nil then | |
meta[k] = v | |
end | |
end | |
return meta | |
end, | |
Code = function(code) | |
return {before, code, after} | |
end, | |
CodeBlock = function(code_block) | |
return {pandoc.Para({before}), code_block, pandoc.Para({after})} | |
end, | |
RawBlock = function(raw_block) | |
return {pandoc.Para({before}), raw_block, pandoc.Para({after})} | |
end, | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
date: "\\today" | |
lang: fr | |
babel-otherlangs: [en] | |
polyglossia-otherlangs: | |
- name: english | |
bibliography: src/bibliographie.yaml | |
csl: iso690-numeric-fr.csl | |
mainfont: Linux Biolinum O | |
sansfont: Linux Libertine O | |
monofont: Inconsolata | |
monofontoptions: Scale=0.9 | |
--- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment