diff --git a/hugolib/page.go b/hugolib/page.go index dedbfa7fb..2c423c5bb 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -587,20 +587,42 @@ func (page *Page) Convert() error { func markdownRender(content []byte) []byte { htmlFlags := 0 htmlFlags |= blackfriday.HTML_SKIP_SCRIPT + htmlFlags |= blackfriday.HTML_USE_XHTML htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS + htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS + htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES renderer := blackfriday.HtmlRenderer(htmlFlags, "", "") - return blackfriday.Markdown(content, renderer, 0) + extensions := 0 + extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS + extensions |= blackfriday.EXTENSION_TABLES + extensions |= blackfriday.EXTENSION_FENCED_CODE + extensions |= blackfriday.EXTENSION_AUTOLINK + extensions |= blackfriday.EXTENSION_STRIKETHROUGH + extensions |= blackfriday.EXTENSION_SPACE_HEADERS + + return blackfriday.Markdown(content, renderer, extensions) } func markdownRenderWithTOC(content []byte) []byte { htmlFlags := 0 htmlFlags |= blackfriday.HTML_SKIP_SCRIPT htmlFlags |= blackfriday.HTML_TOC + htmlFlags |= blackfriday.HTML_USE_XHTML htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS + htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS + htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES renderer := blackfriday.HtmlRenderer(htmlFlags, "", "") - return blackfriday.Markdown(content, renderer, 0) + extensions := 0 + extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS + extensions |= blackfriday.EXTENSION_TABLES + extensions |= blackfriday.EXTENSION_FENCED_CODE + extensions |= blackfriday.EXTENSION_AUTOLINK + extensions |= blackfriday.EXTENSION_STRIKETHROUGH + extensions |= blackfriday.EXTENSION_SPACE_HEADERS + + return blackfriday.Markdown(content, renderer, extensions) } func extractTOC(content []byte) (newcontent []byte, toc []byte) { diff --git a/hugolib/page_test.go b/hugolib/page_test.go index e369aa351..b140b6593 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -344,7 +344,7 @@ func TestTableOfContents(t *testing.T) { if err != nil { t.Fatalf("Unable to create a page with frontmatter and body content: %s", err) } - checkPageContent(t, p, "\n\n
For some moments the old man did not reply. He stood with bowed head, buried in deep thought. But at last he spoke.
\n\nI have no idea, of course, how long it took me to reach the limit of the plain,\nbut at last I entered the foothills, following a pretty little canyon upward\ntoward the mountains. Beside me frolicked a laughing brooklet, hurrying upon\nits noisy way down to the silent sea. In its quieter pools I discovered many\nsmall fish, of four-or five-pound weight I should imagine. In appearance,\nexcept as to size and color, they were not unlike the whale of our own seas. As\nI watched them playing about I discovered, not only that they suckled their\nyoung, but that at intervals they rose to the surface to breathe as well as to\nfeed upon certain grasses and a strange, scarlet lichen which grew upon the\nrocks just above the water line.
\n\nI remember I felt an extraordinary persuasion that I was being played with,\nthat presently, when I was upon the very verge of safety, this mysterious\ndeath—as swift as the passage of light—would leap after me from the pit about\nthe cylinder and strike me down. ## BB
\n\n“You’re a great Granser,” he cried delightedly, “always making believe them little marks mean something.”
\n") + checkPageContent(t, p, "\n\nFor some moments the old man did not reply. He stood with bowed head, buried in deep thought. But at last he spoke.
\n\nI have no idea, of course, how long it took me to reach the limit of the plain,\nbut at last I entered the foothills, following a pretty little canyon upward\ntoward the mountains. Beside me frolicked a laughing brooklet, hurrying upon\nits noisy way down to the silent sea. In its quieter pools I discovered many\nsmall fish, of four-or five-pound weight I should imagine. In appearance,\nexcept as to size and color, they were not unlike the whale of our own seas. As\nI watched them playing about I discovered, not only that they suckled their\nyoung, but that at intervals they rose to the surface to breathe as well as to\nfeed upon certain grasses and a strange, scarlet lichen which grew upon the\nrocks just above the water line.
\n\nI remember I felt an extraordinary persuasion that I was being played with,\nthat presently, when I was upon the very verge of safety, this mysterious\ndeath–as swift as the passage of light–would leap after me from the pit about\nthe cylinder and strike me down. ## BB
\n\n“You’re a great Granser,” he cried delightedly, “always making believe them little marks mean something.”
\n") checkPageTOC(t, p, "") }