[CHORE] Remove github.com/yuin/goldmark-meta

- Remove a unused dependency. This dependency was added to handle YAML
'frontmatter' meta, parsing them and converting them to a table or
details in the resulting HTML. As can be read in the issue that reported
the behavior of YAML frontmatter being rendered literally,
https://github.com/go-gitea/gitea/issues/5377.
- It's an unused dependency as the codebase since then moved on to do this YAML
parsing and rendering on their own, this was implemented in
812cfd0ad9.
- Adds unit tests that was related to this functionality, to proof the
codebase already handles this and to prevent regressions.
This commit is contained in:
Gusted 2024-07-07 03:04:45 +02:00
parent 3ff661fe9e
commit cf8f26d616
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 125 additions and 17 deletions

View file

@ -1210,3 +1210,127 @@ func TestCustomMarkdownURL(t *testing.T) {
test("[test](abp)",
`<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/abp" rel="nofollow">test</a></p>`)
}
func TestYAMLMeta(t *testing.T) {
setting.AppURL = AppURL
test := func(input, expected string) {
buffer, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(buffer)))
}
test(`---
include_toc: true
---
## Header`,
`<details><summary><i class="icon table"></i></summary><table>
<thead>
<tr>
<th>include_toc</th>
</tr>
</thead>
<tbody>
<tr>
<td>true</td>
</tr>
</tbody>
</table>
</details><details><summary>toc</summary><ul>
<li>
<a href="#user-content-header" rel="nofollow">Header</a></li>
</ul>
</details><h2 id="user-content-header">Header</h2>`)
test(`---
key: value
---`,
`<details><summary><i class="icon table"></i></summary><table>
<thead>
<tr>
<th>key</th>
</tr>
</thead>
<tbody>
<tr>
<td>value</td>
</tr>
</tbody>
</table>
</details>`)
test("---\n---\n",
`<hr/>
<hr/>`)
test(`---
gitea:
details_icon: smiley
include_toc: true
---
# Another header`,
`<details><summary><i class="icon smiley"></i></summary><table>
<thead>
<tr>
<th>gitea</th>
</tr>
</thead>
<tbody>
<tr>
<td><table>
<thead>
<tr>
<th>details_icon</th>
<th>include_toc</th>
</tr>
</thead>
<tbody>
<tr>
<td>smiley</td>
<td>true</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</details><details><summary>toc</summary><ul>
<li>
<a href="#user-content-another-header" rel="nofollow">Another header</a></li>
</ul>
</details><h1 id="user-content-another-header">Another header</h1>`)
test(`---
gitea:
meta: table
key: value
---`, `<table>
<thead>
<tr>
<th>gitea</th>
<th>key</th>
</tr>
</thead>
<tbody>
<tr>
<td><table>
<thead>
<tr>
<th>meta</th>
</tr>
</thead>
<tbody>
<tr>
<td>table</td>
</tr>
</tbody>
</table>
</td>
<td>value</td>
</tr>
</tbody>
</table>`)
}