diff --git a/parser/block.go b/parser/block.go index 3ef5334..f6e9da0 100644 --- a/parser/block.go +++ b/parser/block.go @@ -76,6 +76,7 @@ var ( "output": {}, "progress": {}, "section": {}, + "svg": {}, "video": {}, } ) diff --git a/parser/block_test.go b/parser/block_test.go new file mode 100644 index 0000000..4e0a808 --- /dev/null +++ b/parser/block_test.go @@ -0,0 +1,53 @@ +package parser + +import ( + "bytes" + "testing" + + "github.com/gomarkdown/markdown/ast" +) + +// Inside HTML, no Markdown is parsed. +func TestHtmlP(t *testing.T) { + input := "
*not emph*
\n" + p := NewWithExtensions(CommonExtensions) + doc := p.Parse([]byte(input)) + var buf bytes.Buffer + ast.Print(&buf, doc) + got := buf.String() + exp := "HTMLBlock '*not emph*
'\n" + if got != exp { + t.Errorf("\nInput [%#v]\nExpected[%#v]\nGot [%#v]\n", + input, exp, got) + } +} + +// Inside SVG, so the RECT element is passed through. +func TestSVG(t *testing.T) { + input := "\n" + p := NewWithExtensions(CommonExtensions) + doc := p.Parse([]byte(input)) + var buf bytes.Buffer + ast.Print(&buf, doc) + got := buf.String() + exp := "HTMLBlock ''\n" + if got != exp { + t.Errorf("\nInput [%#v]\nExpected[%#v]\nGot [%#v]\n", + input, exp, got) + } +} + +// The RECT element on its own is nothing special, so Markdown is parsed. +func TestRect(t *testing.T) { + input := "