all repos — grayfriday @ e0fc1a0cb129d15ec82c8782d6c9424b1b3aae98

blackfriday fork with a few changes

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
commit

e0fc1a0cb129d15ec82c8782d6c9424b1b3aae98

parent

39b8ed198a70e25ec9e861f7f54167055a1d1d8c

1 files changed, 3 insertions(+), 4 deletions(-)

jump to
M block.goblock.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 }