From c6a2b7e0a6b5c9ca4ccfa4e6195caa042c42b922 Mon Sep 17 00:00:00 2001 From: Robert Wolff Date: Sat, 6 Sep 2025 16:23:06 +0200 Subject: [PATCH] feat(ui): render ordered checkbox lists with numbers (#9184) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses #6332. This allows ``` 1. [ ] task1 2. [ ] task2 ``` to be rendered with numbers. It also fixes a little alignment issue between items from unordered checkbox and other lists. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9184 Reviewed-by: Earl Warren Reviewed-by: Ellen Εμιλία Άννα Zscheile Reviewed-by: Gusted Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Robert Wolff Co-committed-by: Robert Wolff --- modules/markup/markdown/markdown_test.go | 21 +++++++++++++++++++++ web_src/css/markup/content.css | 9 ++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index f9306b99a2..7c13494a67 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -882,6 +882,27 @@ foo: bar } } +func TestRenderCheckList(t *testing.T) { + input := `- [ ] a +- [x] b +1. [x] a +2. [ ] b +5. [ ] e` + expected := `
    +
  • a
  • +
  • b
  • +
+
    +
  1. a
  2. +
  3. b
  4. +
  5. e
  6. +
+` + res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, input) + require.NoError(t, err) + assert.Equal(t, template.HTML(expected), res) +} + func TestRenderLinks(t *testing.T) { input := ` space @mention-user${SPACE}${SPACE} /just/a/path.bin diff --git a/web_src/css/markup/content.css b/web_src/css/markup/content.css index 8a872f2623..b22df9a402 100644 --- a/web_src/css/markup/content.css +++ b/web_src/css/markup/content.css @@ -153,7 +153,7 @@ list-style-type: none; } -.markup .task-list-item { +.markup ul .task-list-item { list-style-type: none; } @@ -162,11 +162,14 @@ } .markup .task-list-item input[type="checkbox"] { - margin: 0 .3em .25em -1.4em; - vertical-align: middle; + margin: 0 .4em .25em -1.4em; padding: 0; } +.markup ol .task-list-item input[type="checkbox"] { + margin-left: 0; +} + .markup .task-list-item input[type="checkbox"] + p { margin-left: -0.2em; display: inline;