summaryrefslogtreecommitdiff
path: root/src/Secret.hs
blob: 7b428ce958627b9d201ec5aeac86473434c41ab8 (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
module Secret
( to_secret
) where


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



import Text.Pandoc
import Text.Pandoc.JSON


firstLine :: [Inline] -> ([Inline],[Inline])
firstLine [] = ([],[])
firstLine ((SoftBreak) : x) = ([], x)
firstLine (x:q) = ([x] ++ y, z) where (y,z) = (firstLine q)




to_secret (BlockQuote (Para (Str(first) : inlines) : blocks)) = 
    Div
            ("", ["secret"], [])
            ([
                 RawBlock (Format "html")
                     (start_detail ++ start_summary)
             ] ++ [Plain $ fLine] ++ [
                     RawBlock (Format "html")
                     (end_summary)
                  ] ++ [ Plain rest ]++ blocks ++ [
                     RawBlock (Format "html")
                     (end_detail)
                  ]
            )
            where start_detail = "<details>"
                  start_summary = "<summary>"
                  end_detail = "</details>"
                  end_summary = "</summary>"
                  (fLine, rest) = firstLine inlines