Remove superfluous p-tags around shortcodes
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 21 Jun 2015 11:08:30 +0000 (13:08 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 21 Jun 2015 20:51:12 +0000 (22:51 +0200)
commit004fcddc806d5a05a6d1a908f6ef902ef76aba06
tree81da2cecea6f8f56e3522c66e5043a8f3e777393
parentae4f72b091cb218842ef26dc032f2bac45ff3cc0
Remove superfluous p-tags around shortcodes

This commit replaces the regexp driven `replaceShortcodeTokens` with a handwritten one.

It wasnt't possible to handle the p-tags case without breaking performance.

This fix actually improves in that area:

```
benchmark                           old ns/op     new ns/op     delta
BenchmarkParsePage                  142738        142667        -0.05%
BenchmarkReplaceShortcodeTokens     665590        575645        -13.51%
BenchmarkShortcodeLexer             176038        181074        +2.86%

benchmark                           old allocs     new allocs     delta
BenchmarkParsePage                  87             87             +0.00%
BenchmarkReplaceShortcodeTokens     9631           9424           -2.15%
BenchmarkShortcodeLexer             274            274            +0.00%

benchmark                           old bytes     new bytes     delta
BenchmarkParsePage                  141830        141830        +0.00%
BenchmarkReplaceShortcodeTokens     52275         35219         -32.63%
BenchmarkShortcodeLexer             30177         30178         +0.00%
```

Fixes #1148
hugolib/handler_page.go
hugolib/page.go
hugolib/shortcode.go
hugolib/shortcode_test.go
hugolib/site_test.go