Verified Commit dc3d5124 authored by Camil Staps's avatar Camil Staps 🚀

Use new maybe type in Clean.Doc.Markup for genabcdoc utility

parent 2b2d7317
Pipeline #45100 passed with stages
in 20 minutes and 27 seconds
......@@ -5,7 +5,6 @@ import StdBool
import StdChar
import StdClass
import StdInt
import StdMaybe
import StdString
import Text.HTML
......@@ -29,36 +28,36 @@ walk last i end link s
| otherwise = case s.[i] of
'`'
| s.[i+1]=='`' && s.[i+2]==' ' -> case find (i+1) end " ``" s of
Nothing -> walk last (i+1) end link s
Just r -> [Text (s%(last,i-1)),CodeTag [] (walk (i+3) (i+3) (r-1) link s):walk (r+3) (r+3) end link s]
?None -> walk last (i+1) end link s
?Just r -> [Text (s%(last,i-1)),CodeTag [] (walk (i+3) (i+3) (r-1) link s):walk (r+3) (r+3) end link s]
| otherwise -> case find (i+1) end "`" s of
Nothing -> walk last (i+1) end link s
Just r -> [Text (s%(last,i-1)),CodeTag [] (walk (i+1) (i+1) (r-1) link s):walk (r+1) (r+1) end link s]
?None -> walk last (i+1) end link s
?Just r -> [Text (s%(last,i-1)),CodeTag [] (walk (i+1) (i+1) (r-1) link s):walk (r+1) (r+1) end link s]
'\n'
| s.[i+1]=='\n'
-> [Text (s%(last,i-1)),BrTag []:walk (i+1) (i+1) end link s]
| s.[i+1]=='`' && s.[i+2]=='`' && s.[i+3]=='`' -> case find (i+4) end "\n" s of
Nothing -> walk last (i+1) end link s
Just nl -> case find nl end "\n```" s of
Nothing -> walk last (i+1) end link s
Just r -> [Text (s%(last,i-1)),PreTag [] [Text (s%(nl,r-1))]:walk (r+4) (r+4) end link s]
?None -> walk last (i+1) end link s
?Just nl -> case find nl end "\n```" s of
?None -> walk last (i+1) end link s
?Just r -> [Text (s%(last,i-1)),PreTag [] [Text (s%(nl,r-1))]:walk (r+4) (r+4) end link s]
# li=first_after_whitespace i s
| s.[li]=='-' || s.[li]=='*'
-> [Text (s%(last,i-1)),BrTag [],Text {s.[li]}:walk (li+1) (li+1) end link s]
'*'
| s.[i+1]=='*'
| s.[i+2]=='*' -> case find (i+3) end "***" s of
Nothing -> walk last (i+1) end link s
Just r -> [Text (s%(last,i-1)),StrongTag [] [EmTag [] (walk (i+3) (i+3) (r-1) link s)]:walk (r+3) (r+3) end link s]
?None -> walk last (i+1) end link s
?Just r -> [Text (s%(last,i-1)),StrongTag [] [EmTag [] (walk (i+3) (i+3) (r-1) link s)]:walk (r+3) (r+3) end link s]
| otherwise -> case find (i+2) end "**" s of
Nothing -> walk last (i+1) end link s
Just r -> [Text (s%(last,i-1)),StrongTag [] (walk (i+2) (i+2) (r-1) link s):walk (r+2) (r+2) end link s]
?None -> walk last (i+1) end link s
?Just r -> [Text (s%(last,i-1)),StrongTag [] (walk (i+2) (i+2) (r-1) link s):walk (r+2) (r+2) end link s]
| otherwise -> case find (i+1) end "*" s of
Nothing -> walk last (i+1) end link s
Just r -> [Text (s%(last,i-1)),EmTag [] (walk (i+1) (i+1) (r-1) link s):walk (r+1) (r+1) end link s]
?None -> walk last (i+1) end link s
?Just r -> [Text (s%(last,i-1)),EmTag [] (walk (i+1) (i+1) (r-1) link s):walk (r+1) (r+1) end link s]
'{' | s.[i+1]=='{' -> case find (i+2) end "}}" s of
Nothing -> walk last (i+1) end link s
Just r -> [Text (s%(last,i-1)),link (s%(i+2,r-1)):walk (r+2) (r+2) end link s]
?None -> walk last (i+1) end link s
?Just r -> [Text (s%(last,i-1)),link (s%(i+2,r-1)):walk (r+2) (r+2) end link s]
_
-> walk last (i+1) end link s
......@@ -66,9 +65,9 @@ find :: !Int !Int !String !String -> Maybe Int
find i end q s
# sq = size q
| i+sq-1>end
= Nothing
= ?None
| startsWithAt (i+sq-1) (sq-1) q s
= Just i
= ?Just i
= find (i+1) end q s
where
startsWithAt :: !Int !Int !String !String -> Bool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment