Skip to content

chore: introduce HTMLBuilder#37688

Merged
wxiaoguang merged 4 commits into
go-gitea:mainfrom
wxiaoguang:refactor-html-builder
May 13, 2026
Merged

chore: introduce HTMLBuilder#37688
wxiaoguang merged 4 commits into
go-gitea:mainfrom
wxiaoguang:refactor-html-builder

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

No description provided.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces new HTML helper APIs (HTMLPrintf usage patterns plus a new HTMLBuilder) and refactors a few call sites to write escaped HTML directly to an io.Writer rather than allocating intermediate strings.

Changes:

  • Add htmlutil.EscapeString and a fluent htmlutil.HTMLBuilder with tests.
  • Replace some HTMLFormat + Write([]byte(...)) patterns with htmlutil.HTMLPrintf(...).
  • Minor internal rendering refactor to use io.WriteString when outputting template.HTML.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
routers/web/repo/view_home.go Switches only_content submodule response to emit meta-refresh via HTMLPrintf.
modules/web/router.go Uses HTMLPrintf for a 404 HTML response body.
modules/markup/orgmode/orgmode.go Replaces a small local helper with direct HTMLPrintf calls for links/media.
modules/markup/internal/renderinternal.go Writes protected HTML via io.WriteString instead of []byte(...).
modules/htmlutil/html.go Adds EscapeString and the new HTMLBuilder type.
modules/htmlutil/html_test.go Adds unit coverage for HTMLBuilder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routers/web/repo/view_home.go
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 13, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 13, 2026
@bircni bircni added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label May 13, 2026
@bircni
Copy link
Copy Markdown
Member

bircni commented May 13, 2026

@wxiaoguang isn't it a refactor?

@wxiaoguang
Copy link
Copy Markdown
Contributor Author

Too trivial to appear in the changelog

@wxiaoguang wxiaoguang enabled auto-merge (squash) May 13, 2026 16:48
@bircni bircni added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 13, 2026
@wxiaoguang wxiaoguang merged commit 5238220 into go-gitea:main May 13, 2026
21 checks passed
@GiteaBot GiteaBot added this to the 1.27.0 milestone May 13, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 13, 2026
@wxiaoguang wxiaoguang deleted the refactor-html-builder branch May 13, 2026 18:03
silverwind added a commit to bircni/gitea that referenced this pull request May 14, 2026
…thor

* origin/main:
  [skip ci] Updated translations via Crowdin
  fix: snap build (main branch) (go-gitea#37685)
  chore: introduce HTMLBuilder (go-gitea#37688)
  chore: clean up "contrib" dir (go-gitea#37690)
  feat(api): add sort and order query parameters to job list endpoints (go-gitea#37672)
  fix: Sort action run jobs by JobID and Name with matrix examples (go-gitea#37046)
  fix: catch and fix more lint problems (go-gitea#37674)
  docs(agents): update AGENTS.md (go-gitea#37684)
  fix(actions): run `TransferLogs` on `UpdateLog{Rows:[], NoMore:true}` (go-gitea#37631)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants