1{- 2 AbsSyntaxWiki: Represents a parsed Skate Schema 3 4 Part of Skate: a Schema specification languge 5 6 Copyright (c) 2017, ETH Zurich. 7 All rights reserved. 8 9 This file is distributed under the terms in the attached LICENSE file. 10 If you do not find this file, copies can be found by writing to: 11 ETH Zurich D-INFK, Universit\"atstr. 6, CH-8092 Zurich. Attn: Systems Group. 12-} 13 14module AbsSyntaxWiki where 15 16 17import Data.List 18 19 20tableOfContent :: String 21tableOfContent = (heading "Table of contents:") ++ "<<TableOfContents()>>" 22 23footnote :: String -> String 24footnote s = "<<FootNote("++ s ++")>>" 25 26 27newLine :: String 28newLine = "\n" 29 30lineBreak :: String 31lineBreak = newLine ++ newLine 32 33hline :: String 34hline = "----" 35 36 37{- issue = title = -} 38headingGeneric :: String -> Int -> String 39headingGeneric n l = 40 hardbreak ++ prefix ++ " " ++ n ++ " " ++ prefix ++ lineBreak 41 where 42 hardbreak = newLine ++ "<<BR>>" ++ newLine 43 prefix = concat $ replicate l "=" 44 45title :: String -> String 46title n = (headingGeneric n 1) 47 48heading :: String -> String 49heading n = (headingGeneric n 2) 50 51subheading :: String -> String 52subheading n = headingGeneric n 3 53 54{-lists-} 55unOrderedList :: Int -> [String] -> String 56unOrderedList n elms = concat (elms2) 57 where 58 indent = concat $ replicate n " " 59 listPrefix = newLine ++ indent ++ "* " 60 elms2 = [listPrefix ++ e | e <- elms ] 61 62orderedList :: Int -> [String] -> String 63orderedList n elms = concat (elms2) 64 where 65 indent = concat $ replicate n " " 66 listPrefix = newLine ++ indent ++ "1. " 67 elms2 = [listPrefix ++ e | e <- elms ] 68 69 70 71{-code-} 72code:: String -> String 73code c = "{{{\n" ++ c ++ "\n}}}\n" 74 75inlinecode :: String -> String 76inlinecode c = "{{{" ++ c ++ "}}}" 77 78 79 80{-formats-} 81 82textit :: String -> String 83textit s = "''" ++ s ++ "''" 84 85textbf :: String -> String 86textbf s = "'''" ++ s ++ "'''" 87 88texttt :: String -> String 89texttt s = "`" ++ s ++ "`" 90 91textul :: String -> String 92textul s = "__" ++ s ++ "__" 93 94 95{-table-} 96 97 98tableHeading :: [String] -> String 99tableHeading cols = "||" ++ colstr ++ "||\n" 100 where 101 colstr = concat (intersperse "||" [textbf s | s <- cols]) 102 103tableRow :: [String] -> String 104tableRow cols = "||" ++ colstr ++ "||\n" 105 where 106 colstr = concat (intersperse "||" cols)