Skip to content

Instantly share code, notes, and snippets.

View tarleb's full-sized avatar
🌱
Growing some software

Albert Krewinkel tarleb

🌱
Growing some software
View GitHub Profile
@tarleb
tarleb / highlight.lua
Created July 15, 2022 12:54
Custom syntax extension
--[[
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.
@tarleb
tarleb / sentence.lua
Created October 29, 2022 15:05
One sentece per line
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
@tarleb
tarleb / list-formats.lua
Last active April 26, 2024 14:55
list-formats.lua
--- 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
@tarleb
tarleb / chapter-numbers.lua
Last active July 16, 2024 15:31
Continuous chapter numbering
-- 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 <albert+pandoc@tarleb.com>
-- License: MIT