diff --git a/markup/lexer.go b/markup/lexer.go index b69a3cf..4dae95b 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -51,6 +51,13 @@ func lineToAST(line string, state *GemLexerState, ast *[]Line) { addLine := func(text interface{}) { *ast = append(*ast, Line{id: state.id, contents: text}) } + addParagraphIfNeeded := func() { + if state.where == "p" { + state.where = "" + addLine(fmt.Sprintf("
%s
", state.id, strings.ReplaceAll(ParagraphToHtml(state.name, state.buf), "\n", "", state.id, strings.TrimPrefix(line, "```"))
case startsWith("* "):
+ addParagraphIfNeeded()
state.where = "list"
state.buf = fmt.Sprintf("\n", state.id)
goto listState
case startsWith("*. "):
+ addParagraphIfNeeded()
state.where = "number"
state.buf = fmt.Sprintf("\n", state.id)
goto numberState
case startsWith("###### "):
+ addParagraphIfNeeded()
addHeading(6)
case startsWith("##### "):
+ addParagraphIfNeeded()
addHeading(5)
case startsWith("#### "):
+ addParagraphIfNeeded()
addHeading(4)
case startsWith("### "):
+ addParagraphIfNeeded()
addHeading(3)
case startsWith("## "):
+ addParagraphIfNeeded()
addHeading(2)
case startsWith("# "):
+ addParagraphIfNeeded()
addHeading(1)
case startsWith(">"):
+ addParagraphIfNeeded()
addLine(fmt.Sprintf(
"%s
", state.id, remover(">")(line)))
case startsWith("=>"):
+ addParagraphIfNeeded()
state.where = "launchpad"
state.buf = fmt.Sprintf("\n", state.id)
goto launchpadState
case startsWith("<="):
+ addParagraphIfNeeded()
addLine(parseTransclusion(line, state.name))
case line == "----":
+ addParagraphIfNeeded()
*ast = append(*ast, Line{id: -1, contents: "
"})
case MatchesImg(line):
+ addParagraphIfNeeded()
img, shouldGoBackToNormal := ImgFromFirstLine(line, state.name)
if shouldGoBackToNormal {
addLine(*img)
@@ -220,9 +243,14 @@ normalState:
state.img = img
}
case MatchesTable(line):
+ addParagraphIfNeeded()
state.where = "table"
state.table = TableFromFirstLine(line, state.name)
+
+ case state.where == "p":
+ state.buf += "\n" + line
default:
- addLine(fmt.Sprintf("%s
", state.id, ParagraphToHtml(state.name, line)))
+ state.where = "p"
+ state.buf = line
}
}
diff --git a/metarrhiza b/metarrhiza
index 95f48bf..b67144c 160000
--- a/metarrhiza
+++ b/metarrhiza
@@ -1 +1 @@
-Subproject commit 95f48bfd7a7cfef17d56cef207a770767d727950
+Subproject commit b67144cc770900104a652483c11cabfecc7325aa