summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Weave.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Weave.hs b/src/Weave.hs
index f10617f..f2d7836 100644
--- a/src/Weave.hs
+++ b/src/Weave.hs
@@ -23,9 +23,19 @@ weaveFragment :: Fragment -> String
weaveFragment (Documentation text) = text
weaveFragment (BlockCode name body) =
"\\begin{LytBlockCode}{" ++ name ++ "}\n"
- ++ concatMap weaveCodeOrReference body
+ ++ weaveBlockBody body
++ "\\end{LytBlockCode}\n"
+weaveBlockBody :: [CodeOrReference] -> String
+weaveBlockBody ((Code first):rest) =
+ {- The first block is code. To make sure it gets typeset correctly, drop
+ everything up to the first newline or non-space character. -}
+ (case dropWhile (==' ') first of
+ '\n' : first' -> first'
+ first' -> first')
+ ++ concatMap weaveCodeOrReference rest
+weaveBlockBody blocks = concatMap weaveCodeOrReference blocks
+
weaveCodeOrReference :: CodeOrReference -> String
weaveCodeOrReference (Code text) = text
weaveCodeOrReference (Reference name) = "\\LytFragmentReference{" ++ name ++ "}"