web: preview markup before writing it !433

merged merged by cmc on 2026-09-19 20:07 UTC · krz/gitbay:markup-preview into main

Discussion

cmc

Closes #235. Every form that takes markup gets a Preview submit beside its own: issue and merge request create, their edit and comment boxes, release create and edit, the profile about text, and the file editor on a path the forge renders. It posts to the form's own action, which renders the draft and hands the page back without writing, so the preview is the rendering the thread will show, autolinks included. No JavaScript, so it is the round trip the blob page's rendered/source toggle already uses.

The =draft= type in =internal/httpd/preview.go= carries the markup, its format and the rest of the submitted form. =Is= names the textarea it belongs to, so a page with two forms previews only the one submitted, and =Or= refills a field from the draft or from what is stored. The format is the one the write would have used: the picker on create, the item's stored format on edit, markdown for a comment.

Diff-line comments are left out: they sit inside the diff, where a page-level preview has nowhere to go.

=e2e/previewweb_test.go= drives all ten forms and checks each one rendered, kept the draft, and wrote nothing. Verified by hand on a local instance in both colour schemes and at 375px.