summaryrefslogtreecommitdiff
path: root/src/titleFilter.hs
blob: c215253ae3442743585af1c1a302a20daeca4fbb (plain)
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
import Text.Pandoc
import Text.Pandoc.JSON

{- 
 - Écrit par Hédy GIRAUDEAU
 - 27/07/17
-}


{- Convertit une liste de Inline (sorte de span, contie du formatage légé de
 - texte) vers  une chaine de caractère normal                   -}

toString :: [Inline] -> String
toString [] = ""
toString inls@((Str f):tl) = f ++ (toString tl)
toString inls@((Space):tl) = " " ++ (toString tl)
toString inls@((Emph inls2):tl) = (toString inls2) ++ (toString tl)
toString inls@((SmallCaps inls2):tl) = (toString inls2) ++ (toString tl)
toString inls@((Strong inls2):tl) = (toString inls2) ++ (toString tl)
toString (_:tl) = (toString tl)


transformBlock :: [Block] -> [Block]
transformBlock ( hdF@(Header 1 _ inlines) : _ ) = [(Plain [(Str (toString inlines))])]

transformBlock x = x


bar :: Pandoc -> Pandoc
bar x = bottomUp transformBlock x

main :: IO()
main = toJSONFilter bar


-- vim:set et: