blob: 8bd769d03196e2a7db8e58f96d47fd517b441ae0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
|