Escape color codes by prepending a backslash
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
This MR implements the following behaviour:
- If a color code is prepended with a backslash (), the color chip will not be rendered, and the text will be displayed without the backslash.
- Example:
\#12345→#12345(without the color chip)
References
Screenshots
spec/lib/banzai/filter/color_filter_spec.rb:
How to set up and validate locally
- Install GDK if you haven't already.
- Apply the changes from this MR.
- Restart GDK.
- Create a new project and add an .md file with the following content:
Color Codes:
- `#F00`
- `#F00A`
- `#FF0000`
- `#FF0000AA`
- `RGB(0,255,0)`
- `RGB(0%,100%,0%)`
- `RGBA(0,255,0,0.3)`
- `HSL(540,70%,50%)`
- `HSLA(540,70%,50%,0.3)`
Escaped Color Codes:
- `\#F00`
- `\#F00A`
- `\#FF0000`
- `\#FF0000AA`
- `\RGB(0,255,0)`
- `\RGB(0%,100%,0%)`
- `\RGBA(0,255,0,0.3)`
- `\HSL(540,70%,50%)`
- `\HSLA(540,70%,50%,0.3)`
- Confirm that the color chip is not activated and the text is displayed without the
\for escaped color codes cases.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #359069 (closed)
Edited by Anantha Vijay.M

