From a58baa64c340f16135debe14e09b126bf89b0261 Mon Sep 17 00:00:00 2001 From: bouncepaw Date: Tue, 3 Nov 2020 20:47:22 +0500 Subject: [PATCH] Add numbered lists --- markup/lexer.go | 22 ++++++++++++++++++++++ metarrhiza | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/markup/lexer.go b/markup/lexer.go index d71e497..2f1d3fc 100644 --- a/markup/lexer.go +++ b/markup/lexer.go @@ -107,6 +107,8 @@ func geminiLineToAST(line string, state *GemLexerState, ast *[]Line) { goto preformattedState case "list": goto listState + case "number": + goto numberState default: goto normalState } @@ -146,6 +148,22 @@ listState: } return +numberState: + switch { + case startsWith("*. "): + state.buf += fmt.Sprintf("\t
  • %s
  • \n", ParagraphToHtml(line[2:])) + case startsWith("```"): + state.where = "pre" + addLine(state.buf + "") + state.id++ + state.buf = fmt.Sprintf("
    ", state.id, strings.TrimPrefix(line, "```"))
    +	default:
    +		state.where = ""
    +		addLine(state.buf + "")
    +		goto normalState
    +	}
    +	return
    +
     normalState:
     	state.id++
     	switch {
    @@ -157,6 +175,10 @@ normalState:
     		state.where = "list"
     		state.buf = fmt.Sprintf("
      \n", state.id) goto listState + case startsWith("*. "): + state.where = "number" + state.buf = fmt.Sprintf("
        \n", state.id) + goto numberState case startsWith("###### "): addLine(fmt.Sprintf( diff --git a/metarrhiza b/metarrhiza index a54be90..9fa5334 160000 --- a/metarrhiza +++ b/metarrhiza @@ -1 +1 @@ -Subproject commit a54be905923b10524d74435fb62dbdd9a0aac06a +Subproject commit 9fa5334ee958c02fbb327c002bf646e648a5a1be