2module ExtractNoscript (extractNoscript) where
5import qualified Text.Pandoc as Pan
7extractNoscript :: Module -> String
8extractNoscript modul = concat (extract modul)
11 extract :: a -> [String]
13instance Extract Module where
14 extract (Module _ _ _ stmts) =
15 map (\s -> "<p>" ++ s ++ "</p>") (concatMap extract stmts)
17instance Extract Statement where
18 extract (Definition d) = extract d
21instance Extract Def where
22 extract (FnDef _ _ e) = extract e
23 extract (OpDef _ _ _ e) = extract e
25instance Extract Expr where
30 Binop op e1 e2 -> case (op, f e1, f e2) of
31 ("++", [s1], [s2]) -> [s1 ++ s2]
32 (_ , ss1 , ss2 ) -> ss1 ++ ss2
34 App (App (Var "link") src) txt -> linkExtract src txt
35 App (App (Var "Graphics.link") src) txt -> linkExtract src txt
36 App (App (Var "Text.link") src) txt -> linkExtract src txt
37 App (Var "header") e -> tag "h1" e
38 App (Var "bold") e -> tag "b" e
39 App (Var "italic") e -> tag "i" e
40 App (Var "monospace") e -> tag "code" e
41 App e1 e2 -> f e1 ++ f e2
42 If eb et ef -> f et ++ f ef
43 Let defs e -> concatMap extract defs ++ f e
45 Case e cases -> concatMap (f . snd) cases
46 Data _ es -> concatMap f es
47 Markdown doc -> [ Pan.writeHtmlString Pan.defaultWriterOptions doc ]
51 case (extract src, extract txt) of
52 ([s1],[s2]) -> [ "<a href=\"" ++ s1 ++ "\">" ++ s2 ++ "</a>" ]
53 ( ss1, ss2) -> ss1 ++ ss2
56tag t e = map (\s -> concat [ "<", t, ">", s, "</", t, ">" ]) (extract e)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list