From 3d6f98c4a37cc4b0e09f33032f93ed5063a7ea7c Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sun, 12 Nov 2017 15:36:11 -0800 Subject: [PATCH] lua-filters.md doc: Added handout example. --- doc/lua-filters.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 0aed95cb5..ab6d221fa 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -362,6 +362,27 @@ function Note(el) end ``` +## Creating a handout from a paper + +This filter extracts all the numbered examples, section +headers, block quotes from a document, in addition to any +divs with class `handout`: + +``` lua +function Pandoc(doc) + local hblocks = {} + for i,el in pairs(doc.blocks) do + if (el.t == "Div" and el.classes[1] == "handout") or + (el.t == "BlockQuote") or + (el.t == "OrderedList" and el.style == "Example") or + (el.t == "Header") then + table.insert(hblocks, el) + end + end + return pandoc.Pandoc(hblocks, meta) +end +``` + ## Converting ABC code to music notation This filter replaces code blocks with class `abc` with