From 57ecf0978766138fc084a3f1e158278bfd0d5d34 Mon Sep 17 00:00:00 2001 From: Roland Koebler Date: Thu, 21 Mar 2019 14:53:06 +0100 Subject: [PATCH] Markdown: enable some more extensions (#6362) * Markdown: enable some more extensions Improve Markdown-rendering by enabling some extensions: - enable definitions lists - enable footnotes - enable header-ids and automatically generate header-ids (for linking to README-sections or creating table-of-contents for larger READMEs) * Markdown: update and exted tests Update and add tests for additionally enabled Markdown-extensions. --- modules/markup/markdown/markdown.go | 6 +- modules/markup/markdown/markdown_test.go | 70 +++++++++++++++++++++++- routers/api/v1/misc/markdown_test.go | 4 +- 3 files changed, 74 insertions(+), 6 deletions(-) diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go index 1525ba781..aab951c60 100644 --- a/modules/markup/markdown/markdown.go +++ b/modules/markup/markdown/markdown.go @@ -128,7 +128,11 @@ const ( blackfriday.EXTENSION_TABLES | blackfriday.EXTENSION_FENCED_CODE | blackfriday.EXTENSION_STRIKETHROUGH | - blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK + blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK | + blackfriday.EXTENSION_DEFINITION_LISTS | + blackfriday.EXTENSION_FOOTNOTES | + blackfriday.EXTENSION_HEADER_IDS | + blackfriday.EXTENSION_AUTO_HEADER_IDS blackfridayHTMLFlags = 0 | blackfriday.HTML_SKIP_STYLE | blackfriday.HTML_OMIT_CONTENTS | diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index a5ab84e0e..5aa9c3d7d 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -106,11 +106,11 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
  • Plot var helper
  • `, - `

    What is Wine Staging?

    + `

    What is Wine Staging?

    Wine Staging on website wine-staging.com.

    -

    Quick Links

    +

    Here are some links to the most important topics. You can find the full list of pages at the sidebar.

    @@ -138,6 +138,42 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
  • Perform a test run by hitting the Run! button. images/2.png
  • + +

    More tests

    + +

    (from https://www.markdownguide.org/extended-syntax/)

    + +

    Definition list

    + +
    +
    First Term
    +
    This is the definition of the first term.
    +
    Second Term
    +
    This is one definition of the second term.
    +
    This is another definition of the second term.
    +
    + +

    Footnotes

    + +

    Here is a simple footnote,1 and here is a longer one.2

    +
    + +
    + +
      +
    1. This is the first footnote. +
    2. + +
    3. Here is one with multiple paragraphs and code.

      + +

      Indent paragraphs to include them in the footnote.

      + +

      { my code }

      + +

      Add as many paragraphs as you like.

      +
    4. +
    +
    `, } } @@ -172,7 +208,35 @@ Here are some links to the most important topics. You can find the full list of 1. [Package your libGDX application](https://github.com/libgdx/libgdx/wiki/Gradle-on-the-Commandline#packaging-for-the-desktop) [[images/1.png]] 2. Perform a test run by hitting the Run! button. -[[images/2.png]]`, +[[images/2.png]] + +## More tests {#custom-id} + +(from https://www.markdownguide.org/extended-syntax/) + +### Definition list + +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +### Footnotes + +Here is a simple footnote,[^1] and here is a longer one.[^bignote] + +[^1]: This is the first footnote. + +[^bignote]: Here is one with multiple paragraphs and code. + + Indent paragraphs to include them in the footnote. + + ` + "`{ my code }`" + ` + + Add as many paragraphs as you like. +`, } func TestTotal_RenderWiki(t *testing.T) { diff --git a/routers/api/v1/misc/markdown_test.go b/routers/api/v1/misc/markdown_test.go index 32d2f0730..9de1f77f6 100644 --- a/routers/api/v1/misc/markdown_test.go +++ b/routers/api/v1/misc/markdown_test.go @@ -87,11 +87,11 @@ Here are some links to the most important topics. You can find the full list of [[images/icon-bug.png]] `, // rendered - `

    What is Wine Staging?

    + `

    What is Wine Staging?

    Wine Staging on website wine-staging.com.

    -

    Quick Links

    +

    Here are some links to the most important topics. You can find the full list of pages at the sidebar.