aboutsummaryrefslogtreecommitdiff
path: root/man/capitalizeHeaders.hs
blob: d3909df768baee0ebf613fb7e07b7d2b6200e8a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 = walk capitalizeHeaderLinks 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