mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 15:14:49 +03:00
25 lines
708 B
Haskell
Executable File
25 lines
708 B
Haskell
Executable File
#!/usr/bin/env stack
|
|
{- stack runghc --verbosity info --package pandoc-types -}
|
|
-- Ensure level 1 and 2 headings are first-letter-capitalised.
|
|
|
|
import Data.Char
|
|
import Text.Pandoc.JSON
|
|
import Text.Pandoc.Walk
|
|
|
|
main :: IO ()
|
|
main = toJSONFilter capitalizeHeaders
|
|
|
|
capitalizeHeaders :: Block -> Block
|
|
capitalizeHeaders (Header lvl attr xs) | lvl < 3 = Header lvl attr $ map capitalize (take 1 xs) ++ drop 1 xs
|
|
capitalizeHeaders x = x
|
|
|
|
capitalize :: Inline -> Inline
|
|
capitalize (Str s) = Str $ map toUpper (take 1 s) ++ map toLower (drop 1 s)
|
|
capitalize x = x
|
|
|
|
{-
|
|
capitalizeHeaderLinks :: Inline -> Inline
|
|
capitalizeHeaderLinks (Link xs t@('#':_,_)) = Link (walk capitalize xs) t
|
|
capitalizeHeaderLinks x = x
|
|
-}
|