This file contains 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
-- This filter numbers second-level headings as chapters, and treats | |
-- first-level headings as "parts". | |
--- Fix numbering when using parts | |
-- | |
-- This filter numbers second-level headings as chapters, and treats | |
-- first-level headings as "parts". | |
-- | |
-- Copyright: © 2024 Albert Krewinkel <[email protected]> | |
-- License: MIT |
This file contains 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
--- Lists the formats that support all the extensions given on the command line. | |
-- | |
-- Usage: | |
-- | |
-- pandoc lua list-formats.lua [extensions,...] | |
-- | |
-- Example: | |
-- | |
-- $ pandoc lua list-formats.lua native_numbering citations | |
-- docx |
This file contains 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
local function sentence_lines (el) | |
local inlines = el.content | |
for i = 2, #inlines do | |
if inlines[i].t == 'Space' and | |
inlines[i-1].t == 'Str' and | |
inlines[i-1].text:match '%.$' then | |
inlines[i] = pandoc.SoftBreak() | |
end | |
end | |
return el |
This file contains 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
--[[ | |
Add support for a custom inline syntax. | |
This pandoc Lua filter allows to add a custom markup syntax | |
extension. It is designed to be adjustable; it should not be | |
necessary to modify the code below the separator line. | |
The example here allows to add highlighted text by enclosing the | |
text with `==` on each side. Pandoc supports this for HTML output | |
out of the box. Other outputs will need additional filters. |
This file contains 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
function interactive (it, env) | |
local has_readline, RL = pcall(require, 'readline') | |
if not has_readline then | |
RL = { | |
readline = function (prompt) | |
io.stdout:write(prompt) | |
return io.read() | |
end | |
} |
This file contains 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
-- Generate a Table of Contents. | |
-- | |
-- This is an adaption of the Haskell code used in pandoc. This script | |
-- is intended to be adapted to specific requirements before use. E.g., | |
-- it can be modified to add additional elements as TOC items, to add | |
-- more info to each line in the TOC, or to control whether the heading | |
-- number is included in the link. | |
local PANDOC_WRITER_OPTIONS = PANDOC_WRITER_OPTIONS | |
_ENV = pandoc |
This file contains 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
-- This is a sample custom writer for pandoc, using Layout to | |
-- produce nicely wrapped output. | |
local layout = pandoc.layout | |
local text = pandoc.text | |
local type = pandoc.utils.type | |
local l = layout.literal | |
-- Table to store footnotes, so they can be included at the end. |
This file contains 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
local known_exts = pandoc.List{".png", ".jpg", "jpeg"} | |
if FORMAT:match 'tex' then | |
known_exts = pandoc.List { | |
".pdf", ".png", ".jpg", ".mps", ".jpeg", ".jbig2", ".jb2" | |
} | |
elseif FORMAT:match 'html' then | |
known_exts = pandoc.List { | |
".svg", ".png", ".jpg", ".jpeg", ".webp", ".gif" | |
} | |
end |
This file contains 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
-- Render TeX and LaTeX like the `\TeX` and `\LaTeX{}` macros do. | |
-- Copyright © 2020 Albert Krewinkel <[email protected]> | |
-- License: MIT License | |
-- Style inspired by https://tess.oconnor.cx/2007/08/tex-poshlet | |
local style = pandoc.RawBlock('html', [[ | |
<style> | |
.tex-logo sub, .latex-logo sub { | |
font-size: 100%; | |
margin-left: -0.1667em; |
This file contains 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
local List = require 'pandoc.List' | |
local meta | |
function merge_meta(m1, m2) | |
local result = m1 | |
for k, v in pairs(m2) do | |
if result[k] == nil then | |
result[k] = v | |
end |
NewerOlder