forgejo/modules/markup/orgmode/orgmode_test.go
Renovate Bot 4b0d11976f
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
Update module github.com/alecthomas/chroma/v2 to v2.15.0 (forgejo) (#6477)
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 [@&#8203;Simran-B](https://github.com/Simran-B) in https://github.com/alecthomas/chroma/pull/968
-   chore(styles): add evergarden inspired style by [@&#8203;comfysage](https://github.com/comfysage) in https://github.com/alecthomas/chroma/pull/970
-   chore(deps): update dependency svu to v2 by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/971
-   chore(deps): update dependency watchexec to v2 by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/962
-   chore(deps): update all non-major dependencies by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/955
-   styles: Fix Gleam alias by [@&#8203;jmooring](https://github.com/jmooring) in https://github.com/alecthomas/chroma/pull/973
-   chore(deps): update all non-major dependencies by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/974
-   chore(deps): update dependency python3 to v3.12.3 by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/976
-   added the nordic theme via chroma/styles/nordic.xml by [@&#8203;avih7531](https://github.com/avih7531) in https://github.com/alecthomas/chroma/pull/977
-   Update the Materialize lexer by [@&#8203;arusahni](https://github.com/arusahni) in https://github.com/alecthomas/chroma/pull/978
-   feat(lexers/hare): add done keyword by [@&#8203;wackbyte](https://github.com/wackbyte) in https://github.com/alecthomas/chroma/pull/979
-   pygments2chroma: escape regex.words by [@&#8203;oliverpool](https://github.com/oliverpool) in https://github.com/alecthomas/chroma/pull/982
-   chore(deps): update all non-major dependencies by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/981
-   Add JSONata Lexer by [@&#8203;DevDimov](https://github.com/DevDimov) in https://github.com/alecthomas/chroma/pull/983
-   Go lexer: single line comment without consuming endline, disable EnsureNL by [@&#8203;msorc](https://github.com/msorc) in https://github.com/alecthomas/chroma/pull/984
-   Update the Materialize lexer by [@&#8203;arusahni](https://github.com/arusahni) in https://github.com/alecthomas/chroma/pull/987
-   chore(deps): update all non-major dependencies by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/985
-   Add Gleam to README by [@&#8203;Nicd](https://github.com/Nicd) in https://github.com/alecthomas/chroma/pull/990
-   Port Minecraft lexers from Pygments by [@&#8203;kofuk](https://github.com/kofuk) in https://github.com/alecthomas/chroma/pull/992
-   Don't output extra whitespace in YAML multiline by [@&#8203;Gusted](https://github.com/Gusted) in https://github.com/alecthomas/chroma/pull/993
-   chore(deps): update all non-major dependencies by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/991
-   add beef syntax and tests by [@&#8203;Booklordofthedings](https://github.com/Booklordofthedings) in https://github.com/alecthomas/chroma/pull/995
-   Update GitHub light color palette by [@&#8203;konradreiche](https://github.com/konradreiche) in https://github.com/alecthomas/chroma/pull/998
-   chore(deps): update module github.com/alecthomas/kong to v1 by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/999
-   Update the Materialize lexer by [@&#8203;arusahni](https://github.com/arusahni) in https://github.com/alecthomas/chroma/pull/1001
-   Update TypeScript lexer to allow nested generics by [@&#8203;fredrare](https://github.com/fredrare) in https://github.com/alecthomas/chroma/pull/1002
-   Pager friendly terminal formatting by [@&#8203;walles](https://github.com/walles) in https://github.com/alecthomas/chroma/pull/1006
-   chore(deps): update all non-major dependencies by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/997
-   Add Typst Lexer by [@&#8203;oliverpool](https://github.com/oliverpool) in https://github.com/alecthomas/chroma/pull/1007
-   Add Jsonnet Lexer by [@&#8203;jolheiser](https://github.com/jolheiser) in https://github.com/alecthomas/chroma/pull/1011
-   fix: add underscore parsing in numbers for haskell by [@&#8203;Gusted](https://github.com/Gusted) in https://github.com/alecthomas/chroma/pull/1020
-   Add CSV lexer by [@&#8203;walles](https://github.com/walles) in https://github.com/alecthomas/chroma/pull/1005
-   fix(typescript): highlight string literal type parameters by [@&#8203;SKalt](https://github.com/SKalt) in https://github.com/alecthomas/chroma/pull/1010
-   add any as a builtin type for go by [@&#8203;quartercastle](https://github.com/quartercastle) in https://github.com/alecthomas/chroma/pull/1021
-   chore(deps): update all non-major dependencies by [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/1013
-   Remove whitespace tokenizing rule in markdown lexer by [@&#8203;cloudchamb3r](https://github.com/cloudchamb3r) in https://github.com/alecthomas/chroma/pull/1008
-   feat(JSON): support `.jsonc` extension by [@&#8203;CarterLi](https://github.com/CarterLi) in https://github.com/alecthomas/chroma/pull/1022
-   Add Eclipse ATL language (https://eclipse.dev/atl/) by [@&#8203;dwagelaar](https://github.com/dwagelaar) in https://github.com/alecthomas/chroma/pull/1024
-   Import NSIS Lexer from Pygments by [@&#8203;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 [@&#8203;renovate](https://github.com/renovate) in https://github.com/alecthomas/chroma/pull/1025
-   fix(nix): nix lexor missing '=' operator by [@&#8203;FlyingStitchman](https://github.com/FlyingStitchman) in https://github.com/alecthomas/chroma/pull/1031
-   Add WebVTT lexer ([#&#8203;707](https://github.com/alecthomas/chroma/issues/707)) by [@&#8203;dschuessler](https://github.com/dschuessler) in https://github.com/alecthomas/chroma/pull/1032

#### New Contributors

-   [@&#8203;comfysage](https://github.com/comfysage) made their first contribution in https://github.com/alecthomas/chroma/pull/970
-   [@&#8203;avih7531](https://github.com/avih7531) made their first contribution in https://github.com/alecthomas/chroma/pull/977
-   [@&#8203;wackbyte](https://github.com/wackbyte) made their first contribution in https://github.com/alecthomas/chroma/pull/979
-   [@&#8203;oliverpool](https://github.com/oliverpool) made their first contribution in https://github.com/alecthomas/chroma/pull/982
-   [@&#8203;DevDimov](https://github.com/DevDimov) made their first contribution in https://github.com/alecthomas/chroma/pull/983
-   [@&#8203;msorc](https://github.com/msorc) made their first contribution in https://github.com/alecthomas/chroma/pull/984
-   [@&#8203;Nicd](https://github.com/Nicd) made their first contribution in https://github.com/alecthomas/chroma/pull/990
-   [@&#8203;Booklordofthedings](https://github.com/Booklordofthedings) made their first contribution in https://github.com/alecthomas/chroma/pull/995
-   [@&#8203;konradreiche](https://github.com/konradreiche) made their first contribution in https://github.com/alecthomas/chroma/pull/998
-   [@&#8203;fredrare](https://github.com/fredrare) made their first contribution in https://github.com/alecthomas/chroma/pull/1002
-   [@&#8203;SKalt](https://github.com/SKalt) made their first contribution in https://github.com/alecthomas/chroma/pull/1010
-   [@&#8203;quartercastle](https://github.com/quartercastle) made their first contribution in https://github.com/alecthomas/chroma/pull/1021
-   [@&#8203;cloudchamb3r](https://github.com/cloudchamb3r) made their first contribution in https://github.com/alecthomas/chroma/pull/1008
-   [@&#8203;CarterLi](https://github.com/CarterLi) made their first contribution in https://github.com/alecthomas/chroma/pull/1022
-   [@&#8203;dwagelaar](https://github.com/dwagelaar) made their first contribution in https://github.com/alecthomas/chroma/pull/1024
-   [@&#8203;FlyingStitchman](https://github.com/FlyingStitchman) made their first contribution in https://github.com/alecthomas/chroma/pull/1031
-   [@&#8203;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>
2025-01-06 04:11:25 +00:00

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 &#34;Hello World&#34;</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">&#34;Hello World&#34;</span><span class="p">)</span>
<span class="p">}</span></code></pre>
</div>`)
}