Use lua filter to generate man page from MANUAL.

Instead of three Haskell filters.

This is easier and faster.
This commit is contained in:
John MacFarlane 2017-11-11 15:26:24 -08:00
parent 6174b5bea5
commit 6b75d6e08c
7 changed files with 281 additions and 321 deletions

View file

@ -55,10 +55,8 @@ pandoc-$(version)-windows.msi:
rm pandoc.msi
man/pandoc.1: MANUAL.txt man/pandoc.1.template
pandoc $< -t man -s --template man/pandoc.1.template \
--filter man/capitalizeHeaders.hs \
--filter man/removeNotes.hs \
--filter man/removeLinks.hs \
pandoc $< -f markdown-smart -t man -s --template man/pandoc.1.template \
--lua-filter man/manfilter.lua \
--variable version="pandoc $(version)" \
-o $@

View file

@ -1,20 +0,0 @@
import Text.Pandoc.JSON
import Text.Pandoc.Walk
import Data.Char (toUpper)
main :: IO ()
main = toJSONFilter capitalizeHeaders
capitalizeHeaders :: Block -> Block
capitalizeHeaders (Header 1 attr xs) = Header 1 attr $ walk capitalize xs
capitalizeHeaders x = x
capitalize :: Inline -> Inline
capitalize (Str xs) = Str $ map toUpper xs
capitalize x = x
{-
capitalizeHeaderLinks :: Inline -> Inline
capitalizeHeaderLinks (Link xs t@('#':_,_)) = Link (walk capitalize xs) t
capitalizeHeaderLinks x = x
-}

19
man/manfilter.lua Normal file
View file

@ -0,0 +1,19 @@
-- filters to create the pandoc man page from MANUAL.txt
-- capitalize headers
function Header(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

File diff suppressed because it is too large Load diff

View file

@ -1,9 +0,0 @@
import Text.Pandoc.JSON
main :: IO ()
main = toJSONFilter removeLinks
removeLinks :: Inline -> [Inline]
removeLinks (Link _ l _) = l
removeLinks x = [x]

View file

@ -1,9 +0,0 @@
import Text.Pandoc.JSON
main :: IO ()
main = toJSONFilter removeNotes
removeNotes :: Inline -> Inline
removeNotes (Note _) = Str ""
removeNotes x = x

View file

@ -126,9 +126,7 @@ extra-source-files:
-- stack build plan
stack.yaml
-- files needed to build man page
man/capitalizeHeaders.hs
man/removeNotes.hs
man/removeLinks.hs
man/manfilter.lua
man/pandoc.1.template
-- trypandoc
trypandoc/Makefile