Make Syntax\ Highlighting.py not language specific
This commit is contained in:
parent
e0d17d68c8
commit
7031a4ed7c
1 changed files with 66 additions and 81 deletions
|
@ -45,84 +45,72 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define colors for different classes (modify as needed)
|
# Define colors for different classes (modify as needed)
|
||||||
class_colors_c = {
|
class_colors = {
|
||||||
"c": "#3D7B7B",
|
"hll": "#ffffcc",
|
||||||
"k": "#008000",
|
"c": "#3D7B7B", # Comment
|
||||||
"ch": "#3D7B7B",
|
"k": "#008000", # Keyword
|
||||||
"cm": "#3D7B7B",
|
"o": "#666666", # Operator
|
||||||
"cpf": "#3D7B7B",
|
"ch": "#3D7B7B", # Comment.Hashbang
|
||||||
"c1": "#3D7B7B",
|
"cm": "#3D7B7B", # Comment.Multiline
|
||||||
"cs": "#3D7B7B",
|
"cp": "#9C6500", # Comment.Preproc
|
||||||
"gh": "#000080",
|
"cpf": "#3D7B7B", # Comment.PreprocFile
|
||||||
"gp": "#000080",
|
"c1": "#3D7B7B", # Comment.Single
|
||||||
"gu": "#800080",
|
"cs": "#3D7B7B", # Comment.Special
|
||||||
"kc": "#008000",
|
"gd": "#A00000", # Generic.Deleted
|
||||||
"kd": "#008000",
|
"gr": "#E40000", # Generic.Error
|
||||||
"kn": "#008000",
|
"gh": "#000080", # Generic.Heading
|
||||||
"kr": "#008000",
|
"gi": "#008400", # Generic.Inserted
|
||||||
"nc": "#0000FF",
|
"go": "#717171", # Generic.Output
|
||||||
"ni": "#717171",
|
"gp": "#000080", # Generic.Prompt
|
||||||
"ne": "#CB3F38",
|
"gu": "#800080", # Generic.Subheading
|
||||||
"nn": "#0000FF",
|
"gt": "#0044DD", # Generic.Traceback
|
||||||
"nt": "#008000",
|
"kc": "#008000", # Keyword.Constant
|
||||||
"ow": "#AA22FF",
|
"kd": "#008000", # Keyword.Declaration
|
||||||
"sd": "#BA2121",
|
"kn": "#008000", # Keyword.Namespace
|
||||||
"se": "#AA5D1F",
|
"kp": "#008000", # Keyword.Pseudo
|
||||||
"si": "#A45A77",
|
"kr": "#008000", # Keyword.Reserved
|
||||||
}
|
"kt": "#B00040", # Keyword.Type
|
||||||
|
"m": "#666666", # Literal.Number
|
||||||
# Define colors for different classes (modify as needed)
|
"s": "#BA2121", # Literal.String
|
||||||
class_colors_bash = {
|
"na": "#687822", # Name.Attribute
|
||||||
"bash .c": "#3D7B7B",
|
"nb": "#008000", # Name.Builtin
|
||||||
"bash .k": "#008000",
|
"nc": "#0000FF", # Name.Class
|
||||||
"bash .ch": "#3D7B7B",
|
"no": "#880000", # Name.Constant
|
||||||
"bash .cm": "#3D7B7B",
|
"nd": "#AA22FF", # Name.Decorator
|
||||||
"bash .cpf": "#3D7B7B",
|
"ni": "#717171", # Name.Entity
|
||||||
"bash .c1": "#3D7B7B",
|
"ne": "#CB3F38", # Name.Exception
|
||||||
"bash .cs": "#3D7B7B",
|
"nf": "#0000FF", # Name.Function
|
||||||
"bash .gh": "#000080",
|
"nl": "#767600", # Name.Label
|
||||||
"bash .gp": "#000080",
|
"nn": "#0000FF", # Name.Namespace
|
||||||
"bash .gu": "#800080",
|
"nt": "#008000", # Name.Tag
|
||||||
"bash .kc": "#008000",
|
"nv": "#19177C", # Name.Variable
|
||||||
"bash .kd": "#008000",
|
"ow": "#AA22FF", # Operator.Word
|
||||||
"bash .kn": "#008000",
|
"w": "#bbbbbb", # Text.Whitespace
|
||||||
"bash .kr": "#008000",
|
"mb": "#666666", # Literal.Number.Bin
|
||||||
"bash .nc": "#0000FF",
|
"mf": "#666666", # Literal.Number.Float
|
||||||
"bash .ni": "#717171",
|
"mh": "#666666", # Literal.Number.Hex
|
||||||
"bash .ne": "#CB3F38",
|
"mi": "#666666", # Literal.Number.Integer
|
||||||
"bash .nn": "#0000FF",
|
"mo": "#666666", # Literal.Number.Oct
|
||||||
"bash .nt": "#008000",
|
"sa": "#BA2121", # Literal.String.Affix
|
||||||
"bash .ow": "#AA22FF",
|
"sb": "#BA2121", # Literal.String.Backtick
|
||||||
"bash .sd": "#BA2121",
|
"sc": "#BA2121", # Literal.String.Char
|
||||||
"bash .se": "#AA5D1F",
|
"dl": "#BA2121", # Literal.String.Delimiter
|
||||||
"bash .si": "#A45A77",
|
"sd": "#BA2121", # Literal.String.Doc
|
||||||
}
|
"s2": "#BA2121", # Literal.String.Double
|
||||||
|
"se": "#AA5D1F", # Literal.String.Escape
|
||||||
# Define colors for different classes (modify as needed)
|
"sh": "#BA2121", # Literal.String.Heredoc
|
||||||
class_colors_html = {
|
"si": "#A45A77", # Literal.String.Interpol
|
||||||
"html .c": "#3D7B7B",
|
"sx": "#008000", # Literal.String.Other
|
||||||
"html .k": "#008000",
|
"sr": "#A45A77", # Literal.String.Regex
|
||||||
"html .ch": "#3D7B7B",
|
"s1": "#BA2121", # Literal.String.Single
|
||||||
"html .cm": "#3D7B7B",
|
"ss": "#19177C", # Literal.String.Symbol
|
||||||
"html .cpf": "#3D7B7B",
|
"bp": "#008000", # Name.Builtin.Pseudo
|
||||||
"html .c1": "#3D7B7B",
|
"fm": "#0000FF", # Name.Function.Magic
|
||||||
"html .cs": "#3D7B7B",
|
"vc": "#19177C", # Name.Variable.Class
|
||||||
"html .gh": "#000080",
|
"vg": "#19177C", # Name.Variable.Global
|
||||||
"html .gp": "#000080",
|
"vi": "#19177C", # Name.Variable.Instance
|
||||||
"html .gu": "#800080",
|
"vm": "#19177C", # Name.Variable.Magic
|
||||||
"html .kc": "#008000",
|
"il": "#666666", # Literal.Number.Integer.Long
|
||||||
"html .kd": "#008000",
|
|
||||||
"html .kn": "#008000",
|
|
||||||
"html .kr": "#008000",
|
|
||||||
"html .nc": "#0000FF",
|
|
||||||
"html .ni": "#717171",
|
|
||||||
"html .ne": "#CB3F38",
|
|
||||||
"html .nn": "#0000FF",
|
|
||||||
"html .nt": "#008000",
|
|
||||||
"html .ow": "#AA22FF",
|
|
||||||
"html .sd": "#BA2121",
|
|
||||||
"html .se": "#AA5D1F",
|
|
||||||
"html .si": "#A45A77",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a directory to store the generated HTML files
|
# Create a directory to store the generated HTML files
|
||||||
|
@ -135,13 +123,10 @@ for snippet_name, code in code_snippets.items():
|
||||||
# Choose lexer based on the language
|
# Choose lexer based on the language
|
||||||
if snippet_name == "c":
|
if snippet_name == "c":
|
||||||
lexer = get_lexer_by_name("c")
|
lexer = get_lexer_by_name("c")
|
||||||
class_colors = class_colors_c
|
|
||||||
elif snippet_name == "bash":
|
elif snippet_name == "bash":
|
||||||
lexer = get_lexer_by_name("bash")
|
lexer = get_lexer_by_name("bash")
|
||||||
class_colors = class_colors_bash
|
|
||||||
elif snippet_name == "html":
|
elif snippet_name == "html":
|
||||||
lexer = get_lexer_by_name("html")
|
lexer = get_lexer_by_name("html")
|
||||||
class_colors = class_colors_html
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"No lexer for language '{snippet_name}' found.")
|
raise ValueError(f"No lexer for language '{snippet_name}' found.")
|
||||||
|
|
||||||
|
|
Reference in a new issue