Make Syntax\ Highlighting.py not language specific

This commit is contained in:
Out Of Ideas 2024-05-21 21:47:21 -05:00
parent e0d17d68c8
commit 7031a4ed7c

View file

@ -45,84 +45,72 @@ int main() {
}
# Define colors for different classes (modify as needed)
class_colors_c = {
"c": "#3D7B7B",
"k": "#008000",
"ch": "#3D7B7B",
"cm": "#3D7B7B",
"cpf": "#3D7B7B",
"c1": "#3D7B7B",
"cs": "#3D7B7B",
"gh": "#000080",
"gp": "#000080",
"gu": "#800080",
"kc": "#008000",
"kd": "#008000",
"kn": "#008000",
"kr": "#008000",
"nc": "#0000FF",
"ni": "#717171",
"ne": "#CB3F38",
"nn": "#0000FF",
"nt": "#008000",
"ow": "#AA22FF",
"sd": "#BA2121",
"se": "#AA5D1F",
"si": "#A45A77",
}
# Define colors for different classes (modify as needed)
class_colors_bash = {
"bash .c": "#3D7B7B",
"bash .k": "#008000",
"bash .ch": "#3D7B7B",
"bash .cm": "#3D7B7B",
"bash .cpf": "#3D7B7B",
"bash .c1": "#3D7B7B",
"bash .cs": "#3D7B7B",
"bash .gh": "#000080",
"bash .gp": "#000080",
"bash .gu": "#800080",
"bash .kc": "#008000",
"bash .kd": "#008000",
"bash .kn": "#008000",
"bash .kr": "#008000",
"bash .nc": "#0000FF",
"bash .ni": "#717171",
"bash .ne": "#CB3F38",
"bash .nn": "#0000FF",
"bash .nt": "#008000",
"bash .ow": "#AA22FF",
"bash .sd": "#BA2121",
"bash .se": "#AA5D1F",
"bash .si": "#A45A77",
}
# Define colors for different classes (modify as needed)
class_colors_html = {
"html .c": "#3D7B7B",
"html .k": "#008000",
"html .ch": "#3D7B7B",
"html .cm": "#3D7B7B",
"html .cpf": "#3D7B7B",
"html .c1": "#3D7B7B",
"html .cs": "#3D7B7B",
"html .gh": "#000080",
"html .gp": "#000080",
"html .gu": "#800080",
"html .kc": "#008000",
"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",
class_colors = {
"hll": "#ffffcc",
"c": "#3D7B7B", # Comment
"k": "#008000", # Keyword
"o": "#666666", # Operator
"ch": "#3D7B7B", # Comment.Hashbang
"cm": "#3D7B7B", # Comment.Multiline
"cp": "#9C6500", # Comment.Preproc
"cpf": "#3D7B7B", # Comment.PreprocFile
"c1": "#3D7B7B", # Comment.Single
"cs": "#3D7B7B", # Comment.Special
"gd": "#A00000", # Generic.Deleted
"gr": "#E40000", # Generic.Error
"gh": "#000080", # Generic.Heading
"gi": "#008400", # Generic.Inserted
"go": "#717171", # Generic.Output
"gp": "#000080", # Generic.Prompt
"gu": "#800080", # Generic.Subheading
"gt": "#0044DD", # Generic.Traceback
"kc": "#008000", # Keyword.Constant
"kd": "#008000", # Keyword.Declaration
"kn": "#008000", # Keyword.Namespace
"kp": "#008000", # Keyword.Pseudo
"kr": "#008000", # Keyword.Reserved
"kt": "#B00040", # Keyword.Type
"m": "#666666", # Literal.Number
"s": "#BA2121", # Literal.String
"na": "#687822", # Name.Attribute
"nb": "#008000", # Name.Builtin
"nc": "#0000FF", # Name.Class
"no": "#880000", # Name.Constant
"nd": "#AA22FF", # Name.Decorator
"ni": "#717171", # Name.Entity
"ne": "#CB3F38", # Name.Exception
"nf": "#0000FF", # Name.Function
"nl": "#767600", # Name.Label
"nn": "#0000FF", # Name.Namespace
"nt": "#008000", # Name.Tag
"nv": "#19177C", # Name.Variable
"ow": "#AA22FF", # Operator.Word
"w": "#bbbbbb", # Text.Whitespace
"mb": "#666666", # Literal.Number.Bin
"mf": "#666666", # Literal.Number.Float
"mh": "#666666", # Literal.Number.Hex
"mi": "#666666", # Literal.Number.Integer
"mo": "#666666", # Literal.Number.Oct
"sa": "#BA2121", # Literal.String.Affix
"sb": "#BA2121", # Literal.String.Backtick
"sc": "#BA2121", # Literal.String.Char
"dl": "#BA2121", # Literal.String.Delimiter
"sd": "#BA2121", # Literal.String.Doc
"s2": "#BA2121", # Literal.String.Double
"se": "#AA5D1F", # Literal.String.Escape
"sh": "#BA2121", # Literal.String.Heredoc
"si": "#A45A77", # Literal.String.Interpol
"sx": "#008000", # Literal.String.Other
"sr": "#A45A77", # Literal.String.Regex
"s1": "#BA2121", # Literal.String.Single
"ss": "#19177C", # Literal.String.Symbol
"bp": "#008000", # Name.Builtin.Pseudo
"fm": "#0000FF", # Name.Function.Magic
"vc": "#19177C", # Name.Variable.Class
"vg": "#19177C", # Name.Variable.Global
"vi": "#19177C", # Name.Variable.Instance
"vm": "#19177C", # Name.Variable.Magic
"il": "#666666", # Literal.Number.Integer.Long
}
# 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
if snippet_name == "c":
lexer = get_lexer_by_name("c")
class_colors = class_colors_c
elif snippet_name == "bash":
lexer = get_lexer_by_name("bash")
class_colors = class_colors_bash
elif snippet_name == "html":
lexer = get_lexer_by_name("html")
class_colors = class_colors_html
else:
raise ValueError(f"No lexer for language '{snippet_name}' found.")