tools: pandoc filters used when making man pages

This commit is contained in:
Simon Michael 2015-10-26 06:56:33 -07:00
parent 844e04812c
commit 3762ae8f70
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#!/usr/bin/env stack
-- stack runghc --package pandoc-types
-- ^ installs pandoc-types in the current stack db when needed
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
-}

12
tools/pandocRemoveLinks.hs Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env stack
-- stack runghc --package pandoc-types
import Text.Pandoc.JSON
main :: IO ()
main = toJSONFilter removeLinks
removeLinks :: Inline -> [Inline]
removeLinks (Link l _) = l
removeLinks x = [x]

12
tools/pandocRemoveNotes.hs Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env stack
-- stack runghc --package pandoc-types
import Text.Pandoc.JSON
main :: IO ()
main = toJSONFilter removeNotes
removeNotes :: Inline -> Inline
removeNotes (Note _) = Str ""
removeNotes x = x