Merge pull request '[CHORE] Remove github.com/yuin/goldmark-meta' (#4383) from gusted/chore-goldmark-meta into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4383 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
502adec4ce
6 changed files with 125 additions and 17 deletions
10
assets/go-licenses.json
generated
10
assets/go-licenses.json
generated
File diff suppressed because one or more lines are too long
1
go.mod
1
go.mod
|
@ -103,7 +103,6 @@ require (
|
|||
github.com/yohcop/openid-go v1.0.1
|
||||
github.com/yuin/goldmark v1.7.4
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
||||
github.com/yuin/goldmark-meta v1.1.0
|
||||
go.uber.org/mock v0.4.0
|
||||
golang.org/x/crypto v0.24.0
|
||||
golang.org/x/image v0.18.0
|
||||
|
|
2
go.sum
2
go.sum
|
@ -746,8 +746,6 @@ github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg=
|
|||
github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+IAOyRda+RLrxa1WC7umKOZRsGq4QrFFMYApOeHzQwQ=
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I=
|
||||
github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc=
|
||||
github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0=
|
||||
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
|
||||
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
||||
github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg=
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
|
||||
"github.com/yuin/goldmark"
|
||||
highlighting "github.com/yuin/goldmark-highlighting/v2"
|
||||
meta "github.com/yuin/goldmark-meta"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"github.com/yuin/goldmark/parser"
|
||||
"github.com/yuin/goldmark/renderer"
|
||||
|
@ -121,7 +120,6 @@ func SpecializedMarkdown() goldmark.Markdown {
|
|||
math.NewExtension(
|
||||
math.Enabled(setting.Markdown.EnableMath),
|
||||
),
|
||||
meta.Meta,
|
||||
),
|
||||
goldmark.WithParserOptions(
|
||||
parser.WithAttribute(),
|
||||
|
@ -182,7 +180,7 @@ func actualRender(ctx *markup.RenderContext, input io.Reader, output io.Writer)
|
|||
bufWithMetadataLength := len(buf)
|
||||
|
||||
rc := &RenderConfig{
|
||||
Meta: renderMetaModeFromString(string(ctx.RenderMetaAs)),
|
||||
Meta: markup.RenderMetaAsDetails,
|
||||
Icon: "table",
|
||||
Lang: "",
|
||||
}
|
||||
|
|
|
@ -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>`)
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@ type RenderContext struct {
|
|||
ShaExistCache map[string]bool
|
||||
cancelFn func()
|
||||
SidebarTocNode ast.Node
|
||||
RenderMetaAs RenderMetaMode
|
||||
InStandalonePage bool // used by external render. the router "/org/repo/render/..." will output the rendered content in a standalone page
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue