From 351308fb72b28dfdc03f8f8fccbc7ff06800d1c0 Mon Sep 17 00:00:00 2001 From: yuin Date: Sat, 11 Sep 2021 11:20:50 +0900 Subject: [PATCH] Fix #245 - 4 --- _test/extra.txt | 10 +++++++++- renderer/html/html.go | 6 ++++++ testutil/testutil.go | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/_test/extra.txt b/_test/extra.txt index 8c9578f..1701fd5 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -381,9 +381,17 @@ a* b c d *e* //= = = = = = = = = = = = = = = = = = = = = = = =// -25: code block starts with tab +25: Indented code blocks can start with tab //- - - - - - - - -// x //- - - - - - - - -//
	x
//= = = = = = = = = = = = = = = = = = = = = = = =// + +26: NUL bytes must be replaced with U+FFFD + OPTIONS: {"enableEscape": true} +//- - - - - - - - -// +hello\x00world +//- - - - - - - - -// +

hello\ufffdworld

+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/renderer/html/html.go b/renderer/html/html.go index d8ff7e5..d0243cb 100644 --- a/renderer/html/html.go +++ b/renderer/html/html.go @@ -719,6 +719,12 @@ func (d *defaultWriter) Write(writer util.BufWriter, source []byte) { continue } } + if c == '\x00' { + d.RawWrite(writer, source[n:i]) + d.RawWrite(writer, []byte("\ufffd")) + n = i + 1 + continue + } if c == '&' { pos := i next := i + 1 diff --git a/testutil/testutil.go b/testutil/testutil.go index 91496fc..4827f5e 100644 --- a/testutil/testutil.go +++ b/testutil/testutil.go @@ -223,7 +223,7 @@ Diff if err := m.Convert([]byte(source(&testCase)), &out, opts...); err != nil { panic(err) } - ok = bytes.Equal(bytes.TrimSpace(out.Bytes()), []byte(expected(&testCase))) + ok = bytes.Equal(bytes.TrimSpace(out.Bytes()), bytes.TrimSpace([]byte(expected(&testCase)))) } type diffType int