mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Fix markdown color code detection (#30208)
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.
This commit is contained in:
		@@ -436,6 +436,10 @@ func TestColorPreview(t *testing.T) {
 | 
			
		||||
		testcase string
 | 
			
		||||
		expected string
 | 
			
		||||
	}{
 | 
			
		||||
		{ // do not render color names
 | 
			
		||||
			"The CSS class `red` is there",
 | 
			
		||||
			"<p>The CSS class <code>red</code> is there</p>\n",
 | 
			
		||||
		},
 | 
			
		||||
		{ // hex
 | 
			
		||||
			"`#FF0000`",
 | 
			
		||||
			`<p><code>#FF0000<span class="color-preview" style="background-color: #FF0000"></span></code></p>` + nl,
 | 
			
		||||
@@ -445,8 +449,8 @@ func TestColorPreview(t *testing.T) {
 | 
			
		||||
			`<p><code>rgb(16, 32, 64)<span class="color-preview" style="background-color: rgb(16, 32, 64)"></span></code></p>` + nl,
 | 
			
		||||
		},
 | 
			
		||||
		{ // short hex
 | 
			
		||||
			"This is the color white `#000`",
 | 
			
		||||
			`<p>This is the color white <code>#000<span class="color-preview" style="background-color: #000"></span></code></p>` + nl,
 | 
			
		||||
			"This is the color white `#0a0`",
 | 
			
		||||
			`<p>This is the color white <code>#0a0<span class="color-preview" style="background-color: #0a0"></span></code></p>` + nl,
 | 
			
		||||
		},
 | 
			
		||||
		{ // hsl
 | 
			
		||||
			"HSL stands for hue, saturation, and lightness. An example: `hsl(0, 100%, 50%)`.",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user