#!/usr/bin/env runhaskell -- filter.hs {-- A filter to help convert a markdown file to an org file. It does the following: 1. Remove all headings --} import Text.Pandoc.JSON import Data.Text import Data.Map.Strict main :: IO () main = toJSONFilter filter'' filter'' :: Pandoc -> Pandoc filter'' (Pandoc meta blocks) = Pandoc meta (filter' <$> blocks) getFilename :: Meta -> Text getFilename meta = case lookupMeta (pack "filename") meta of Just (MetaString s) -> s _ -> pack "" makeInlines :: Text -> [Inline] makeInlines s = [Str s] getFilenameInlines :: Meta -> [Inline] getFilenameInlines = makeInlines . getFilename makeCustomId :: Text -> Attr makeCustomId s = (pack "", [], [(pack "CUSTOM_ID", s)]) emptyAttr :: Attr emptyAttr = (pack "", [], []) filter' :: Block -> Block filter' (Header _ _ _) = Null filter' x = x