Skip to content

Commit 57ecf09

Browse files
rkoelafriks
authored andcommitted
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.
1 parent 6f2e1bd commit 57ecf09

File tree

3 files changed

+74
-6
lines changed

3 files changed

+74
-6
lines changed

modules/markup/markdown/markdown.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ const (
128128
blackfriday.EXTENSION_TABLES |
129129
blackfriday.EXTENSION_FENCED_CODE |
130130
blackfriday.EXTENSION_STRIKETHROUGH |
131-
blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK
131+
blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK |
132+
blackfriday.EXTENSION_DEFINITION_LISTS |
133+
blackfriday.EXTENSION_FOOTNOTES |
134+
blackfriday.EXTENSION_HEADER_IDS |
135+
blackfriday.EXTENSION_AUTO_HEADER_IDS
132136
blackfridayHTMLFlags = 0 |
133137
blackfriday.HTML_SKIP_STYLE |
134138
blackfriday.HTML_OMIT_CONTENTS |

modules/markup/markdown/markdown_test.go

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
106106
<li><a href="` + baseURLContent + `/plot_var_example" rel="nofollow">Plot var helper</a></li>
107107
</ul>
108108
`,
109-
`<h2>What is Wine Staging?</h2>
109+
`<h2 id="what-is-wine-staging">What is Wine Staging?</h2>
110110
111111
<p><strong>Wine Staging</strong> on website <a href="http://wine-staging.com" rel="nofollow">wine-staging.com</a>.</p>
112112
113-
<h2>Quick Links</h2>
113+
<h2 id="quick-links">Quick Links</h2>
114114
115115
<p>Here are some links to the most important topics. You can find the full list of pages at the sidebar.</p>
116116
@@ -138,6 +138,42 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
138138
<li>Perform a test run by hitting the Run! button.
139139
<a href="` + baseURLImages + `/images/2.png" rel="nofollow"><img src="` + baseURLImages + `/images/2.png" title="2.png" alt="images/2.png"/></a></li>
140140
</ol>
141+
142+
<h2 id="custom-id">More tests</h2>
143+
144+
<p>(from <a href="https://www.markdownguide.org/extended-syntax/" rel="nofollow">https://www.markdownguide.org/extended-syntax/</a>)</p>
145+
146+
<h3 id="definition-list">Definition list</h3>
147+
148+
<dl>
149+
<dt>First Term</dt>
150+
<dd>This is the definition of the first term.</dd>
151+
<dt>Second Term</dt>
152+
<dd>This is one definition of the second term.</dd>
153+
<dd>This is another definition of the second term.</dd>
154+
</dl>
155+
156+
<h3 id="footnotes">Footnotes</h3>
157+
158+
<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>
159+
<div>
160+
161+
<hr/>
162+
163+
<ol>
164+
<li id="fn:1">This is the first footnote.
165+
</li>
166+
167+
<li id="fn:bignote"><p>Here is one with multiple paragraphs and code.</p>
168+
169+
<p>Indent paragraphs to include them in the footnote.</p>
170+
171+
<p><code>{ my code }</code></p>
172+
173+
<p>Add as many paragraphs as you like.</p>
174+
</li>
175+
</ol>
176+
</div>
141177
`,
142178
}
143179
}
@@ -172,7 +208,35 @@ Here are some links to the most important topics. You can find the full list of
172208
1. [Package your libGDX application](https://github.com/libgdx/libgdx/wiki/Gradle-on-the-Commandline#packaging-for-the-desktop)
173209
[[images/1.png]]
174210
2. Perform a test run by hitting the Run! button.
175-
[[images/2.png]]`,
211+
[[images/2.png]]
212+
213+
## More tests {#custom-id}
214+
215+
(from https://www.markdownguide.org/extended-syntax/)
216+
217+
### Definition list
218+
219+
First Term
220+
: This is the definition of the first term.
221+
222+
Second Term
223+
: This is one definition of the second term.
224+
: This is another definition of the second term.
225+
226+
### Footnotes
227+
228+
Here is a simple footnote,[^1] and here is a longer one.[^bignote]
229+
230+
[^1]: This is the first footnote.
231+
232+
[^bignote]: Here is one with multiple paragraphs and code.
233+
234+
Indent paragraphs to include them in the footnote.
235+
236+
` + "`{ my code }`" + `
237+
238+
Add as many paragraphs as you like.
239+
`,
176240
}
177241

178242
func TestTotal_RenderUncyclo(t *testing.T) {

routers/api/v1/misc/markdown_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ Here are some links to the most important topics. You can find the full list of
8787
[[images/icon-bug.png]]
8888
`,
8989
// rendered
90-
`<h2>What is Wine Staging?</h2>
90+
`<h2 id="what-is-wine-staging">What is Wine Staging?</h2>
9191
9292
<p><strong>Wine Staging</strong> on website <a href="http://wine-staging.com" rel="nofollow">wine-staging.com</a>.</p>
9393
94-
<h2>Quick Links</h2>
94+
<h2 id="quick-links">Quick Links</h2>
9595
9696
<p>Here are some links to the most important topics. You can find the full list of pages at the sidebar.</p>
9797

0 commit comments

Comments
 (0)