From 8dfd2fcf9bdfe9957106d4ded4cec39b864ce8af Mon Sep 17 00:00:00 2001 From: hugmouse Date: Fri, 5 Mar 2021 14:34:56 +0800 Subject: [PATCH] Fix lexer for "----" (
) case The point is that there may be another character in the string. For example, a space or a line break. Because we check the whole string, not the first 4 characters - we can ignore the variant where it can be "----\s" or "----\r\n" and make the wrong markup. Alternatively: use `startsWith("----")`, but this is a bit more expensive operation. --- markup/lexer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markup/lexer.go b/markup/lexer.go index 607393f..fbd87fc 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -235,7 +235,7 @@ normalState: case startsWith("<="): addParagraphIfNeeded() addLine(parseTransclusion(line, state.name)) - case line == "----": + case line[:4] == "----": addParagraphIfNeeded() *ast = append(*ast, Line{id: -1, contents: "
"}) case MatchesImg(line):