Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix markdown color code detection #30208

Merged
merged 1 commit into from Mar 31, 2024

Conversation

wxiaoguang
Copy link
Contributor

When reviewing PRs, some color names might be mentioned, the transformCodeSpan (which calls css.ColorHandler) considered it as a valid color, but actually it shouldn't be rendered as a color codespan.

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 31, 2024
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 31, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Mar 31, 2024
@wxiaoguang wxiaoguang added backport/v1.22 This PR should be backported to Gitea 1.22 type/bug labels Mar 31, 2024
@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 Mar 31, 2024
@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 Mar 31, 2024
@wxiaoguang wxiaoguang merged commit ab02835 into go-gitea:main Mar 31, 2024
26 checks passed
@GiteaBot GiteaBot added this to the 1.23.0 milestone Mar 31, 2024
@wxiaoguang wxiaoguang deleted the fix-markdown-color branch March 31, 2024 11:17
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Mar 31, 2024
When reviewing PRs, some color names might be mentioned, the
`transformCodeSpan` (which calls `css.ColorHandler`) considered it as a
valid color, but actually it shouldn't be rendered as a color codespan.
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Mar 31, 2024
wxiaoguang added a commit that referenced this pull request Mar 31, 2024
Backport #30208 by wxiaoguang

When reviewing PRs, some color names might be mentioned, the
`transformCodeSpan` (which calls `css.ColorHandler`) considered it as a
valid color, but actually it shouldn't be rendered as a color codespan.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@@ -49,9 +49,28 @@ func (r *HTMLRenderer) renderCodeSpan(w util.BufWriter, source []byte, n ast.Nod
return ast.WalkContinue, nil
}

// cssColorHandler checks if a string is a render-able CSS color value.
// The code is from "github.com/microcosm-cc/bluemonday/css.ColorHandler", except that it doesn't handle color words like "red".
Copy link
Member

Choose a reason for hiding this comment

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

This "link" is 404. I wonder if it can handle hex RRGGBBAA syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not a link, it just refers to the package and its method.

And, modern IDE could resolve the method name:

image

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 wonder if it can handle hex RRGGBBAA syntax.

image

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Seems far-fetched that a IDE should highlight inside "links". Better to put web links next time.

Copy link
Member

Choose a reason for hiding this comment

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

And no, I don't mean rgba() syntax, bug #rrggbbaa and also #rgba.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Seems far-fetched that a IDE should highlight inside "links". Better to put web links next time.

But Golang's package import is not a link, it is just a package path : "github.com/microcosm-cc/bluemonday/css"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And no, I don't mean rgba() syntax, bug #rrggbbaa and also #rgba.
It's a upstream bug that it does not support #rgba:

Sorry, I don't understand what do you mean. I think #rgba is well-supported.

image

image

OK, I see your point, you only mean #rgba the short format.

Copy link
Member

Choose a reason for hiding this comment

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

No, it only support 3,6,8 length, not 4 length.

Copy link
Member

Choose a reason for hiding this comment

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

zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 31, 2024
* giteaofficial/main:
  Remove fomantic input module (go-gitea#30194)
  Remove most jQuery function calls from the repository topic box (go-gitea#30191)
  Prevent flash of dropdown menu on labels list (go-gitea#30215)
  Remove jQuery class from the `repo-issue.js` file (go-gitea#30192)
  Ignore fomantic folder in linters (go-gitea#30200)
  Remove `modifies/frontend` from labeler (go-gitea#30198)
  Make a distinction between `active` and `selected` in the issue author dropdown (go-gitea#30207)
  Move and simplify tab-size helpers (go-gitea#30196)
  Fix markdown color code detection (go-gitea#30208)
@wxiaoguang wxiaoguang added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.22 This PR should be backported to Gitea 1.22 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code size/S Denotes a PR that changes 10-29 lines, ignoring generated files. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants