-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRST.hs
48 lines (41 loc) · 1.27 KB
/
RST.hs
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
module RST where
line :: String -> [String]
line = go id where
go :: (String -> String) -> String -> [String]
go f [] = f [] : []
go f ('\n' : xs) = f [] : go id xs
go f (x : xs) = go (f . (x :)) xs
paragraph :: [String] -> [[String]]
paragraph = go id where
go :: ([String] -> [String]) -> [String] -> [[String]]
go f [] = f [] : []
go f ("" : xs) = f [] : go id xs
go f (x : xs) = go (f . (x :)) xs
title :: a -> ([String] -> a) -> [String] -> a
title yes no x = case x of
[t, l] -> title2 yes no t l
[l, t, r] -> title3 yes no l t r
x' -> no x'
title2 :: a -> ([String] -> a) -> String -> String -> a
title2 yes no t l = case t of
[] -> no [[], l]
t' -> title2_line yes no t' l
title2_line :: a -> ([String] -> a) -> String -> String -> a
title2_line yes no t l = case l of
'=' : _ -> undefined
'-' : _ -> undefined
'`' : _ -> undefined
':' : _ -> undefined
''' : _ -> undefined
'"' : _ -> undefined
'~' : _ -> undefined
'^' : _ -> undefined
'_' : _ -> undefined
'*' : _ -> undefined
'+' : _ -> undefined
'#' : _ -> undefined
'<' : _ -> undefined
'>' : _ -> undefined
title3 :: a -> ([String] -> a) -> String -> String -> String -> a
title3 yes no l t r = undefined
title :: [String] ->