diff --git a/hugolib/helpers.go b/hugolib/helpers.go index cf84835fd..feed341e5 100644 --- a/hugolib/helpers.go +++ b/hugolib/helpers.go @@ -270,6 +270,10 @@ func WordCount(s string) map[string]int { return m } +func RemoveSummaryDivider(content []byte) []byte { + return bytes.Replace(content, summaryDivider, []byte(""), -1) +} + func StripHTML(s string) string { output := "" diff --git a/hugolib/page.go b/hugolib/page.go index 409da23bc..eb8f142b3 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -481,7 +481,7 @@ func (page *Page) convertMarkdown(lines io.Reader) { b := new(bytes.Buffer) b.ReadFrom(lines) content := b.Bytes() - page.Content = template.HTML(string(blackfriday.MarkdownCommon(content))) + page.Content = template.HTML(string(blackfriday.MarkdownCommon(RemoveSummaryDivider(content)))) summary, plain := getSummaryString(content) if plain { page.Summary = template.HTML(string(summary)) diff --git a/hugolib/page_test.go b/hugolib/page_test.go index a1c7c755d..4ffda4461 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -100,6 +100,14 @@ Simple Page Some more text ` +var SIMPLE_PAGE_WITH_SUMMARY_DELIMITER_SAME_LINE = `--- +title: Simple +--- +Simple Page + +Some more text +` + func checkError(t *testing.T, err error, expected string) { if err == nil { t.Fatalf("err is nil") @@ -175,7 +183,20 @@ func TestPageWithDelimiter(t *testing.T) { t.Fatalf("Unable to create a page with frontmatter and body content: %s", err) } checkPageTitle(t, p, "Simple") - checkPageContent(t, p, "
Simple Page
\n\n\n\nSome more text
\n") + checkPageContent(t, p, "Simple Page
\n\nSome more text
\n") + checkPageSummary(t, p, "Simple Page
\n") + checkPageType(t, p, "page") + checkPageLayout(t, p, "page/single.html") + +} + +func TestPageWithMoreTag(t *testing.T) { + p, err := ReadFrom(strings.NewReader(SIMPLE_PAGE_WITH_SUMMARY_DELIMITER_SAME_LINE), "simple") + if err != nil { + t.Fatalf("Unable to create a page with frontmatter and body content: %s", err) + } + checkPageTitle(t, p, "Simple") + checkPageContent(t, p, "Simple Page
\n\nSome more text
\n") checkPageSummary(t, p, "Simple Page
\n") checkPageType(t, p, "page") checkPageLayout(t, p, "page/single.html") diff --git a/hugolib/site.go b/hugolib/site.go index 73862a383..8bf8d0c06 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -31,16 +31,16 @@ import ( var DefaultTimer = nitro.Initalize() type Site struct { - Config Config - Pages Pages - Tmpl *template.Template - Indexes IndexList - Files []string - Sections Index - Info SiteInfo - Shortcodes map[string]ShortcodeFunc - timer *nitro.B - Target target.Publisher + Config Config + Pages Pages + Tmpl *template.Template + Indexes IndexList + Files []string + Sections Index + Info SiteInfo + Shortcodes map[string]ShortcodeFunc + timer *nitro.B + Target target.Publisher } type SiteInfo struct {