@@ -897,7 +897,7 @@ title: "p1"
897897---
898898# HTML comments
899899
900- ## Simple
900+ ## Simple
901901<!-- This is a comment -->
902902
903903 <!-- This is a comment indented -->
@@ -918,7 +918,7 @@ title: "p1"
918918<img border="0" src="pic_trulli.jpg" alt="Trulli">
919919-->
920920
921- ## XSS
921+ ## XSS
922922
923923<!-- --><script>alert("I just escaped the HTML comment")</script><!-- -->
924924
@@ -931,10 +931,10 @@ This is a <!-- hidden--> word.
931931
932932This is a <!-- hidden --> word.
933933
934- This is a <!--
934+ This is a <!--
935935hidden --> word.
936936
937- This is a <!--
937+ This is a <!--
938938hidden
939939--> word.
940940
@@ -961,3 +961,72 @@ hidden
961961 )
962962 b .AssertLogContains ("! WARN" )
963963}
964+
965+ func TestFootnoteExtension (t * testing.T ) {
966+ t .Parallel ()
967+
968+ files := `
969+ -- hugo.toml --
970+ disableKinds = ['home','rss','section','sitemap','taxonomy','term']
971+ [markup.goldmark.extensions.footnote]
972+ enable = false
973+ enableAutoIDPrefix = false
974+ -- layouts/all.html --
975+ {{ .Content }}
976+ -- content/p1.md --
977+ ---
978+ title: p1
979+ ---
980+ foo[^1] and bar[^2]
981+
982+ [^1]: footnote one
983+ [^2]: footnote two
984+ -- content/p2.md --
985+ ---
986+ title: p2
987+ ---
988+ foo[^1] and bar[^2]
989+
990+ [^1]: footnote one
991+ [^2]: footnote two
992+ -- content/_content.gotmpl --
993+ {{ range slice 3 4 }}
994+ {{ $page := dict
995+ "content" (dict "mediaType" "text/markdown" "value" "foo[^1] and bar[^2]\n\n[^1]: footnote one\n[^2]: footnote two")
996+ "path" (printf "p%d" .)
997+ "title" (printf "p%d" .)
998+ }}
999+ {{ $.AddPage $page }}
1000+ {{ end }}
1001+ `
1002+
1003+ want := "<p>foo[^1] and bar[^2]</p>\n <p>[^1]: footnote one\n [^2]: footnote two</p>"
1004+ b := hugolib .Test (t , files )
1005+ b .AssertFileContent ("public/p1/index.html" , want )
1006+ b .AssertFileContent ("public/p2/index.html" , want )
1007+ b .AssertFileContent ("public/p3/index.html" , want )
1008+ b .AssertFileContent ("public/p4/index.html" , want )
1009+
1010+ files = strings .ReplaceAll (files , "enable = false" , "enable = true" )
1011+ want = "<p>foo<sup id=\" fnref:1\" ><a href=\" #fn:1\" class=\" footnote-ref\" role=\" doc-noteref\" >1</a></sup> and bar<sup id=\" fnref:2\" ><a href=\" #fn:2\" class=\" footnote-ref\" role=\" doc-noteref\" >2</a></sup></p>\n <div class=\" footnotes\" role=\" doc-endnotes\" >\n <hr>\n <ol>\n <li id=\" fn:1\" >\n <p>footnote one <a href=\" #fnref:1\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n <li id=\" fn:2\" >\n <p>footnote two <a href=\" #fnref:2\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n </ol>\n </div>"
1012+ b = hugolib .Test (t , files )
1013+ b .AssertFileContent ("public/p1/index.html" , want )
1014+ b .AssertFileContent ("public/p2/index.html" , want )
1015+ b .AssertFileContent ("public/p3/index.html" , want )
1016+ b .AssertFileContent ("public/p4/index.html" , want )
1017+
1018+ files = strings .ReplaceAll (files , "enableAutoIDPrefix = false" , "enableAutoIDPrefix = true" )
1019+ b = hugolib .Test (t , files )
1020+ b .AssertFileContent ("public/p1/index.html" ,
1021+ "<p>foo<sup id=\" hb5cdcabc9e678612fnref:1\" ><a href=\" #hb5cdcabc9e678612fn:1\" class=\" footnote-ref\" role=\" doc-noteref\" >1</a></sup> and bar<sup id=\" hb5cdcabc9e678612fnref:2\" ><a href=\" #hb5cdcabc9e678612fn:2\" class=\" footnote-ref\" role=\" doc-noteref\" >2</a></sup></p>\n <div class=\" footnotes\" role=\" doc-endnotes\" >\n <hr>\n <ol>\n <li id=\" hb5cdcabc9e678612fn:1\" >\n <p>footnote one <a href=\" #hb5cdcabc9e678612fnref:1\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n <li id=\" hb5cdcabc9e678612fn:2\" >\n <p>footnote two <a href=\" #hb5cdcabc9e678612fnref:2\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n </ol>\n </div>" ,
1022+ )
1023+ b .AssertFileContent ("public/p2/index.html" ,
1024+ "<p>foo<sup id=\" h58e8265a0c07b195fnref:1\" ><a href=\" #h58e8265a0c07b195fn:1\" class=\" footnote-ref\" role=\" doc-noteref\" >1</a></sup> and bar<sup id=\" h58e8265a0c07b195fnref:2\" ><a href=\" #h58e8265a0c07b195fn:2\" class=\" footnote-ref\" role=\" doc-noteref\" >2</a></sup></p>\n <div class=\" footnotes\" role=\" doc-endnotes\" >\n <hr>\n <ol>\n <li id=\" h58e8265a0c07b195fn:1\" >\n <p>footnote one <a href=\" #h58e8265a0c07b195fnref:1\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n <li id=\" h58e8265a0c07b195fn:2\" >\n <p>footnote two <a href=\" #h58e8265a0c07b195fnref:2\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n </ol>\n </div>" ,
1025+ )
1026+ b .AssertFileContent ("public/p3/index.html" ,
1027+ "<p>foo<sup id=\" h0aab769290d7e233fnref:1\" ><a href=\" #h0aab769290d7e233fn:1\" class=\" footnote-ref\" role=\" doc-noteref\" >1</a></sup> and bar<sup id=\" h0aab769290d7e233fnref:2\" ><a href=\" #h0aab769290d7e233fn:2\" class=\" footnote-ref\" role=\" doc-noteref\" >2</a></sup></p>\n <div class=\" footnotes\" role=\" doc-endnotes\" >\n <hr>\n <ol>\n <li id=\" h0aab769290d7e233fn:1\" >\n <p>footnote one <a href=\" #h0aab769290d7e233fnref:1\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n <li id=\" h0aab769290d7e233fn:2\" >\n <p>footnote two <a href=\" #h0aab769290d7e233fnref:2\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n </ol>\n </div>" ,
1028+ )
1029+ b .AssertFileContent ("public/p4/index.html" ,
1030+ "<p>foo<sup id=\" ha35b794ad6e8626cfnref:1\" ><a href=\" #ha35b794ad6e8626cfn:1\" class=\" footnote-ref\" role=\" doc-noteref\" >1</a></sup> and bar<sup id=\" ha35b794ad6e8626cfnref:2\" ><a href=\" #ha35b794ad6e8626cfn:2\" class=\" footnote-ref\" role=\" doc-noteref\" >2</a></sup></p>\n <div class=\" footnotes\" role=\" doc-endnotes\" >\n <hr>\n <ol>\n <li id=\" ha35b794ad6e8626cfn:1\" >\n <p>footnote one <a href=\" #ha35b794ad6e8626cfnref:1\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n <li id=\" ha35b794ad6e8626cfn:2\" >\n <p>footnote two <a href=\" #ha35b794ad6e8626cfnref:2\" class=\" footnote-backref\" role=\" doc-backlink\" >↩︎</a></p>\n </li>\n </ol>\n </div>" ,
1031+ )
1032+ }
0 commit comments