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.
Vytautas Ĺ altenis vytas@rtfb.lt
Sat, 10 Sep 2016 12:21:53 +0300
1 files changed,
3 insertions(+),
4 deletions(-)
jump to
M
block.go
→
block.go
@@ -29,7 +29,6 @@
var ( reBackslashOrAmp = regexp.MustCompile("[\\&]") reEntityOrEscapedChar = regexp.MustCompile("(?i)\\\\" + escapable + "|" + charEntity) - reTrailingWhitespace = regexp.MustCompile("(\n *)+$") ) // Parse block-level data.@@ -419,8 +418,8 @@ return i
} 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 @@ rest := block.content[newlinePos+1:]
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 }