diff options
Diffstat (limited to 'filter-standalone.hs')
-rw-r--r-- | filter-standalone.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/filter-standalone.hs b/filter-standalone.hs new file mode 100644 index 0000000..8bd769d --- /dev/null +++ b/filter-standalone.hs @@ -0,0 +1,39 @@ +#!/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 |