aboutsummaryrefslogtreecommitdiff
path: root/mardown
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-09-30 21:00:51 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2025-09-30 21:00:51 +0200
commit3d3ccdec245b5a5d1c1f01d0b6972959332c882e (patch)
treeef4e94c4711590ff85bc326bbed848740ef14584 /mardown
parente20acb05fd33b8fbcfafee4b72734224093c2d20 (diff)
fix(markdown): wrong return in lexer next
Diffstat (limited to 'mardown')
-rw-r--r--mardown/ast.go10
-rw-r--r--mardown/ast_header.go2
-rw-r--r--mardown/ast_modifier.go2
-rw-r--r--mardown/ast_paragraph.go2
-rw-r--r--mardown/lexer.go4
5 files changed, 10 insertions, 10 deletions
diff --git a/mardown/ast.go b/mardown/ast.go
index 731dea9..d9d2b1d 100644
--- a/mardown/ast.go
+++ b/mardown/ast.go
@@ -20,7 +20,7 @@ func (t *tree) Eval() (template.HTML, error) {
return "", nil
}
-func ast(lxs lexers) (*tree, error) {
+func ast(lxs *lexers) (*tree, error) {
tr := new(tree)
newLine := false
for lxs.Next() {
@@ -34,7 +34,7 @@ func ast(lxs lexers) (*tree, error) {
return tr, nil
}
-func getBlock(lxs lexers, newLine bool) (block, error) {
+func getBlock(lxs *lexers, newLine bool) (block, error) {
var b block
var err error
switch lxs.Current().Type {
@@ -48,17 +48,17 @@ func getBlock(lxs lexers, newLine bool) (block, error) {
if newLine && lxs.Current().Value == "!" {
//TODO: handle
} else {
- b, err = paragraph(lxs)
+ b, err = paragraph(lxs, false)
}
case lexerQuote:
case lexerCode:
if newLine && len(lxs.Current().Value) == 3 {
//TODO: handle
} else {
- b, err = paragraph(lxs)
+ b, err = paragraph(lxs, false)
}
case lexerLiteral, lexerEscape, lexerModifier:
- b, err = paragraph(lxs)
+ b, err = paragraph(lxs, false)
case lexerBreak: // do nothing
default:
err = errors.Join(ErrUnkownLexType, fmt.Errorf("type received: %s", lxs.Current().Type))
diff --git a/mardown/ast_header.go b/mardown/ast_header.go
index 1526efa..28a0a25 100644
--- a/mardown/ast_header.go
+++ b/mardown/ast_header.go
@@ -25,7 +25,7 @@ func (a *astHeader) Eval() (template.HTML, error) {
return template.HTML(fmt.Sprintf("<h%d>%s</h%d>", a.level, content, a.level)), nil
}
-func header(lxs lexers) (*astHeader, error) {
+func header(lxs *lexers) (*astHeader, error) {
b := &astHeader{level: uint(len(lxs.Current().Value))}
var err error
b.content, err = paragraph(lxs, true)
diff --git a/mardown/ast_modifier.go b/mardown/ast_modifier.go
index e505aef..b9e53a1 100644
--- a/mardown/ast_modifier.go
+++ b/mardown/ast_modifier.go
@@ -39,7 +39,7 @@ func (a *astModifier) Eval() (template.HTML, error) {
return template.HTML(fmt.Sprintf("<%s>%s</%s>", a.tag, content, a.tag)), nil
}
-func modifier(lxs lexers) (*astModifier, error) {
+func modifier(lxs *lexers) (*astModifier, error) {
current := lxs.Current().Value
mod := modifierDetect(current)
modInside := mod
diff --git a/mardown/ast_paragraph.go b/mardown/ast_paragraph.go
index 3c8f985..24b7057 100644
--- a/mardown/ast_paragraph.go
+++ b/mardown/ast_paragraph.go
@@ -31,7 +31,7 @@ func (a *astParagraph) Eval() (template.HTML, error) {
return template.HTML(fmt.Sprintf("<p>%s</p>", content)), nil
}
-func paragraph(lxs lexers, oneLine bool) (*astParagraph, error) {
+func paragraph(lxs *lexers, oneLine bool) (*astParagraph, error) {
tree := new(astParagraph)
tree.oneLine = oneLine
maxBreak := 2
diff --git a/mardown/lexer.go b/mardown/lexer.go
index afac4d7..7ab393f 100644
--- a/mardown/lexer.go
+++ b/mardown/lexer.go
@@ -34,7 +34,7 @@ type lexers struct {
func (l *lexers) Next() bool {
l.current++
- return l.Finished()
+ return !l.Finished()
}
func (l *lexers) Current() lexer {
@@ -42,7 +42,7 @@ func (l *lexers) Current() lexer {
}
func (l *lexers) Finished() bool {
- return l.current+1 >= len(l.lexers)
+ return l.current >= len(l.lexers)-1
}
func (l *lexers) String() string {