Fix shortcode in markdown headers

This issue was introduced as a fix to shortcode not working in RST.

One could argue that Blackfriday and friends should handle `#` in titles, but that will be a discussion
for another day.

The new placeholder pattern should be RST safe and work with titles.

And now with a test so this doesn't break again.

Fixes #2192
Fixes #2209
Closes #2210
This commit is contained in:
Bjørn Erik Pedersen
2016-06-13 19:10:53 +02:00
parent 6ba074562c
commit 34f40044d7
3 changed files with 42 additions and 38 deletions

View File

@@ -197,7 +197,7 @@ func isInnerShortcode(t *template.Template) (bool, error) {
}
func createShortcodePlaceholder(id int) string {
return fmt.Sprintf("{#{#%s-%d#}#}", shortcodePlaceholderPrefix, id)
return fmt.Sprintf("{-{-%s-%d-}-}", shortcodePlaceholderPrefix, id)
}
const innerNewlineRegexp = "\n"
@@ -507,8 +507,8 @@ func replaceShortcodeTokens(source []byte, prefix string, replacements map[strin
sourceLen := len(source)
start := 0
pre := []byte("{#{#" + prefix)
post := []byte("#}#}")
pre := []byte("{-{-" + prefix)
post := []byte("-}-}")
pStart := []byte("<p>")
pEnd := []byte("</p>")