mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-02-09 14:03:49 +01:00
Some checks are pending
/ release (push) Waiting to run
testing / test-e2e (push) Blocked by required conditions
testing / test-unit (push) Blocked by required conditions
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/alecthomas/chroma/v2](https://github.com/alecthomas/chroma) | require | minor | `v2.14.0` -> `v2.15.0` | --- ### Release Notes <details> <summary>alecthomas/chroma (github.com/alecthomas/chroma/v2)</summary> ### [`v2.15.0`](https://github.com/alecthomas/chroma/releases/tag/v2.15.0) [Compare Source](https://github.com/alecthomas/chroma/compare/v2.14.0...v2.15.0) #### What's Changed - AQL: Add builtin functions introduced in v3.12 by [@​Simran-B](https://github.com/Simran-B) in https://github.com/alecthomas/chroma/pull/968 - chore(styles): add evergarden inspired style by [@​comfysage](https://github.com/comfysage) in https://github.com/alecthomas/chroma/pull/970 - chore(deps): update dependency svu to v2 by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/971 - chore(deps): update dependency watchexec to v2 by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/962 - chore(deps): update all non-major dependencies by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/955 - styles: Fix Gleam alias by [@​jmooring](https://github.com/jmooring) in https://github.com/alecthomas/chroma/pull/973 - chore(deps): update all non-major dependencies by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/974 - chore(deps): update dependency python3 to v3.12.3 by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/976 - added the nordic theme via chroma/styles/nordic.xml by [@​avih7531](https://github.com/avih7531) in https://github.com/alecthomas/chroma/pull/977 - Update the Materialize lexer by [@​arusahni](https://github.com/arusahni) in https://github.com/alecthomas/chroma/pull/978 - feat(lexers/hare): add done keyword by [@​wackbyte](https://github.com/wackbyte) in https://github.com/alecthomas/chroma/pull/979 - pygments2chroma: escape regex.words by [@​oliverpool](https://github.com/oliverpool) in https://github.com/alecthomas/chroma/pull/982 - chore(deps): update all non-major dependencies by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/981 - Add JSONata Lexer by [@​DevDimov](https://github.com/DevDimov) in https://github.com/alecthomas/chroma/pull/983 - Go lexer: single line comment without consuming endline, disable EnsureNL by [@​msorc](https://github.com/msorc) in https://github.com/alecthomas/chroma/pull/984 - Update the Materialize lexer by [@​arusahni](https://github.com/arusahni) in https://github.com/alecthomas/chroma/pull/987 - chore(deps): update all non-major dependencies by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/985 - Add Gleam to README by [@​Nicd](https://github.com/Nicd) in https://github.com/alecthomas/chroma/pull/990 - Port Minecraft lexers from Pygments by [@​kofuk](https://github.com/kofuk) in https://github.com/alecthomas/chroma/pull/992 - Don't output extra whitespace in YAML multiline by [@​Gusted](https://github.com/Gusted) in https://github.com/alecthomas/chroma/pull/993 - chore(deps): update all non-major dependencies by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/991 - add beef syntax and tests by [@​Booklordofthedings](https://github.com/Booklordofthedings) in https://github.com/alecthomas/chroma/pull/995 - Update GitHub light color palette by [@​konradreiche](https://github.com/konradreiche) in https://github.com/alecthomas/chroma/pull/998 - chore(deps): update module github.com/alecthomas/kong to v1 by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/999 - Update the Materialize lexer by [@​arusahni](https://github.com/arusahni) in https://github.com/alecthomas/chroma/pull/1001 - Update TypeScript lexer to allow nested generics by [@​fredrare](https://github.com/fredrare) in https://github.com/alecthomas/chroma/pull/1002 - Pager friendly terminal formatting by [@​walles](https://github.com/walles) in https://github.com/alecthomas/chroma/pull/1006 - chore(deps): update all non-major dependencies by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/997 - Add Typst Lexer by [@​oliverpool](https://github.com/oliverpool) in https://github.com/alecthomas/chroma/pull/1007 - Add Jsonnet Lexer by [@​jolheiser](https://github.com/jolheiser) in https://github.com/alecthomas/chroma/pull/1011 - fix: add underscore parsing in numbers for haskell by [@​Gusted](https://github.com/Gusted) in https://github.com/alecthomas/chroma/pull/1020 - Add CSV lexer by [@​walles](https://github.com/walles) in https://github.com/alecthomas/chroma/pull/1005 - fix(typescript): highlight string literal type parameters by [@​SKalt](https://github.com/SKalt) in https://github.com/alecthomas/chroma/pull/1010 - add any as a builtin type for go by [@​quartercastle](https://github.com/quartercastle) in https://github.com/alecthomas/chroma/pull/1021 - chore(deps): update all non-major dependencies by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/1013 - Remove whitespace tokenizing rule in markdown lexer by [@​cloudchamb3r](https://github.com/cloudchamb3r) in https://github.com/alecthomas/chroma/pull/1008 - feat(JSON): support `.jsonc` extension by [@​CarterLi](https://github.com/CarterLi) in https://github.com/alecthomas/chroma/pull/1022 - Add Eclipse ATL language (https://eclipse.dev/atl/) by [@​dwagelaar](https://github.com/dwagelaar) in https://github.com/alecthomas/chroma/pull/1024 - Import NSIS Lexer from Pygments by [@​JakobDev](https://github.com/JakobDev) in https://github.com/alecthomas/chroma/pull/1026 - chore(deps): update module github.com/alecthomas/kong to v1.5.1 by [@​renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/1025 - fix(nix): nix lexor missing '=' operator by [@​FlyingStitchman](https://github.com/FlyingStitchman) in https://github.com/alecthomas/chroma/pull/1031 - Add WebVTT lexer ([#​707](https://github.com/alecthomas/chroma/issues/707)) by [@​dschuessler](https://github.com/dschuessler) in https://github.com/alecthomas/chroma/pull/1032 #### New Contributors - [@​comfysage](https://github.com/comfysage) made their first contribution in https://github.com/alecthomas/chroma/pull/970 - [@​avih7531](https://github.com/avih7531) made their first contribution in https://github.com/alecthomas/chroma/pull/977 - [@​wackbyte](https://github.com/wackbyte) made their first contribution in https://github.com/alecthomas/chroma/pull/979 - [@​oliverpool](https://github.com/oliverpool) made their first contribution in https://github.com/alecthomas/chroma/pull/982 - [@​DevDimov](https://github.com/DevDimov) made their first contribution in https://github.com/alecthomas/chroma/pull/983 - [@​msorc](https://github.com/msorc) made their first contribution in https://github.com/alecthomas/chroma/pull/984 - [@​Nicd](https://github.com/Nicd) made their first contribution in https://github.com/alecthomas/chroma/pull/990 - [@​Booklordofthedings](https://github.com/Booklordofthedings) made their first contribution in https://github.com/alecthomas/chroma/pull/995 - [@​konradreiche](https://github.com/konradreiche) made their first contribution in https://github.com/alecthomas/chroma/pull/998 - [@​fredrare](https://github.com/fredrare) made their first contribution in https://github.com/alecthomas/chroma/pull/1002 - [@​SKalt](https://github.com/SKalt) made their first contribution in https://github.com/alecthomas/chroma/pull/1010 - [@​quartercastle](https://github.com/quartercastle) made their first contribution in https://github.com/alecthomas/chroma/pull/1021 - [@​cloudchamb3r](https://github.com/cloudchamb3r) made their first contribution in https://github.com/alecthomas/chroma/pull/1008 - [@​CarterLi](https://github.com/CarterLi) made their first contribution in https://github.com/alecthomas/chroma/pull/1022 - [@​dwagelaar](https://github.com/dwagelaar) made their first contribution in https://github.com/alecthomas/chroma/pull/1024 - [@​FlyingStitchman](https://github.com/FlyingStitchman) made their first contribution in https://github.com/alecthomas/chroma/pull/1031 - [@​dschuessler](https://github.com/dschuessler) made their first contribution in https://github.com/alecthomas/chroma/pull/1032 **Full Changelog**: https://github.com/alecthomas/chroma/compare/v2.14.0...v2.15.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "* 0-3 * * *" (UTC), Automerge - "* 0-3 * * *" (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS45MC4wIiwidXBkYXRlZEluVmVyIjoiMzkuOTAuMCIsInRhcmdldEJyYW5jaCI6ImZvcmdlam8iLCJsYWJlbHMiOlsiZGVwZW5kZW5jeS11cGdyYWRlIiwidGVzdC9ub3QtbmVlZGVkIl19--> Co-authored-by: Gusted <postmaster@gusted.xyz> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6477 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org> Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
160 lines
5.6 KiB
Go
160 lines
5.6 KiB
Go
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package markup
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/modules/git"
|
|
"code.gitea.io/gitea/modules/markup"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
"code.gitea.io/gitea/modules/util"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
const (
|
|
AppURL = "http://localhost:3000/"
|
|
Repo = "gogits/gogs"
|
|
AppSubURL = AppURL + Repo + "/"
|
|
)
|
|
|
|
func TestRender_StandardLinks(t *testing.T) {
|
|
setting.AppURL = AppURL
|
|
setting.AppSubURL = AppSubURL
|
|
|
|
test := func(input, expected string) {
|
|
buffer, err := RenderString(&markup.RenderContext{
|
|
Ctx: git.DefaultContext,
|
|
Links: markup.Links{
|
|
Base: setting.AppSubURL,
|
|
},
|
|
}, input)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
|
}
|
|
|
|
// No BranchPath or TreePath set.
|
|
test("[[file:comfy][comfy]]",
|
|
`<p><a href="http://localhost:3000/gogits/gogs/comfy">comfy</a></p>`)
|
|
|
|
test("[[https://google.com/]]",
|
|
`<p><a href="https://google.com/">https://google.com/</a></p>`)
|
|
|
|
lnk := util.URLJoin(AppSubURL, "WikiPage")
|
|
test("[[WikiPage][WikiPage]]",
|
|
`<p><a href="`+lnk+`">WikiPage</a></p>`)
|
|
}
|
|
|
|
func TestRender_BaseLinks(t *testing.T) {
|
|
setting.AppURL = AppURL
|
|
setting.AppSubURL = AppSubURL
|
|
|
|
testBranch := func(input, expected string) {
|
|
buffer, err := RenderString(&markup.RenderContext{
|
|
Ctx: git.DefaultContext,
|
|
Links: markup.Links{
|
|
Base: setting.AppSubURL,
|
|
BranchPath: "branch/main",
|
|
},
|
|
}, input)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
|
}
|
|
|
|
testBranchTree := func(input, expected string) {
|
|
buffer, err := RenderString(&markup.RenderContext{
|
|
Ctx: git.DefaultContext,
|
|
Links: markup.Links{
|
|
Base: setting.AppSubURL,
|
|
BranchPath: "branch/main",
|
|
TreePath: "deep/nested/folder",
|
|
},
|
|
}, input)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
|
}
|
|
|
|
testBranch("[[file:comfy][comfy]]",
|
|
`<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/comfy">comfy</a></p>`)
|
|
testBranchTree("[[file:comfy][comfy]]",
|
|
`<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/deep/nested/folder/comfy">comfy</a></p>`)
|
|
|
|
testBranch("[[file:./src][./src/]]",
|
|
`<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/src">./src/</a></p>`)
|
|
testBranchTree("[[file:./src][./src/]]",
|
|
`<p><a href="http://localhost:3000/gogits/gogs/src/branch/main/deep/nested/folder/src">./src/</a></p>`)
|
|
}
|
|
|
|
func TestRender_Media(t *testing.T) {
|
|
setting.AppURL = AppURL
|
|
setting.AppSubURL = AppSubURL
|
|
|
|
test := func(input, expected string) {
|
|
buffer, err := RenderString(&markup.RenderContext{
|
|
Ctx: git.DefaultContext,
|
|
Links: markup.Links{
|
|
Base: setting.AppSubURL,
|
|
},
|
|
}, input)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
|
}
|
|
|
|
url := "../../.images/src/02/train.jpg"
|
|
result := util.URLJoin(AppSubURL, url)
|
|
|
|
test("[[file:"+url+"]]",
|
|
`<p><img src="`+result+`" alt="`+result+`" /></p>`)
|
|
|
|
// With description.
|
|
test("[[https://example.com][https://example.com/example.svg]]",
|
|
`<p><a href="https://example.com"><img src="https://example.com/example.svg" alt="https://example.com/example.svg" /></a></p>`)
|
|
test("[[https://example.com][pre https://example.com/example.svg post]]",
|
|
`<p><a href="https://example.com">pre <img src="https://example.com/example.svg" alt="https://example.com/example.svg" /> post</a></p>`)
|
|
test("[[https://example.com][https://example.com/example.mp4]]",
|
|
`<p><a href="https://example.com"><video src="https://example.com/example.mp4">https://example.com/example.mp4</video></a></p>`)
|
|
test("[[https://example.com][pre https://example.com/example.mp4 post]]",
|
|
`<p><a href="https://example.com">pre <video src="https://example.com/example.mp4">https://example.com/example.mp4</video> post</a></p>`)
|
|
|
|
// Without description.
|
|
test("[[https://example.com/example.svg]]",
|
|
`<p><img src="https://example.com/example.svg" alt="https://example.com/example.svg" /></p>`)
|
|
test("[[https://example.com/example.mp4]]",
|
|
`<p><video src="https://example.com/example.mp4">https://example.com/example.mp4</video></p>`)
|
|
|
|
// Text description.
|
|
test("[[file:./lem-post.png][file:./lem-post.png]]",
|
|
`<p><a href="http://localhost:3000/gogits/gogs/lem-post.png"><img src="http://localhost:3000/gogits/gogs/lem-post.png" alt="http://localhost:3000/gogits/gogs/lem-post.png" /></a></p>`)
|
|
test("[[file:./lem-post.mp4][file:./lem-post.mp4]]",
|
|
`<p><a href="http://localhost:3000/gogits/gogs/lem-post.mp4"><video src="http://localhost:3000/gogits/gogs/lem-post.mp4">http://localhost:3000/gogits/gogs/lem-post.mp4</video></a></p>`)
|
|
}
|
|
|
|
func TestRender_Source(t *testing.T) {
|
|
setting.AppURL = AppURL
|
|
setting.AppSubURL = AppSubURL
|
|
|
|
test := func(input, expected string) {
|
|
buffer, err := RenderString(&markup.RenderContext{
|
|
Ctx: git.DefaultContext,
|
|
}, input)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
|
|
}
|
|
|
|
test(`#+begin_src go
|
|
// HelloWorld prints "Hello World"
|
|
func HelloWorld() {
|
|
fmt.Println("Hello World")
|
|
}
|
|
#+end_src
|
|
`, `<div class="src src-go">
|
|
<pre><code class="chroma language-go"><span class="c1">// HelloWorld prints "Hello World"</span>
|
|
<span class="kd">func</span> <span class="nf">HelloWorld</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">"Hello World"</span><span class="p">)</span>
|
|
<span class="p">}</span></code></pre>
|
|
</div>`)
|
|
}
|