Allow the same shortcode to be used with or without inline content

Fixes #934
This commit is contained in:
bep
2015-03-02 21:23:16 +01:00
parent 241f9f9e46
commit ab5862cd00
4 changed files with 19 additions and 3 deletions

View File

@@ -184,6 +184,9 @@ func TestExtractShortcodes(t *testing.T) {
testScPlaceholderRegexp, ""},
{"inner", `Some text. {{< inner >}}Inner Content{{< / inner >}}. Some more text.`, `inner([], false){[Inner Content]}`,
fmt.Sprintf("Some text. %s. Some more text.", testScPlaceholderRegexp), ""},
// issue #934
{"inner self-closing", `Some text. {{< inner />}}. Some more text.`, `inner([], false){[]}`,
fmt.Sprintf("Some text. %s. Some more text.", testScPlaceholderRegexp), ""},
{"close, but not inner", "{{< tag >}}foo{{< /tag >}}", "", false, "Shortcode 'tag' in page 'simple.md' has no .Inner.*"},
{"nested inner", `Inner->{{< inner >}}Inner Content->{{% inner2 param1 %}}inner2txt{{% /inner2 %}}Inner close->{{< / inner >}}<-done`,
`inner([], false){[Inner Content-> inner2([\"param1\"], true){[inner2txt]} Inner close->]}`,
@@ -212,7 +215,7 @@ func TestExtractShortcodes(t *testing.T) {
tem.AddInternalShortcode("tag.html", `tag`)
tem.AddInternalShortcode("sc1.html", `sc1`)
tem.AddInternalShortcode("sc2.html", `sc2`)
tem.AddInternalShortcode("inner.html", `{{.Inner}}`)
tem.AddInternalShortcode("inner.html", `{{with .Inner }}{{ . }}{{ end }}`)
tem.AddInternalShortcode("inner2.html", `{{.Inner}}`)
tem.AddInternalShortcode("inner3.html", `{{.Inner}}`)