diff options
author | Roland Koebler <rk@simple-is-better.org> | 2019-03-21 14:53:06 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-03-21 15:53:06 +0200 |
commit | 57ecf0978766138fc084a3f1e158278bfd0d5d34 (patch) | |
tree | a414a8e250b2dfe2464e375c992155d9fe4b2f02 /modules | |
parent | 6f2e1bd23ab7670e3bbc76d569b80007ca38af05 (diff) | |
download | gitea-57ecf0978766138fc084a3f1e158278bfd0d5d34.tar.gz gitea-57ecf0978766138fc084a3f1e158278bfd0d5d34.zip |
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.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/markup/markdown/markdown.go | 6 | ||||
-rw-r--r-- | modules/markup/markdown/markdown_test.go | 70 |
2 files changed, 72 insertions, 4 deletions
diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go index 1525ba7812..aab951c60f 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 a5ab84e0ec..5aa9c3d7d2 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 { <li><a href="` + baseURLContent + `/plot_var_example" rel="nofollow">Plot var helper</a></li> </ul> `, - `<h2>What is Wine Staging?</h2> + `<h2 id="what-is-wine-staging">What is Wine Staging?</h2> <p><strong>Wine Staging</strong> on website <a href="http://wine-staging.com" rel="nofollow">wine-staging.com</a>.</p> -<h2>Quick Links</h2> +<h2 id="quick-links">Quick Links</h2> <p>Here are some links to the most important topics. You can find the full list of pages at the sidebar.</p> @@ -138,6 +138,42 @@ func testAnswers(baseURLContent, baseURLImages string) []string { <li>Perform a test run by hitting the Run! button. <a href="` + baseURLImages + `/images/2.png" rel="nofollow"><img src="` + baseURLImages + `/images/2.png" title="2.png" alt="images/2.png"/></a></li> </ol> + +<h2 id="custom-id">More tests</h2> + +<p>(from <a href="https://www.markdownguide.org/extended-syntax/" rel="nofollow">https://www.markdownguide.org/extended-syntax/</a>)</p> + +<h3 id="definition-list">Definition list</h3> + +<dl> +<dt>First Term</dt> +<dd>This is the definition of the first term.</dd> +<dt>Second Term</dt> +<dd>This is one definition of the second term.</dd> +<dd>This is another definition of the second term.</dd> +</dl> + +<h3 id="footnotes">Footnotes</h3> + +<p>Here is a simple footnote,<sup id="fnref:1"><a href="#fn:1" rel="nofollow">1</a></sup> and here is a longer one.<sup id="fnref:bignote"><a href="#fn:bignote" rel="nofollow">2</a></sup></p> +<div> + +<hr/> + +<ol> +<li id="fn:1">This is the first footnote. +</li> + +<li id="fn:bignote"><p>Here is one with multiple paragraphs and code.</p> + +<p>Indent paragraphs to include them in the footnote.</p> + +<p><code>{ my code }</code></p> + +<p>Add as many paragraphs as you like.</p> +</li> +</ol> +</div> `, } } @@ -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) { |