-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix broken Chroma CSS styles #23174
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
Merged
Merged
Fix broken Chroma CSS styles #23174
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9c090cc
fix
wxiaoguang fd8e091
fix stylelint
wxiaoguang 9165c17
Merge branch 'main' into fix-chroma-css
wxiaoguang cc279dc
move stylelint override to config
silverwind da20310
Update .stylelintrc.yaml
silverwind 97fe91c
Merge branch 'main' into fix-chroma-css
wxiaoguang d761264
use "base.less" for chroma
wxiaoguang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build ignore | ||
|
||
/* | ||
This tool is used to compare the CSS names in a chroma builtin styles with the Gitea theme CSS names. | ||
|
||
It outputs the difference between the two sets of CSS names, eg: | ||
|
||
``` | ||
CSS names not in builtin: | ||
.chroma .ln | ||
---- | ||
Builtin CSS names not in file: | ||
.chroma .vm | ||
``` | ||
|
||
Developers could use this tool to re-sync the CSS names in the Gitea theme. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/alecthomas/chroma/v2" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) != 2 { | ||
println("Usage: chroma-style-diff css-or-less-file") | ||
os.Exit(1) | ||
} | ||
|
||
data, err := os.ReadFile(os.Args[1]) | ||
if err != nil { | ||
println(err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
content := string(data) | ||
|
||
// a simple CSS parser to collect CSS names | ||
content = regexp.MustCompile("//.*\r?\n").ReplaceAllString(content, "\n") | ||
content = regexp.MustCompile("/\\*.*?\\*/").ReplaceAllString(content, "") | ||
matches := regexp.MustCompile("\\s*([-.#:\\w\\s]+)\\s*\\{[^}]*}").FindAllStringSubmatch(content, -1) | ||
|
||
cssNames := map[string]bool{} | ||
for _, matchGroup := range matches { | ||
cssName := strings.TrimSpace(matchGroup[1]) | ||
cssNames[cssName] = true | ||
} | ||
|
||
// collect Chroma builtin CSS names | ||
builtin := map[string]bool{} | ||
for tokenType, cssName := range chroma.StandardTypes { | ||
if tokenType > 0 && cssName != "" { | ||
builtin[".chroma ."+cssName] = true | ||
} | ||
} | ||
|
||
// show the diff | ||
println("CSS names not in builtin:") | ||
for cssName := range cssNames { | ||
if !builtin[cssName] { | ||
println(cssName) | ||
} | ||
} | ||
println("----") | ||
println("Builtin CSS names not in file:") | ||
for cssName := range builtin { | ||
if !cssNames[cssName] { | ||
println(cssName) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
@import "../chroma/dark.less"; | ||
@import "../chroma/overwrite.less"; | ||
@import "../codemirror/dark.less"; | ||
|
||
:root { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.