mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
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:
parent
39b8ed198a
commit
e0fc1a0cb1
7
block.go
7
block.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user