From 3762ae8f70bf4e7e63246cad8da79c0ee6d88280 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 26 Oct 2015 06:56:33 -0700 Subject: [PATCH] tools: pandoc filters used when making man pages --- tools/pandocCapitalizeHeaders.hs | 24 ++++++++++++++++++++++++ tools/pandocRemoveLinks.hs | 12 ++++++++++++ tools/pandocRemoveNotes.hs | 12 ++++++++++++ 3 files changed, 48 insertions(+) create mode 100755 tools/pandocCapitalizeHeaders.hs create mode 100755 tools/pandocRemoveLinks.hs create mode 100755 tools/pandocRemoveNotes.hs diff --git a/tools/pandocCapitalizeHeaders.hs b/tools/pandocCapitalizeHeaders.hs new file mode 100755 index 000000000..1872bca76 --- /dev/null +++ b/tools/pandocCapitalizeHeaders.hs @@ -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 +-} diff --git a/tools/pandocRemoveLinks.hs b/tools/pandocRemoveLinks.hs new file mode 100755 index 000000000..64a780b05 --- /dev/null +++ b/tools/pandocRemoveLinks.hs @@ -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] + diff --git a/tools/pandocRemoveNotes.hs b/tools/pandocRemoveNotes.hs new file mode 100755 index 000000000..4fd894e27 --- /dev/null +++ b/tools/pandocRemoveNotes.hs @@ -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 +