blob: a94cd3d7e79f7560566502c0f3ad6aa6019ffb57 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import Text.Pandoc
import Text.Pandoc.JSON
import Control.Monad.State
import Id
{-
- Écrit par Hédy GIRAUDEAU
- 27/07/17
-}
extractStart :: [Inline] -> ([Inline],[Inline])
extractStart [] = ([],[])
extractStart ((SoftBreak):q) = ((SoftBreak):y, z) where (y,z) = (extractStart q)
extractStart ((LineBreak):q) = ((LineBreak):y, z) where (y,z) = (extractStart q)
extractStart (img@(Image _ _ _):q) = (img: y, z) where (y,z) = (extractStart q)
extractStart x = ([],x)
transformBlock cnt ( hdF@(Header 1 _ inlines) : paraF@(Para inlinesP) : blocks ) =
return (( (RawBlock (Format "html")
( start_header )
) : hdF :
(RawBlock (Format "html")
( end_header )
) : (Plain inlinesP) :
(RawBlock (Format "html")
( end_intro )
) : blocks
) ++ [ (RawBlock (Format "html")
(end_article) )
])
where start_header = "<header>"
end_header = "</header><section class=\"entry-content clearfix\" >"
end_intro = ""
end_article = "</section>"
--transformBlock _ ((Para inlines):tl) =
-- return ((Plain plainInline):(Para paraInline:tl))
-- where (plainInline, paraInline) = extractStart(inlines)
transformBlock _ x = return x
bar :: Pandoc -> IO Pandoc
bar x = do cnt <- newId
bottomUpM (transformBlock cnt) x
main :: IO()
main = toJSONFilter bar
-- vim:set et:
|