Skip to content

Commit

Permalink
Merge pull request #4834 from jfdm/fix-literate
Browse files Browse the repository at this point in the history
Fix subtle bug in `Text.Literate`.
  • Loading branch information
jfdm committed Mar 28, 2020
2 parents c6c928f + c80ef9f commit ecb49fa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/contrib/Text/Literate.idr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ line : String -> Lexer
line s = exact s <+> space <+> untilEOL

block : String -> String -> Lexer
block s e = exact s <+> manyUntil (exact e) any
block s e = surround (exact s) (exact e) any

data Token = CodeBlock String String String
| Any String
Expand Down Expand Up @@ -76,7 +76,7 @@ reduce (MkToken _ _ (CodeBlock l r src) :: rest) acc with (lines src) -- Strip t
reduce (MkToken _ _ (CodeBlock l r src) :: rest) acc | (s :: ys) with (snocList ys)
reduce (MkToken _ _ (CodeBlock l r src) :: rest) acc | (s :: []) | Empty = reduce rest acc -- 2
reduce (MkToken _ _ (CodeBlock l r src) :: rest) acc | (s :: (srcs ++ [f])) | (Snoc rec) =
reduce rest (acc ++ "\n" ++ unlines srcs ++ "\n")
reduce rest (acc ++ unlines srcs)

-- [ NOTE ] 1 & 2 shouldn't happen as code blocks are well formed i.e. have two deliminators.

Expand Down

0 comments on commit ecb49fa

Please sign in to comment.