Skip to content

Commit

Permalink
Fixes #28, #29
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed Nov 16, 2019
1 parent ea8789f commit afc3654
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 19 additions & 2 deletions extra_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
package goldmark_test

import (
"bytes"
"testing"

. "github.com/yuin/goldmark"
"github.com/yuin/goldmark/testutil"
"github.com/yuin/goldmark/renderer/html"
"github.com/yuin/goldmark/testutil"
)

func TestDefinitionList(t *testing.T) {
func TestExtras(t *testing.T) {
markdown := New(WithRendererOptions(
html.WithXHTML(),
html.WithUnsafe(),
))
testutil.DoTestCaseFile(markdown, "_test/extra.txt", t)
}

func TestEndsWithNonSpaceCharacters(t *testing.T) {
markdown := New(WithRendererOptions(
html.WithXHTML(),
html.WithUnsafe(),
))
source := []byte("```\na\n```")
var b bytes.Buffer
err := markdown.Convert(source, &b)
if err != nil {
t.Error(err.Error())
}
if b.String() != "<pre><code>a\n</code></pre>\n" {
t.Errorf("%s \n---------\n %s", source, b.String())
}
}
6 changes: 5 additions & 1 deletion parser/fcode_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc C
}
length := i - pos
if length >= fdata.length && util.IsBlank(line[i:]) {
reader.Advance(segment.Stop - segment.Start - 1 - segment.Padding)
newline := 1
if line[len(line)-1] != '\n' {
newline = 0
}
reader.Advance(segment.Stop - segment.Start - newline - segment.Padding)
return Close
}
}
Expand Down

0 comments on commit afc3654

Please sign in to comment.