From f9c7b49502ffcc69c41737a02b5da733b4a6f93e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 11 Nov 2017 16:18:39 -0800 Subject: lua-filters.md: use real-world man page filter as example. --- doc/lua-filters.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 1e0b988ba..0d9a2c0e0 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -335,17 +335,30 @@ will output: ``` -## Uppercasing text inside all headers +## Modifying pandoc's `MANUAL.txt` for man pages -This filter uses `walk_block` to transform inline elements -inside headers, converting all their text into uppercase. +This is the filter we use when converting `MANUAL.txt` +to man pages. It converts level-1 headers to uppercase +(uisng `walk_block` to transform inline elements +inside headers), removes footnotes, and replaces links +with regular text. ``` lua function Header(el) - return pandoc.walk_block(el, { + if el.level == 1 then + return pandoc.walk_block(el, { Str = function(el) return pandoc.Str(el.text:upper()) end }) + end +end + +function Link(el) + return el.content +end + +function Note(el) + return {} end ``` -- cgit v1.2.3