Skip to content

feat(webui): remark upgrade + gfm + syntax highlighting#1444

Merged
sudoforge merged 5 commits intogit-bug:masterfrom
lygaret:webui-feat-syntax-highlighting
May 17, 2025
Merged

feat(webui): remark upgrade + gfm + syntax highlighting#1444
sudoforge merged 5 commits intogit-bug:masterfrom
lygaret:webui-feat-syntax-highlighting

Conversation

@lygaret
Copy link
Contributor

@lygaret lygaret commented May 17, 2025

  • upgrades remark/rehype/unified npm packages, and reconfigures everything for 2025
  • Label can now be made inline, which fixes a react hydration error on the bug page
  • new remark plugins for GFM, hard line breaks & syntax highlighting

lygaret added 4 commits May 16, 2025 23:11
updates remark/rehype/unified to the latest versions, and reconfigures
the markdown pipeline to be more efficient and use the latest plugins.

the pipeline now includes GFM style features like code highlighting,
footnotes, inline urls, and hard line breaks, and no longer double
parses to html.

also implements the first part of code highlighting in markdown,
what's left is correctly bringing in theme css files
the full theme is loaded, but controled by a parent's data attribute.
p>div is not a valid nesting in HTML, and with strict-mode turned on,
react complains about it.

this fix allows labels to be inline, and then uses that in the LabelChange
component to avoid getting hydration warnings from react
<Route element={<NotFoundPage />} />
</Routes>
</Layout>
</React.StrictMode>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

gets us warnings for strict-mode violations in dev-mode, and nop in prod

.use(rehypeSanitize as unknown as RehypePlugin)
.use(rehypeHighlight as unknown as RehypePlugin<RehypeHighlightOpts[]>, {
detect: true,
subset: ['text'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the subset of languages syntax highlighting will try if no language is provided

  • without detect:true, code blocks without a given language have bad styling (no margin/padding)
  • ['text'] as a subset means we only bother trying plain text as the default, which does no additional highlighting.

Copy link
Contributor

Choose a reason for hiding this comment

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

without detect:true, code blocks without a given language have bad styling (no margin/padding)

that's a weird design choice. good catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could have hacked together css to do it, but this was cleaner imo

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, i see no issue with it. that's the behavior i would expect, tbh -- plain text unless i specify a language.

@lygaret
Copy link
Contributor Author

lygaret commented May 17, 2025

before/after screenshots:

before light
Screenshot 2025-05-16 at 11 22 53 PM

after light
Screenshot 2025-05-16 at 11 22 47 PM

before dark
Screenshot 2025-05-16 at 11 22 37 PM

after dark
Screenshot 2025-05-16 at 11 22 44 PM

Copy link
Contributor

@sudoforge sudoforge left a comment

Choose a reason for hiding this comment

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

lgtm. i like the better differentiation between code blocks and the comment background that this change brings in.

@sudoforge sudoforge added this pull request to the merge queue May 17, 2025
Merged via the queue into git-bug:master with commit 6ee47b9 May 17, 2025
8 checks passed
@lygaret lygaret mentioned this pull request May 17, 2025
@MichaelMure
Copy link
Contributor

Love it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants