From 55597dddf25b7bc5f9f07bd3d45154dea9eb7f0e Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Tue, 3 Nov 2020 21:10:17 +0500 Subject: [PATCH] Fix some lexer bugs --- markup/lexer.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/markup/lexer.go b/markup/lexer.go index 2f1d3fc..c6fe504 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -53,14 +53,14 @@ func wikilink(src string, state *GemLexerState) (href, text, class string) { hyphaName := canonicalName(path.Join( state.name, strings.TrimPrefix(href, "./"))) if !HyphaExists(hyphaName) { - class = "wikilink_new" + class += " wikilink_new" } href = path.Join("/page", hyphaName) case strings.HasPrefix(href, "../"): hyphaName := canonicalName(path.Join( path.Dir(state.name), strings.TrimPrefix(href, "../"))) if !HyphaExists(hyphaName) { - class = "wikilink_new" + class += " wikilink_new" } href = path.Join("/page", hyphaName) case strings.HasPrefix(href, "/"): @@ -68,6 +68,9 @@ func wikilink(src string, state *GemLexerState) (href, text, class string) { class = "wikilink_external" default: href = path.Join("/page", href) + if !HyphaExists(href) { + class += " wikilink_new" + } } return href, strings.TrimSpace(text), class } @@ -88,7 +91,7 @@ func geminiLineToAST(line string, state *GemLexerState, ast *[]Line) { } if "" == strings.TrimSpace(line) { - if state.where == "list" { + if state.where == "list" || state.where == "number" { state.where = "" addLine(state.buf + "") } @@ -151,7 +154,7 @@ listState: numberState: switch { case startsWith("*. "): - state.buf += fmt.Sprintf("\t
  • %s
  • \n", ParagraphToHtml(line[2:])) + state.buf += fmt.Sprintf("\t
  • %s
  • \n", ParagraphToHtml(line[3:])) case startsWith("```"): state.where = "pre" addLine(state.buf + "")