diff --git a/helpers/content.go b/helpers/content.go index 96e84e5cf..9b46bbe83 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -69,15 +69,15 @@ func BytesToHTML(b []byte) template.HTML { return template.HTML(string(b)) } -func GetHtmlRenderer(defaultFlags int, footnoteref string) blackfriday.Renderer { +func GetHtmlRenderer(defaultFlags int, documentId string) blackfriday.Renderer { renderParameters := blackfriday.HtmlRendererParameters{ FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"), FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"), } - if len(footnoteref) != 0 { - renderParameters.FootnoteAnchorPrefix = footnoteref + ":" + - renderParameters.FootnoteAnchorPrefix + if len(documentId) != 0 { + renderParameters.FootnoteAnchorPrefix = documentId + ":" + renderParameters.FootnoteAnchorPrefix + renderParameters.HeaderIDSuffix = ":" + documentId } htmlFlags := defaultFlags @@ -95,17 +95,17 @@ func GetMarkdownExtensions() int { blackfriday.EXTENSION_TABLES | blackfriday.EXTENSION_FENCED_CODE | blackfriday.EXTENSION_AUTOLINK | blackfriday.EXTENSION_STRIKETHROUGH | blackfriday.EXTENSION_SPACE_HEADERS | blackfriday.EXTENSION_FOOTNOTES | - blackfriday.EXTENSION_HEADER_IDS + blackfriday.EXTENSION_HEADER_IDS | blackfriday.EXTENSION_AUTO_HEADER_IDS } -func MarkdownRender(content []byte, footnoteref string) []byte { - return blackfriday.Markdown(content, GetHtmlRenderer(0, footnoteref), +func MarkdownRender(content []byte, documentId string) []byte { + return blackfriday.Markdown(content, GetHtmlRenderer(0, documentId), GetMarkdownExtensions()) } -func MarkdownRenderWithTOC(content []byte, footnoteref string) []byte { +func MarkdownRenderWithTOC(content []byte, documentId string) []byte { return blackfriday.Markdown(content, - GetHtmlRenderer(blackfriday.HTML_TOC, footnoteref), + GetHtmlRenderer(blackfriday.HTML_TOC, documentId), GetMarkdownExtensions()) } @@ -132,7 +132,7 @@ func ExtractTOC(content []byte) (newcontent []byte, toc []byte) { return StripEmptyNav(content), toc } // Need to peek ahead to see if this nav element is actually the right one. - correctNav := bytes.Index(content[startOfTOC:peekEnd], []byte(`#toc_0`)) + correctNav := bytes.Index(content[startOfTOC:peekEnd], []byte(`
  • For some moments the old man did not reply. He stood with bowed head, buried in deep thought. But at last he spoke.

    \n\n

    AA

    \n\n

    I 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\n

    AAA

    \n\n

    I 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

    BBB

    \n\n

    “You’re a great Granser,” he cried delightedly, “always making believe them little marks mean something.”

    \n") - checkPageTOC(t, p, "
    ") + 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\n

    AA

    \n\n

    I 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\n

    AAA

    \n\n

    I 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

    BBB

    \n\n

    “You’re a great Granser,” he cried delightedly, “always making believe them little marks mean something.”

    \n") + checkPageTOC(t, p, "") } func TestPageWithMoreTag(t *testing.T) { diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index 002946bfd..9c5bc1c58 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -74,7 +74,7 @@ func TestInnerSCWithMarkdown(t *testing.T) { [link](http://spf13.com) and text -{{% /inside %}}`, "

    More Here

    \n\n

    link and text

    \n
    ", tem) +{{% /inside %}}`, "

    More Here

    \n\n

    link and text

    \n
    ", tem) } func TestInnerSCWithAndWithoutMarkdown(t *testing.T) { @@ -96,7 +96,7 @@ And then: This is **plain** text. {{< /inside >}} -`, "

    More Here

    \n\n

    link and text

    \n
    \n\nAnd then:\n\n
    \n# More Here\n\nThis is **plain** text.\n\n
    \n", tem) +`, "

    More Here

    \n\n

    link and text

    \n
    \n\nAnd then:\n\n
    \n# More Here\n\nThis is **plain** text.\n\n
    \n", tem) } func TestEmbeddedSC(t *testing.T) { diff --git a/hugolib/site_test.go b/hugolib/site_test.go index ce1d3f0ad..94f737343 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -112,7 +112,7 @@ func TestRenderThing(t *testing.T) { }{ {PAGE_SIMPLE_TITLE, TEMPLATE_TITLE, "simple template"}, {PAGE_SIMPLE_TITLE, TEMPLATE_FUNC, "simple-template"}, - {PAGE_WITH_MD, TEMPLATE_CONTENT, "\n\n

    heading 1

    \n\n

    text

    \n\n

    heading 2

    \n\n

    more text

    \n"}, + {PAGE_WITH_MD, TEMPLATE_CONTENT, "\n\n

    heading 1

    \n\n

    text

    \n\n

    heading 2

    \n\n

    more text

    \n"}, {SIMPLE_PAGE_RFC3339_DATE, TEMPLATE_DATE, "2013-05-17 16:59:30 +0000 UTC"}, } @@ -337,14 +337,14 @@ func TestSkipRender(t *testing.T) { doc string expected string }{ - {"sect/doc1.html", "\n\n

    title

    \n\n

    some content

    \n"}, + {"sect/doc1.html", "\n\n

    title

    \n\n

    some content

    \n"}, {"sect/doc2.html", "more content"}, - {"sect/doc3.html", "\n\n

    doc3

    \n\n

    some content

    \n"}, - {"sect/doc4.html", "\n\n

    doc4

    \n\n

    some content

    \n"}, + {"sect/doc3.html", "\n\n

    doc3

    \n\n

    some content

    \n"}, + {"sect/doc4.html", "\n\n

    doc4

    \n\n

    some content

    \n"}, {"sect/doc5.html", "body5"}, {"sect/doc6.html", "body5"}, {"doc7.html", "doc7 content"}, - {"sect/doc8.html", "\n\n

    title

    \n\n

    some content

    \n"}, + {"sect/doc8.html", "\n\n

    title

    \n\n

    some content

    \n"}, } for _, test := range tests {