1
Fork 0

finish on the website updates for now

This commit is contained in:
Jake Wheat 2015-08-08 22:30:17 +03:00
parent b7d9d92ae7
commit 322b6f200d
5 changed files with 38 additions and 21 deletions

View file

@ -1,5 +1,5 @@
Converts the test data to markdown
Converts the test data to asciidoc
> import Language.SQL.SimpleSQL.Tests
> import Text.Show.Pretty
@ -46,17 +46,32 @@ TODO: should put the dialect in the html output
> render = go False
> where
> go t (Heading level title : is) = do
> when t $ putStrLn "</table>"
> putStrLn $ replicate level '#' ++ " " ++ title
> when t $ putStrLn "|==="
> -- slight hack
> when (level > 1) $
> putStrLn $ "\n" ++ replicate level '=' ++ " " ++ title
> go False is
> go t (Row sql hask : is) = do
> unless t $ putStrLn "<table>"
> let sql' = "\n~~~~{.sql}\n" ++ sql ++ "\n~~~~\n"
> hask' = "\n~~~~{.haskell}\n" ++ hask ++ "\n~~~~\n"
> putStrLn $ "<tr><td>" ++ sql'
> ++ "</td><td>" ++ hask' ++ "</td></tr>"
> unless t $ putStrLn "[cols=\"2\"]\n|==="
> let sql' = "\n[source,sql]\n----\n" ++ sql ++ "\n----\n"
> hask' = "\n[source,haskell]\n----\n" ++ hask ++ "\n----\n"
> putStrLn $ "a| " ++ escapePipe sql'
> ++ "a| " ++ escapePipe hask' ++ " "
> go True is
> go t [] = when t $ putStrLn "</table>"
> go t [] = when t $ putStrLn "|==="
> escapePipe [] = []
> escapePipe ('\\':'|':xs) = '\\' : '\\' : '\\' : '|' : escapePipe xs
> escapePipe ('|':xs) = '\\' : '|' : escapePipe xs
> escapePipe (x:xs) = x : escapePipe xs
> main :: IO ()
> main = render $ doc 1 testData
> main = do
> putStrLn "\n:toc:\n\
> \:toc-placement: macro\n\
> \:sectnums:\n\
> \:toclevels: 10\n\
> \:sectnumlevels: 10\n\
> \:source-highlighter: pygments\n\n\
> \= simple-sql-parser examples/test cases\n\n\
> \toc::[]\n"
> render $ doc 1 testData