Paragraph testing

This commit is contained in:
Nathan McCarty 2025-02-27 04:41:09 -05:00
parent 135b878233
commit 2e66b03baa
10 changed files with 80 additions and 2 deletions

View file

@ -127,4 +127,14 @@ golden input ref = do
-- @@test Paragraph Smoke
smokeParagraph : IO Bool
smokeParagraph = golden "Hello World!" [Paragraph [Text "Hello World!"]]
smokeParagraph =
golden
"Hello World!"
[Paragraph [Text "Hello World!"]]
-- @@test Two Paragraph Smoke
smokeTwoParagraph : IO Bool
smokeTwoParagraph =
golden
"Hello World!\n\nHello Alice!"
[Paragraph [Text "Hello World!"], Paragraph [Text "Hello Alice!"]]

View file

@ -47,7 +47,11 @@ slurp predicate = do
if predicate line
then do
_ <- take
slurp predicate
Just next <- peek
| _ => pure []
if predicate next
then slurp predicate
else pure []
else do
Just x <- take
| _ => pure []

View file

@ -30,6 +30,7 @@ renderBlock (Paragraph content) =
renderBlocks xs = dMap' (\_, x => renderBlock x) xs
||| Render a complete html document from a list of block level elements
export
renderDocument : {types : _} -> DList _ Block types -> Html "html"
renderDocument xs =
Normal "html" ["lang" =$ "en"] [

View file

@ -5,4 +5,5 @@ import Test.Golden.RunnerHelper
main : IO ()
main = goldenRunner
[ "Hedgehog Tests" `atDir` "hedgehog"
, "Djot -> HTML Tests" `atDir` "djotToHtml"
]

View file

@ -0,0 +1,18 @@
module Main
import SSG.Djot
import SSG.HTML
import System
import System.File
main : IO ()
main = do
Right contents <- readFile "./test.dj"
| Left err => do
printLn err
exitFailure
let (_ ** blocks) = block contents
let html = renderDocument blocks
let output = render html
putStrLn output

View file

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html lang=en>
<body>
<p>Hello World!</p>
<p>Hello Alice!</p>
<p>A Multi-line
Paragraph</p>
<p>Two line breaks</p>
<p>A multiline paragraph
with some indentation</p>
</body>
</html>

View file

@ -0,0 +1,5 @@
[custom.all.SSG]
type = "local"
path = "../../.."
ipkg = "SSG.ipkg"
test = "test/test.ipkg"

View file

@ -0,0 +1,6 @@
rm -rf build/
flock "$1" pack -q install-deps test.ipkg
pack -q run test.ipkg
rm -rf build/

View file

@ -0,0 +1,12 @@
Hello World!
Hello Alice!
A Multi-line
Paragraph
Two line breaks
A multiline paragraph
with some indentation

View file

@ -0,0 +1,9 @@
package a-test
depends = SSG
, hedgehog
, eff
main = Main
executable = test