Inner Shortcodes now treated as markdown. fixed #185
authorspf13 <steve.francia@gmail.com>
Thu, 28 Aug 2014 16:48:31 +0000 (12:48 -0400)
committerspf13 <steve.francia@gmail.com>
Thu, 28 Aug 2014 16:48:31 +0000 (12:48 -0400)
hugolib/shortcode.go
hugolib/shortcode_test.go

index bfbb1efdb2cfcff35e9cecc1672df4fe3bfe01fc..823426738a6f1d28c0bc09dd75a42d1b6bd66e71 100644 (file)
@@ -93,7 +93,7 @@ func ShortcodesHandle(stringToParse string, p *Page, t Template) string {
                        var data = &ShortcodeWithPage{Params: params, Page: p}
                        if endStart > 0 {
                                s := stringToParse[leadEnd+3 : leadEnd+endStart]
-                               data.Inner = template.HTML(CleanP(ShortcodesHandle(s, p, t)))
+                               data.Inner = template.HTML(renderBytes([]byte(CleanP(ShortcodesHandle(s, p, t))), p.guessMarkupType()))
                                remainder := CleanP(stringToParse[leadEnd+endEnd:])
 
                                return CleanP(stringToParse[:leadStart]) +
index 138d1a6c9c946d8e0272f62062770f210d89b9d5..115c70fddbd941ab5f08ddc72267e4768c4706be 100644 (file)
@@ -53,8 +53,20 @@ func TestInnerSC(t *testing.T) {
        tem.AddInternalShortcode("inside.html", `<div{{with .Get "class"}} class="{{.}}"{{end}}>{{ .Inner }}</div>`)
 
        CheckShortCodeMatch(t, `{{% inside class="aspen" %}}`, `<div class="aspen"></div>`, tem)
-       CheckShortCodeMatch(t, `{{% inside class="aspen" %}}More Here{{% /inside %}}`, `<div class="aspen">More Here</div>`, tem)
-       CheckShortCodeMatch(t, `{{% inside %}}More Here{{% /inside %}}`, `<div>More Here</div>`, tem)
+       CheckShortCodeMatch(t, `{{% inside class="aspen" %}}More Here{{% /inside %}}`, "<div class=\"aspen\"><p>More Here</p>\n</div>", tem)
+       CheckShortCodeMatch(t, `{{% inside %}}More Here{{% /inside %}}`, "<div><p>More Here</p>\n</div>", tem)
+}
+
+func TestInnerSCWithMarkdown(t *testing.T) {
+       tem := NewTemplate()
+       tem.AddInternalShortcode("inside.html", `<div{{with .Get "class"}} class="{{.}}"{{end}}>{{ .Inner }}</div>`)
+
+       CheckShortCodeMatch(t, `{{% inside %}}
+# More Here
+
+[link](http://spf13.com) and text
+
+{{% /inside %}}`, "<div><h1>More Here</h1>\n\n<p><a href=\"http://spf13.com\">link</a> and text</p>\n</div>", tem)
 }
 
 func TestEmbeddedSC(t *testing.T) {