Don't bother removing trailing newlines in code blocks

The code that collects the block bytes has already removed the trialing
newlines, so this heavyweight regexp machinery is actually doing
nothing.
This commit is contained in:
Vytautas Šaltenis 2016-09-10 12:21:53 +03:00
parent 39b8ed198a
commit e0fc1a0cb1

View File

@ -29,7 +29,6 @@ const (
var (
reBackslashOrAmp = regexp.MustCompile("[\\&]")
reEntityOrEscapedChar = regexp.MustCompile("(?i)\\\\" + escapable + "|" + charEntity)
reTrailingWhitespace = regexp.MustCompile("(\n *)+$")
)
// Parse block-level data.
@ -419,8 +418,8 @@ func (p *parser) html(data []byte, doRender bool) int {
}
func finalizeHTMLBlock(block *Node) {
block.Literal = reTrailingWhitespace.ReplaceAll(block.content, []byte{})
block.content = []byte{}
block.Literal = block.content
block.content = nil
}
// HTML comment, lax form
@ -739,7 +738,7 @@ func finalizeCodeBlock(block *Node) {
block.Info = unescapeString(bytes.Trim(firstLine, "\n"))
block.Literal = rest
} else {
block.Literal = reTrailingWhitespace.ReplaceAll(block.content, []byte{'\n'})
block.Literal = block.content
}
block.content = nil
}