diff options
| -rw-r--r-- | markdown/ast_external.go | 4 | ||||
| -rw-r--r-- | markdown/ast_external_test.go | 4 | ||||
| -rw-r--r-- | markdown/ast_quote.go | 2 | ||||
| -rw-r--r-- | markdown/lexer.go | 2 |
4 files changed, 7 insertions, 5 deletions
diff --git a/markdown/ast_external.go b/markdown/ast_external.go index a172b2b..ea78450 100644 --- a/markdown/ast_external.go +++ b/markdown/ast_external.go @@ -119,7 +119,7 @@ func parseExternal(lxs *lexers, withSource bool) (string, string, []*astParagrap return "", "", nil, false } n += len(lxs.Current().Value) - if first != "" && end != "" { + if n < 2 && first != "" && end != "" { if !lxs.Next() { return first, end, ps, true } @@ -127,8 +127,8 @@ func parseExternal(lxs *lexers, withSource bool) (string, string, []*astParagrap if !ok { return "", "", nil, false } - lxs.Before() // because we must parse lexerBreak } + lxs.Before() // because we must parse lexerBreak and the next call must parse the next value case lexerExternal: if first != "" && end != "" { return "", "", nil, false diff --git a/markdown/ast_external_test.go b/markdown/ast_external_test.go index 6de512b..306b9d0 100644 --- a/markdown/ast_external_test.go +++ b/markdown/ast_external_test.go @@ -33,6 +33,8 @@ func TestExternal(t *testing.T) {  source 1 source 2 + +Hors de la source `) tree, err = ast(lxs) if err != nil { @@ -42,7 +44,7 @@ source 2 if err != nil { t.Fatal(err) } - if string(got) != `<figure><img alt="image alt" src="image src"><figcaption>source 1 source 2</figcaption></figure>` { + if string(got) != `<figure><img alt="image alt" src="image src"><figcaption>source 1 source 2</figcaption></figure><p>Hors de la source</p>` { t.Errorf("invalid value, got %s", got) } diff --git a/markdown/ast_quote.go b/markdown/ast_quote.go index 3dfede1..3040636 100644 --- a/markdown/ast_quote.go +++ b/markdown/ast_quote.go @@ -54,7 +54,7 @@ func quote(lxs *lexers) (*astQuote, *ParseError) { return tree, nil } quoteContinue = true - case lexerLiteral, lexerModifier, lexerCode: + case lexerLiteral, lexerModifier, lexerCode, lexerExternal: n = 0 if !quoteContinue { source = true diff --git a/markdown/lexer.go b/markdown/lexer.go index a02ec54..651e3aa 100644 --- a/markdown/lexer.go +++ b/markdown/lexer.go @@ -25,7 +25,7 @@ type lexer struct { Value string } -func (l *lexer) String() string { +func (l lexer) String() string { return fmt.Sprintf("%s(%s)", l.Type, l.Value) } |
