mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-27 00:23:41 +09:00 
			
		
		
		
	Add color previews in markdown (#21474)
* Resolves #3047 Every time a color code will be in \`backticks`, a cute little color preview will pop up [Inspiration](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#supported-color-models) #### Before  #### After  Signed-off-by: Yarden Shoham <hrsi88@gmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		| @@ -55,6 +55,9 @@ func createDefaultPolicy() *bluemonday.Policy { | ||||
| 	// For JS code copy and Mermaid loading state | ||||
| 	policy.AllowAttrs("class").Matching(regexp.MustCompile(`^code-block( is-loading)?$`)).OnElements("pre") | ||||
|  | ||||
| 	// For color preview | ||||
| 	policy.AllowAttrs("class").Matching(regexp.MustCompile(`^color-preview$`)).OnElements("span") | ||||
|  | ||||
| 	// For Chroma markdown plugin | ||||
| 	policy.AllowAttrs("class").Matching(regexp.MustCompile(`^(chroma )?language-[\w-]+( display)?( is-loading)?$`)).OnElements("code") | ||||
|  | ||||
| @@ -88,8 +91,8 @@ func createDefaultPolicy() *bluemonday.Policy { | ||||
| 	// Allow 'style' attribute on text elements. | ||||
| 	policy.AllowAttrs("style").OnElements("span", "p") | ||||
|  | ||||
| 	// Allow 'color' property for the style attribute on text elements. | ||||
| 	policy.AllowStyles("color").OnElements("span", "p") | ||||
| 	// Allow 'color' and 'background-color' properties for the style attribute on text elements. | ||||
| 	policy.AllowStyles("color", "background-color").OnElements("span", "p") | ||||
|  | ||||
| 	// Allow generally safe attributes | ||||
| 	generalSafeAttrs := []string{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user