This commit is contained in:
yuin 2022-02-08 17:15:15 +09:00
parent d44b18596f
commit f6e93ffd8f
4 changed files with 36 additions and 7 deletions

View file

@ -684,3 +684,22 @@ This line will be displayed.
<video autoplay muted loop>\r\n<source src=\"https://example.com/example.mp4\" type=\"video/mp4\">\r\nYour browser does not support the video tag.\r\n</video>
//= = = = = = = = = = = = = = = = = = = = = = = =//
53: HTML comment without trailing new lines
OPTIONS: {"trim": true}
//- - - - - - - - -//
<!--
-->
//- - - - - - - - -//
<!--
-->
//= = = = = = = = = = = = = = = = = = = = = = = =//
54: Escaped characters followed by a null character
OPTIONS: {"enableEscape": true}
//- - - - - - - - -//
\\\x00\"
//- - - - - - - - -//
<p>\\\ufffd&quot;</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -201,7 +201,7 @@ func (b *htmlBlockParser) Continue(node ast.Node, reader text.Reader, pc Context
}
if bytes.Contains(line, closurePattern) {
htmlBlock.ClosureLine = segment
reader.Advance(segment.Len() - 1)
reader.Advance(segment.Len())
return Close
}

View file

@ -743,6 +743,7 @@ func (d *defaultWriter) Write(writer util.BufWriter, source []byte) {
d.RawWrite(writer, source[n:i])
d.RawWrite(writer, replacementCharacter)
n = i + 1
escaped = false
continue
}
if c == '&' {

View file

@ -35,22 +35,31 @@ type MarkdownTestCase struct {
}
func source(t *MarkdownTestCase) string {
if t.Options.EnableEscape {
return string(applyEscapeSequence([]byte(t.Markdown)))
ret := t.Markdown
if t.Options.Trim {
ret = strings.TrimSpace(ret)
}
return t.Markdown
if t.Options.EnableEscape {
return string(applyEscapeSequence([]byte(ret)))
}
return ret
}
func expected(t *MarkdownTestCase) string {
if t.Options.EnableEscape {
return string(applyEscapeSequence([]byte(t.Expected)))
ret := t.Expected
if t.Options.Trim {
ret = strings.TrimSpace(ret)
}
return t.Expected
if t.Options.EnableEscape {
return string(applyEscapeSequence([]byte(ret)))
}
return ret
}
// MarkdownTestCaseOptions represents options for each test case.
type MarkdownTestCaseOptions struct {
EnableEscape bool
Trim bool
}
const attributeSeparator = "//- - - - - - - - -//"