diff --git a/Syntax Highlighting.py b/Syntax Highlighting.py index 204a6af..29938b1 100644 --- a/Syntax Highlighting.py +++ b/Syntax Highlighting.py @@ -7,7 +7,7 @@ import os # Import the os module code_snippets = { # These are code examples. # I recommend only generating HTML code for one language at a time, and using different class_colors. - "command_line": 'echo "This is an example"', + "bash": 'echo "This is an example"', "c": """ #include #include @@ -46,41 +46,85 @@ int main() { # Define colors for different classes (modify as needed) class_colors_c = { - "cw": "#ffffff", # Default text color (white) - "c": "#ff0000", # Comments (red) - "nf": "#00ff00", # Numbers (green) - "kd": "#0000ff", # Keywords (blue) - "cm": "#808080", # Comment (gray) - "cp": "#ffff00", # Preprocessor (yellow) - "kt": "#0000ff", # Keyword.Type (blue) - "n": "#00ff00", # Number (green) - "o": "#dcdcaa", # Operator (light yellow) - "s": "#d79921", # String (orange) - "se": "#dcdcaa", # Separator (light yellow) - "w": "#ffffff", # Whitespace (white) - "nc": "#ff00ff", # Class name (magenta) - "kn": "#00ffff", # Keyword (cyan) - "si": "#ff9900", # Special Identifier (orange) - "nb": "#ff66cc", # Built-in name (pink) - "mh": "#cccccc", # Meta information (light gray) - "ss": "#6666ff", # Sub-string (blue) - "ni": "#ffcc66", # Number integer (light orange) - "nd": "#99ccff", # Number decimal (light blue) - "nt": "#ff3366", # HTML tag (red-pink) - "na": "#66ffcc", # Attribute name (light cyan) + "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", } -class_colors_command_line = { - "cw": "#ffffff", - "k": "#FFFF00", - "s": "#00FFFF", +# 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 = { - "c": "#FFA07A", - "na": "#98FB98", - "nt": "#87CEFA", + "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", } + # Create a directory to store the generated HTML files output_dir = "highlighted_code" if not os.path.exists(output_dir): @@ -92,9 +136,9 @@ for snippet_name, code in code_snippets.items(): if snippet_name == "c": lexer = get_lexer_by_name("c") class_colors = class_colors_c - elif snippet_name == "command_line": + elif snippet_name == "bash": lexer = get_lexer_by_name("bash") - class_colors = class_colors_command_line + class_colors = class_colors_bash elif snippet_name == "html": lexer = get_lexer_by_name("html") class_colors = class_colors_html