Add back blackfriday extensions during Markdown conversion - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c1b9380dfd35632577fc6960cde316af203e32df
 (DIR) parent 6dd2e9a49acde23dcf5e9701915f7e8ed692ce5a
 (HTM) Author: Niels Widger <niels.widger@gmail.com>
       Date:   Thu, 30 Jan 2014 17:50:47 -0500
       
       Add back blackfriday extensions during Markdown conversion
       
       Modified markdownRender and markdownRenderWithTOC in hugolib/page.go to
       use the same flags and extensions as were previously used when we simply
       called blackfriday.MarkdownCommon to convert Markdown to HTML.  These
       flags/extensions were dropped during the refactor that added the
       `.TableOfContents` page variable, and caused features like Markdown
       tables to no longer work.
       
       Modified the expected output for TestTableOfContents in page_test.go,
       apparently changing the flags/extensions caused an `&mdash;` to become
       `&ndash;`.
       
       Diffstat:
         M hugolib/page.go                     |      26 ++++++++++++++++++++++++--
         M hugolib/page_test.go                |       2 +-
       
       2 files changed, 25 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git 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) {
 (DIR) diff --git 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<p>For some moments the old man did not reply. He stood with bowed head, buried in deep thought. But at last he spoke.</p>\n\n<h2 id=\"toc_0\">AA</h2>\n\n<p>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.</p>\n\n<h3 id=\"toc_1\">AAA</h3>\n\n<p>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&mdash;as swift as the passage of light&mdash;would leap after me from the pit about\nthe cylinder and strike me down. ## BB</p>\n\n<h3 id=\"toc_2\">BBB</h3>\n\n<p>&ldquo;You&rsquo;re a great Granser,&rdquo; he cried delightedly, &ldquo;always making believe them little marks mean something.&rdquo;</p>\n")
       +        checkPageContent(t, p, "\n\n<p>For some moments the old man did not reply. He stood with bowed head, buried in deep thought. But at last he spoke.</p>\n\n<h2 id=\"toc_0\">AA</h2>\n\n<p>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.</p>\n\n<h3 id=\"toc_1\">AAA</h3>\n\n<p>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&ndash;as swift as the passage of light&ndash;would leap after me from the pit about\nthe cylinder and strike me down. ## BB</p>\n\n<h3 id=\"toc_2\">BBB</h3>\n\n<p>&ldquo;You&rsquo;re a great Granser,&rdquo; he cried delightedly, &ldquo;always making believe them little marks mean something.&rdquo;</p>\n")
                checkPageTOC(t, p, "<nav id=\"TableOfContents\">\n<ul>\n<li>\n<ul>\n<li><a href=\"#toc_0\">AA</a>\n<ul>\n<li><a href=\"#toc_1\">AAA</a></li>\n<li><a href=\"#toc_2\">BBB</a></li>\n</ul></li>\n</ul></li>\n</ul>\n</nav>")
        }