Created
January 10, 2025 19:59
-
-
Save Cynosphere/b0f8c1546a64c67398981cee9391568c to your computer and use it in GitHub Desktop.
highlight.js ANSI support with 256 colors and styling
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
@keyframes hljs-ansi-blink { | |
50% { | |
opacity: 0; | |
} | |
} | |
.hljs-ansi-control-sequence { | |
display: none | |
} | |
.hljs-ansi-style-bold { | |
font-weight: 700 | |
} | |
.hljs-ansi-style-underline { | |
text-decoration: underline | |
} | |
.hljs-ansi-style-dim { | |
opacity: 0.5; | |
} | |
.hljs-ansi-style-blink { | |
animation: hljs-ansi-blink 1s linear infinite; | |
} | |
.hljs-ansi-style-hidden { | |
color: transparent !important; | |
} | |
.hljs-ansi-style-strike { | |
text-decoration: line-through; | |
} | |
/* using Tango as a sane default */ | |
.hljs-ansi-foreground-black { | |
color: #000000; | |
} | |
.hljs-ansi-foreground-red { | |
color: #cc0000; | |
} | |
.hljs-ansi-foreground-green { | |
color: #4e9a06; | |
} | |
.hljs-ansi-foreground-yellow { | |
color: #c4a000; | |
} | |
.hljs-ansi-foreground-blue { | |
color: #3465a4; | |
} | |
.hljs-ansi-foreground-magenta { | |
color: #75507b; | |
} | |
.hljs-ansi-foreground-cyan { | |
color: #06989a; | |
} | |
.hljs-ansi-foreground-white { | |
color: #d3d7cf; | |
} | |
.hljs-ansi-foreground-black-bright { | |
color: #555753; | |
} | |
.hljs-ansi-foreground-red-bright { | |
color: #ef2929; | |
} | |
.hljs-ansi-foreground-green-bright { | |
color: #8ae234; | |
} | |
.hljs-ansi-foreground-yellow-bright { | |
color: #fce94f; | |
} | |
.hljs-ansi-foreground-blue-bright { | |
color: #729fcf; | |
} | |
.hljs-ansi-foreground-magenta-bright { | |
color: #ad7fa8; | |
} | |
.hljs-ansi-foreground-cyan-bright { | |
color: #34e2e2; | |
} | |
.hljs-ansi-foreground-white-bright { | |
color: #eeeeec; | |
} | |
.hljs-ansi-background-black { | |
background-color: #000000; | |
} | |
.hljs-ansi-background-red { | |
background-color: #cc0000; | |
} | |
.hljs-ansi-background-green { | |
background-color: #4e9a06; | |
} | |
.hljs-ansi-background-yellow { | |
background-color: #c4a000; | |
} | |
.hljs-ansi-background-blue { | |
background-color: #3465a4; | |
} | |
.hljs-ansi-background-magenta { | |
background-color: #75507b; | |
} | |
.hljs-ansi-background-cyan { | |
background-color: #06989a; | |
} | |
.hljs-ansi-background-white { | |
background-color: #d3d7cf; | |
} | |
.hljs-ansi-background-black-bright { | |
background-color: #555753; | |
} | |
.hljs-ansi-background-red-bright { | |
background-color: #ef2929; | |
} | |
.hljs-ansi-background-green-bright { | |
background-color: #8ae234; | |
} | |
.hljs-ansi-background-yellow-bright { | |
background-color: #fce94f; | |
} | |
.hljs-ansi-background-blue-bright { | |
background-color: #729fcf; | |
} | |
.hljs-ansi-background-magenta-bright { | |
background-color: #ad7fa8; | |
} | |
.hljs-ansi-background-cyan-bright { | |
background-color: #34e2e2; | |
} | |
.hljs-ansi-background-white-bright { | |
background-color: #eeeeec; | |
} | |
/* 256 colors */ | |
.hljs-ansi-foreground-16 { | |
color: #000000; | |
} | |
.hljs-ansi-background-16 { | |
background-color: #000000; | |
} | |
.hljs-ansi-foreground-17 { | |
color: #00005f; | |
} | |
.hljs-ansi-background-17 { | |
background-color: #00005f; | |
} | |
.hljs-ansi-foreground-18 { | |
color: #000087; | |
} | |
.hljs-ansi-background-18 { | |
background-color: #000087; | |
} | |
.hljs-ansi-foreground-19 { | |
color: #0000af; | |
} | |
.hljs-ansi-background-19 { | |
background-color: #0000af; | |
} | |
.hljs-ansi-foreground-20 { | |
color: #0000d7; | |
} | |
.hljs-ansi-background-20 { | |
background-color: #0000d7; | |
} | |
.hljs-ansi-foreground-21 { | |
color: #0000ff; | |
} | |
.hljs-ansi-background-21 { | |
background-color: #0000ff; | |
} | |
.hljs-ansi-foreground-22 { | |
color: #005f00; | |
} | |
.hljs-ansi-background-22 { | |
background-color: #005f00; | |
} | |
.hljs-ansi-foreground-23 { | |
color: #005f5f; | |
} | |
.hljs-ansi-background-23 { | |
background-color: #005f5f; | |
} | |
.hljs-ansi-foreground-24 { | |
color: #005f87; | |
} | |
.hljs-ansi-background-24 { | |
background-color: #005f87; | |
} | |
.hljs-ansi-foreground-25 { | |
color: #005faf; | |
} | |
.hljs-ansi-background-25 { | |
background-color: #005faf; | |
} | |
.hljs-ansi-foreground-26 { | |
color: #005fd7; | |
} | |
.hljs-ansi-background-26 { | |
background-color: #005fd7; | |
} | |
.hljs-ansi-foreground-27 { | |
color: #005fff; | |
} | |
.hljs-ansi-background-27 { | |
background-color: #005fff; | |
} | |
.hljs-ansi-foreground-28 { | |
color: #008700; | |
} | |
.hljs-ansi-background-28 { | |
background-color: #008700; | |
} | |
.hljs-ansi-foreground-29 { | |
color: #00875f; | |
} | |
.hljs-ansi-background-29 { | |
background-color: #00875f; | |
} | |
.hljs-ansi-foreground-30 { | |
color: #008787; | |
} | |
.hljs-ansi-background-30 { | |
background-color: #008787; | |
} | |
.hljs-ansi-foreground-31 { | |
color: #0087af; | |
} | |
.hljs-ansi-background-31 { | |
background-color: #0087af; | |
} | |
.hljs-ansi-foreground-32 { | |
color: #0087d7; | |
} | |
.hljs-ansi-background-32 { | |
background-color: #0087d7; | |
} | |
.hljs-ansi-foreground-33 { | |
color: #0087ff; | |
} | |
.hljs-ansi-background-33 { | |
background-color: #0087ff; | |
} | |
.hljs-ansi-foreground-34 { | |
color: #00af00; | |
} | |
.hljs-ansi-background-34 { | |
background-color: #00af00; | |
} | |
.hljs-ansi-foreground-35 { | |
color: #00af5f; | |
} | |
.hljs-ansi-background-35 { | |
background-color: #00af5f; | |
} | |
.hljs-ansi-foreground-36 { | |
color: #00af87; | |
} | |
.hljs-ansi-background-36 { | |
background-color: #00af87; | |
} | |
.hljs-ansi-foreground-37 { | |
color: #00afaf; | |
} | |
.hljs-ansi-background-37 { | |
background-color: #00afaf; | |
} | |
.hljs-ansi-foreground-38 { | |
color: #00afd7; | |
} | |
.hljs-ansi-background-38 { | |
background-color: #00afd7; | |
} | |
.hljs-ansi-foreground-39 { | |
color: #00afff; | |
} | |
.hljs-ansi-background-39 { | |
background-color: #00afff; | |
} | |
.hljs-ansi-foreground-40 { | |
color: #00d700; | |
} | |
.hljs-ansi-background-40 { | |
background-color: #00d700; | |
} | |
.hljs-ansi-foreground-41 { | |
color: #00d75f; | |
} | |
.hljs-ansi-background-41 { | |
background-color: #00d75f; | |
} | |
.hljs-ansi-foreground-42 { | |
color: #00d787; | |
} | |
.hljs-ansi-background-42 { | |
background-color: #00d787; | |
} | |
.hljs-ansi-foreground-43 { | |
color: #00d7af; | |
} | |
.hljs-ansi-background-43 { | |
background-color: #00d7af; | |
} | |
.hljs-ansi-foreground-44 { | |
color: #00d7d7; | |
} | |
.hljs-ansi-background-44 { | |
background-color: #00d7d7; | |
} | |
.hljs-ansi-foreground-45 { | |
color: #00d7ff; | |
} | |
.hljs-ansi-background-45 { | |
background-color: #00d7ff; | |
} | |
.hljs-ansi-foreground-46 { | |
color: #00ff00; | |
} | |
.hljs-ansi-background-46 { | |
background-color: #00ff00; | |
} | |
.hljs-ansi-foreground-47 { | |
color: #00ff5f; | |
} | |
.hljs-ansi-background-47 { | |
background-color: #00ff5f; | |
} | |
.hljs-ansi-foreground-48 { | |
color: #00ff87; | |
} | |
.hljs-ansi-background-48 { | |
background-color: #00ff87; | |
} | |
.hljs-ansi-foreground-49 { | |
color: #00ffaf; | |
} | |
.hljs-ansi-background-49 { | |
background-color: #00ffaf; | |
} | |
.hljs-ansi-foreground-50 { | |
color: #00ffd7; | |
} | |
.hljs-ansi-background-50 { | |
background-color: #00ffd7; | |
} | |
.hljs-ansi-foreground-51 { | |
color: #00ffff; | |
} | |
.hljs-ansi-background-51 { | |
background-color: #00ffff; | |
} | |
.hljs-ansi-foreground-52 { | |
color: #5f0000; | |
} | |
.hljs-ansi-background-52 { | |
background-color: #5f0000; | |
} | |
.hljs-ansi-foreground-53 { | |
color: #5f005f; | |
} | |
.hljs-ansi-background-53 { | |
background-color: #5f005f; | |
} | |
.hljs-ansi-foreground-54 { | |
color: #5f0087; | |
} | |
.hljs-ansi-background-54 { | |
background-color: #5f0087; | |
} | |
.hljs-ansi-foreground-55 { | |
color: #5f00af; | |
} | |
.hljs-ansi-background-55 { | |
background-color: #5f00af; | |
} | |
.hljs-ansi-foreground-56 { | |
color: #5f00d7; | |
} | |
.hljs-ansi-background-56 { | |
background-color: #5f00d7; | |
} | |
.hljs-ansi-foreground-57 { | |
color: #5f00ff; | |
} | |
.hljs-ansi-background-57 { | |
background-color: #5f00ff; | |
} | |
.hljs-ansi-foreground-58 { | |
color: #5f5f00; | |
} | |
.hljs-ansi-background-58 { | |
background-color: #5f5f00; | |
} | |
.hljs-ansi-foreground-59 { | |
color: #5f5f5f; | |
} | |
.hljs-ansi-background-59 { | |
background-color: #5f5f5f; | |
} | |
.hljs-ansi-foreground-60 { | |
color: #5f5f87; | |
} | |
.hljs-ansi-background-60 { | |
background-color: #5f5f87; | |
} | |
.hljs-ansi-foreground-61 { | |
color: #5f5faf; | |
} | |
.hljs-ansi-background-61 { | |
background-color: #5f5faf; | |
} | |
.hljs-ansi-foreground-62 { | |
color: #5f5fd7; | |
} | |
.hljs-ansi-background-62 { | |
background-color: #5f5fd7; | |
} | |
.hljs-ansi-foreground-63 { | |
color: #5f5fff; | |
} | |
.hljs-ansi-background-63 { | |
background-color: #5f5fff; | |
} | |
.hljs-ansi-foreground-64 { | |
color: #5f8700; | |
} | |
.hljs-ansi-background-64 { | |
background-color: #5f8700; | |
} | |
.hljs-ansi-foreground-65 { | |
color: #5f875f; | |
} | |
.hljs-ansi-background-65 { | |
background-color: #5f875f; | |
} | |
.hljs-ansi-foreground-66 { | |
color: #5f8787; | |
} | |
.hljs-ansi-background-66 { | |
background-color: #5f8787; | |
} | |
.hljs-ansi-foreground-67 { | |
color: #5f87af; | |
} | |
.hljs-ansi-background-67 { | |
background-color: #5f87af; | |
} | |
.hljs-ansi-foreground-68 { | |
color: #5f87d7; | |
} | |
.hljs-ansi-background-68 { | |
background-color: #5f87d7; | |
} | |
.hljs-ansi-foreground-69 { | |
color: #5f87ff; | |
} | |
.hljs-ansi-background-69 { | |
background-color: #5f87ff; | |
} | |
.hljs-ansi-foreground-70 { | |
color: #5faf00; | |
} | |
.hljs-ansi-background-70 { | |
background-color: #5faf00; | |
} | |
.hljs-ansi-foreground-71 { | |
color: #5faf5f; | |
} | |
.hljs-ansi-background-71 { | |
background-color: #5faf5f; | |
} | |
.hljs-ansi-foreground-72 { | |
color: #5faf87; | |
} | |
.hljs-ansi-background-72 { | |
background-color: #5faf87; | |
} | |
.hljs-ansi-foreground-73 { | |
color: #5fafaf; | |
} | |
.hljs-ansi-background-73 { | |
background-color: #5fafaf; | |
} | |
.hljs-ansi-foreground-74 { | |
color: #5fafd7; | |
} | |
.hljs-ansi-background-74 { | |
background-color: #5fafd7; | |
} | |
.hljs-ansi-foreground-75 { | |
color: #5fafff; | |
} | |
.hljs-ansi-background-75 { | |
background-color: #5fafff; | |
} | |
.hljs-ansi-foreground-76 { | |
color: #5fd700; | |
} | |
.hljs-ansi-background-76 { | |
background-color: #5fd700; | |
} | |
.hljs-ansi-foreground-77 { | |
color: #5fd75f; | |
} | |
.hljs-ansi-background-77 { | |
background-color: #5fd75f; | |
} | |
.hljs-ansi-foreground-78 { | |
color: #5fd787; | |
} | |
.hljs-ansi-background-78 { | |
background-color: #5fd787; | |
} | |
.hljs-ansi-foreground-79 { | |
color: #5fd7af; | |
} | |
.hljs-ansi-background-79 { | |
background-color: #5fd7af; | |
} | |
.hljs-ansi-foreground-80 { | |
color: #5fd7d7; | |
} | |
.hljs-ansi-background-80 { | |
background-color: #5fd7d7; | |
} | |
.hljs-ansi-foreground-81 { | |
color: #5fd7ff; | |
} | |
.hljs-ansi-background-81 { | |
background-color: #5fd7ff; | |
} | |
.hljs-ansi-foreground-82 { | |
color: #5fff00; | |
} | |
.hljs-ansi-background-82 { | |
background-color: #5fff00; | |
} | |
.hljs-ansi-foreground-83 { | |
color: #5fff5f; | |
} | |
.hljs-ansi-background-83 { | |
background-color: #5fff5f; | |
} | |
.hljs-ansi-foreground-84 { | |
color: #5fff87; | |
} | |
.hljs-ansi-background-84 { | |
background-color: #5fff87; | |
} | |
.hljs-ansi-foreground-85 { | |
color: #5fffaf; | |
} | |
.hljs-ansi-background-85 { | |
background-color: #5fffaf; | |
} | |
.hljs-ansi-foreground-86 { | |
color: #5fffd7; | |
} | |
.hljs-ansi-background-86 { | |
background-color: #5fffd7; | |
} | |
.hljs-ansi-foreground-87 { | |
color: #5fffff; | |
} | |
.hljs-ansi-background-87 { | |
background-color: #5fffff; | |
} | |
.hljs-ansi-foreground-88 { | |
color: #870000; | |
} | |
.hljs-ansi-background-88 { | |
background-color: #870000; | |
} | |
.hljs-ansi-foreground-89 { | |
color: #87005f; | |
} | |
.hljs-ansi-background-89 { | |
background-color: #87005f; | |
} | |
.hljs-ansi-foreground-90 { | |
color: #870087; | |
} | |
.hljs-ansi-background-90 { | |
background-color: #870087; | |
} | |
.hljs-ansi-foreground-91 { | |
color: #8700af; | |
} | |
.hljs-ansi-background-91 { | |
background-color: #8700af; | |
} | |
.hljs-ansi-foreground-92 { | |
color: #8700d7; | |
} | |
.hljs-ansi-background-92 { | |
background-color: #8700d7; | |
} | |
.hljs-ansi-foreground-93 { | |
color: #8700ff; | |
} | |
.hljs-ansi-background-93 { | |
background-color: #8700ff; | |
} | |
.hljs-ansi-foreground-94 { | |
color: #875f00; | |
} | |
.hljs-ansi-background-94 { | |
background-color: #875f00; | |
} | |
.hljs-ansi-foreground-95 { | |
color: #875f5f; | |
} | |
.hljs-ansi-background-95 { | |
background-color: #875f5f; | |
} | |
.hljs-ansi-foreground-96 { | |
color: #875f87; | |
} | |
.hljs-ansi-background-96 { | |
background-color: #875f87; | |
} | |
.hljs-ansi-foreground-97 { | |
color: #875faf; | |
} | |
.hljs-ansi-background-97 { | |
background-color: #875faf; | |
} | |
.hljs-ansi-foreground-98 { | |
color: #875fd7; | |
} | |
.hljs-ansi-background-98 { | |
background-color: #875fd7; | |
} | |
.hljs-ansi-foreground-99 { | |
color: #875fff; | |
} | |
.hljs-ansi-background-99 { | |
background-color: #875fff; | |
} | |
.hljs-ansi-foreground-100 { | |
color: #878700; | |
} | |
.hljs-ansi-background-100 { | |
background-color: #878700; | |
} | |
.hljs-ansi-foreground-101 { | |
color: #87875f; | |
} | |
.hljs-ansi-background-101 { | |
background-color: #87875f; | |
} | |
.hljs-ansi-foreground-102 { | |
color: #878787; | |
} | |
.hljs-ansi-background-102 { | |
background-color: #878787; | |
} | |
.hljs-ansi-foreground-103 { | |
color: #8787af; | |
} | |
.hljs-ansi-background-103 { | |
background-color: #8787af; | |
} | |
.hljs-ansi-foreground-104 { | |
color: #8787d7; | |
} | |
.hljs-ansi-background-104 { | |
background-color: #8787d7; | |
} | |
.hljs-ansi-foreground-105 { | |
color: #8787ff; | |
} | |
.hljs-ansi-background-105 { | |
background-color: #8787ff; | |
} | |
.hljs-ansi-foreground-106 { | |
color: #87af00; | |
} | |
.hljs-ansi-background-106 { | |
background-color: #87af00; | |
} | |
.hljs-ansi-foreground-107 { | |
color: #87af5f; | |
} | |
.hljs-ansi-background-107 { | |
background-color: #87af5f; | |
} | |
.hljs-ansi-foreground-108 { | |
color: #87af87; | |
} | |
.hljs-ansi-background-108 { | |
background-color: #87af87; | |
} | |
.hljs-ansi-foreground-109 { | |
color: #87afaf; | |
} | |
.hljs-ansi-background-109 { | |
background-color: #87afaf; | |
} | |
.hljs-ansi-foreground-110 { | |
color: #87afd7; | |
} | |
.hljs-ansi-background-110 { | |
background-color: #87afd7; | |
} | |
.hljs-ansi-foreground-111 { | |
color: #87afff; | |
} | |
.hljs-ansi-background-111 { | |
background-color: #87afff; | |
} | |
.hljs-ansi-foreground-112 { | |
color: #87d700; | |
} | |
.hljs-ansi-background-112 { | |
background-color: #87d700; | |
} | |
.hljs-ansi-foreground-113 { | |
color: #87d75f; | |
} | |
.hljs-ansi-background-113 { | |
background-color: #87d75f; | |
} | |
.hljs-ansi-foreground-114 { | |
color: #87d787; | |
} | |
.hljs-ansi-background-114 { | |
background-color: #87d787; | |
} | |
.hljs-ansi-foreground-115 { | |
color: #87d7af; | |
} | |
.hljs-ansi-background-115 { | |
background-color: #87d7af; | |
} | |
.hljs-ansi-foreground-116 { | |
color: #87d7d7; | |
} | |
.hljs-ansi-background-116 { | |
background-color: #87d7d7; | |
} | |
.hljs-ansi-foreground-117 { | |
color: #87d7ff; | |
} | |
.hljs-ansi-background-117 { | |
background-color: #87d7ff; | |
} | |
.hljs-ansi-foreground-118 { | |
color: #87ff00; | |
} | |
.hljs-ansi-background-118 { | |
background-color: #87ff00; | |
} | |
.hljs-ansi-foreground-119 { | |
color: #87ff5f; | |
} | |
.hljs-ansi-background-119 { | |
background-color: #87ff5f; | |
} | |
.hljs-ansi-foreground-120 { | |
color: #87ff87; | |
} | |
.hljs-ansi-background-120 { | |
background-color: #87ff87; | |
} | |
.hljs-ansi-foreground-121 { | |
color: #87ffaf; | |
} | |
.hljs-ansi-background-121 { | |
background-color: #87ffaf; | |
} | |
.hljs-ansi-foreground-122 { | |
color: #87ffd7; | |
} | |
.hljs-ansi-background-122 { | |
background-color: #87ffd7; | |
} | |
.hljs-ansi-foreground-123 { | |
color: #87ffff; | |
} | |
.hljs-ansi-background-123 { | |
background-color: #87ffff; | |
} | |
.hljs-ansi-foreground-124 { | |
color: #af0000; | |
} | |
.hljs-ansi-background-124 { | |
background-color: #af0000; | |
} | |
.hljs-ansi-foreground-125 { | |
color: #af005f; | |
} | |
.hljs-ansi-background-125 { | |
background-color: #af005f; | |
} | |
.hljs-ansi-foreground-126 { | |
color: #af0087; | |
} | |
.hljs-ansi-background-126 { | |
background-color: #af0087; | |
} | |
.hljs-ansi-foreground-127 { | |
color: #af00af; | |
} | |
.hljs-ansi-background-127 { | |
background-color: #af00af; | |
} | |
.hljs-ansi-foreground-128 { | |
color: #af00d7; | |
} | |
.hljs-ansi-background-128 { | |
background-color: #af00d7; | |
} | |
.hljs-ansi-foreground-129 { | |
color: #af00ff; | |
} | |
.hljs-ansi-background-129 { | |
background-color: #af00ff; | |
} | |
.hljs-ansi-foreground-130 { | |
color: #af5f00; | |
} | |
.hljs-ansi-background-130 { | |
background-color: #af5f00; | |
} | |
.hljs-ansi-foreground-131 { | |
color: #af5f5f; | |
} | |
.hljs-ansi-background-131 { | |
background-color: #af5f5f; | |
} | |
.hljs-ansi-foreground-132 { | |
color: #af5f87; | |
} | |
.hljs-ansi-background-132 { | |
background-color: #af5f87; | |
} | |
.hljs-ansi-foreground-133 { | |
color: #af5faf; | |
} | |
.hljs-ansi-background-133 { | |
background-color: #af5faf; | |
} | |
.hljs-ansi-foreground-134 { | |
color: #af5fd7; | |
} | |
.hljs-ansi-background-134 { | |
background-color: #af5fd7; | |
} | |
.hljs-ansi-foreground-135 { | |
color: #af5fff; | |
} | |
.hljs-ansi-background-135 { | |
background-color: #af5fff; | |
} | |
.hljs-ansi-foreground-136 { | |
color: #af8700; | |
} | |
.hljs-ansi-background-136 { | |
background-color: #af8700; | |
} | |
.hljs-ansi-foreground-137 { | |
color: #af875f; | |
} | |
.hljs-ansi-background-137 { | |
background-color: #af875f; | |
} | |
.hljs-ansi-foreground-138 { | |
color: #af8787; | |
} | |
.hljs-ansi-background-138 { | |
background-color: #af8787; | |
} | |
.hljs-ansi-foreground-139 { | |
color: #af87af; | |
} | |
.hljs-ansi-background-139 { | |
background-color: #af87af; | |
} | |
.hljs-ansi-foreground-140 { | |
color: #af87d7; | |
} | |
.hljs-ansi-background-140 { | |
background-color: #af87d7; | |
} | |
.hljs-ansi-foreground-141 { | |
color: #af87ff; | |
} | |
.hljs-ansi-background-141 { | |
background-color: #af87ff; | |
} | |
.hljs-ansi-foreground-142 { | |
color: #afaf00; | |
} | |
.hljs-ansi-background-142 { | |
background-color: #afaf00; | |
} | |
.hljs-ansi-foreground-143 { | |
color: #afaf5f; | |
} | |
.hljs-ansi-background-143 { | |
background-color: #afaf5f; | |
} | |
.hljs-ansi-foreground-144 { | |
color: #afaf87; | |
} | |
.hljs-ansi-background-144 { | |
background-color: #afaf87; | |
} | |
.hljs-ansi-foreground-145 { | |
color: #afafaf; | |
} | |
.hljs-ansi-background-145 { | |
background-color: #afafaf; | |
} | |
.hljs-ansi-foreground-146 { | |
color: #afafd7; | |
} | |
.hljs-ansi-background-146 { | |
background-color: #afafd7; | |
} | |
.hljs-ansi-foreground-147 { | |
color: #afafff; | |
} | |
.hljs-ansi-background-147 { | |
background-color: #afafff; | |
} | |
.hljs-ansi-foreground-148 { | |
color: #afd700; | |
} | |
.hljs-ansi-background-148 { | |
background-color: #afd700; | |
} | |
.hljs-ansi-foreground-149 { | |
color: #afd75f; | |
} | |
.hljs-ansi-background-149 { | |
background-color: #afd75f; | |
} | |
.hljs-ansi-foreground-150 { | |
color: #afd787; | |
} | |
.hljs-ansi-background-150 { | |
background-color: #afd787; | |
} | |
.hljs-ansi-foreground-151 { | |
color: #afd7af; | |
} | |
.hljs-ansi-background-151 { | |
background-color: #afd7af; | |
} | |
.hljs-ansi-foreground-152 { | |
color: #afd7d7; | |
} | |
.hljs-ansi-background-152 { | |
background-color: #afd7d7; | |
} | |
.hljs-ansi-foreground-153 { | |
color: #afd7ff; | |
} | |
.hljs-ansi-background-153 { | |
background-color: #afd7ff; | |
} | |
.hljs-ansi-foreground-154 { | |
color: #afff00; | |
} | |
.hljs-ansi-background-154 { | |
background-color: #afff00; | |
} | |
.hljs-ansi-foreground-155 { | |
color: #afff5f; | |
} | |
.hljs-ansi-background-155 { | |
background-color: #afff5f; | |
} | |
.hljs-ansi-foreground-156 { | |
color: #afff87; | |
} | |
.hljs-ansi-background-156 { | |
background-color: #afff87; | |
} | |
.hljs-ansi-foreground-157 { | |
color: #afffaf; | |
} | |
.hljs-ansi-background-157 { | |
background-color: #afffaf; | |
} | |
.hljs-ansi-foreground-158 { | |
color: #afffd7; | |
} | |
.hljs-ansi-background-158 { | |
background-color: #afffd7; | |
} | |
.hljs-ansi-foreground-159 { | |
color: #afffff; | |
} | |
.hljs-ansi-background-159 { | |
background-color: #afffff; | |
} | |
.hljs-ansi-foreground-160 { | |
color: #d70000; | |
} | |
.hljs-ansi-background-160 { | |
background-color: #d70000; | |
} | |
.hljs-ansi-foreground-161 { | |
color: #d7005f; | |
} | |
.hljs-ansi-background-161 { | |
background-color: #d7005f; | |
} | |
.hljs-ansi-foreground-162 { | |
color: #d70087; | |
} | |
.hljs-ansi-background-162 { | |
background-color: #d70087; | |
} | |
.hljs-ansi-foreground-163 { | |
color: #d700af; | |
} | |
.hljs-ansi-background-163 { | |
background-color: #d700af; | |
} | |
.hljs-ansi-foreground-164 { | |
color: #d700d7; | |
} | |
.hljs-ansi-background-164 { | |
background-color: #d700d7; | |
} | |
.hljs-ansi-foreground-165 { | |
color: #d700ff; | |
} | |
.hljs-ansi-background-165 { | |
background-color: #d700ff; | |
} | |
.hljs-ansi-foreground-166 { | |
color: #d75f00; | |
} | |
.hljs-ansi-background-166 { | |
background-color: #d75f00; | |
} | |
.hljs-ansi-foreground-167 { | |
color: #d75f5f; | |
} | |
.hljs-ansi-background-167 { | |
background-color: #d75f5f; | |
} | |
.hljs-ansi-foreground-168 { | |
color: #d75f87; | |
} | |
.hljs-ansi-background-168 { | |
background-color: #d75f87; | |
} | |
.hljs-ansi-foreground-169 { | |
color: #d75faf; | |
} | |
.hljs-ansi-background-169 { | |
background-color: #d75faf; | |
} | |
.hljs-ansi-foreground-170 { | |
color: #d75fd7; | |
} | |
.hljs-ansi-background-170 { | |
background-color: #d75fd7; | |
} | |
.hljs-ansi-foreground-171 { | |
color: #d75fff; | |
} | |
.hljs-ansi-background-171 { | |
background-color: #d75fff; | |
} | |
.hljs-ansi-foreground-172 { | |
color: #d78700; | |
} | |
.hljs-ansi-background-172 { | |
background-color: #d78700; | |
} | |
.hljs-ansi-foreground-173 { | |
color: #d7875f; | |
} | |
.hljs-ansi-background-173 { | |
background-color: #d7875f; | |
} | |
.hljs-ansi-foreground-174 { | |
color: #d78787; | |
} | |
.hljs-ansi-background-174 { | |
background-color: #d78787; | |
} | |
.hljs-ansi-foreground-175 { | |
color: #d787af; | |
} | |
.hljs-ansi-background-175 { | |
background-color: #d787af; | |
} | |
.hljs-ansi-foreground-176 { | |
color: #d787d7; | |
} | |
.hljs-ansi-background-176 { | |
background-color: #d787d7; | |
} | |
.hljs-ansi-foreground-177 { | |
color: #d787ff; | |
} | |
.hljs-ansi-background-177 { | |
background-color: #d787ff; | |
} | |
.hljs-ansi-foreground-178 { | |
color: #dfaf00; | |
} | |
.hljs-ansi-background-178 { | |
background-color: #dfaf00; | |
} | |
.hljs-ansi-foreground-179 { | |
color: #dfaf5f; | |
} | |
.hljs-ansi-background-179 { | |
background-color: #dfaf5f; | |
} | |
.hljs-ansi-foreground-180 { | |
color: #dfaf87; | |
} | |
.hljs-ansi-background-180 { | |
background-color: #dfaf87; | |
} | |
.hljs-ansi-foreground-181 { | |
color: #dfafaf; | |
} | |
.hljs-ansi-background-181 { | |
background-color: #dfafaf; | |
} | |
.hljs-ansi-foreground-182 { | |
color: #dfafdf; | |
} | |
.hljs-ansi-background-182 { | |
background-color: #dfafdf; | |
} | |
.hljs-ansi-foreground-183 { | |
color: #dfafff; | |
} | |
.hljs-ansi-background-183 { | |
background-color: #dfafff; | |
} | |
.hljs-ansi-foreground-184 { | |
color: #dfdf00; | |
} | |
.hljs-ansi-background-184 { | |
background-color: #dfdf00; | |
} | |
.hljs-ansi-foreground-185 { | |
color: #dfdf5f; | |
} | |
.hljs-ansi-background-185 { | |
background-color: #dfdf5f; | |
} | |
.hljs-ansi-foreground-186 { | |
color: #dfdf87; | |
} | |
.hljs-ansi-background-186 { | |
background-color: #dfdf87; | |
} | |
.hljs-ansi-foreground-187 { | |
color: #dfdfaf; | |
} | |
.hljs-ansi-background-187 { | |
background-color: #dfdfaf; | |
} | |
.hljs-ansi-foreground-188 { | |
color: #dfdfdf; | |
} | |
.hljs-ansi-background-188 { | |
background-color: #dfdfdf; | |
} | |
.hljs-ansi-foreground-189 { | |
color: #dfdfff; | |
} | |
.hljs-ansi-background-189 { | |
background-color: #dfdfff; | |
} | |
.hljs-ansi-foreground-190 { | |
color: #dfff00; | |
} | |
.hljs-ansi-background-190 { | |
background-color: #dfff00; | |
} | |
.hljs-ansi-foreground-191 { | |
color: #dfff5f; | |
} | |
.hljs-ansi-background-191 { | |
background-color: #dfff5f; | |
} | |
.hljs-ansi-foreground-192 { | |
color: #dfff87; | |
} | |
.hljs-ansi-background-192 { | |
background-color: #dfff87; | |
} | |
.hljs-ansi-foreground-193 { | |
color: #dfffaf; | |
} | |
.hljs-ansi-background-193 { | |
background-color: #dfffaf; | |
} | |
.hljs-ansi-foreground-194 { | |
color: #dfffdf; | |
} | |
.hljs-ansi-background-194 { | |
background-color: #dfffdf; | |
} | |
.hljs-ansi-foreground-195 { | |
color: #dfffff; | |
} | |
.hljs-ansi-background-195 { | |
background-color: #dfffff; | |
} | |
.hljs-ansi-foreground-196 { | |
color: #ff0000; | |
} | |
.hljs-ansi-background-196 { | |
background-color: #ff0000; | |
} | |
.hljs-ansi-foreground-197 { | |
color: #ff005f; | |
} | |
.hljs-ansi-background-197 { | |
background-color: #ff005f; | |
} | |
.hljs-ansi-foreground-198 { | |
color: #ff0087; | |
} | |
.hljs-ansi-background-198 { | |
background-color: #ff0087; | |
} | |
.hljs-ansi-foreground-199 { | |
color: #ff00af; | |
} | |
.hljs-ansi-background-199 { | |
background-color: #ff00af; | |
} | |
.hljs-ansi-foreground-200 { | |
color: #ff00df; | |
} | |
.hljs-ansi-background-200 { | |
background-color: #ff00df; | |
} | |
.hljs-ansi-foreground-201 { | |
color: #ff00ff; | |
} | |
.hljs-ansi-background-201 { | |
background-color: #ff00ff; | |
} | |
.hljs-ansi-foreground-202 { | |
color: #ff5f00; | |
} | |
.hljs-ansi-background-202 { | |
background-color: #ff5f00; | |
} | |
.hljs-ansi-foreground-203 { | |
color: #ff5f5f; | |
} | |
.hljs-ansi-background-203 { | |
background-color: #ff5f5f; | |
} | |
.hljs-ansi-foreground-204 { | |
color: #ff5f87; | |
} | |
.hljs-ansi-background-204 { | |
background-color: #ff5f87; | |
} | |
.hljs-ansi-foreground-205 { | |
color: #ff5faf; | |
} | |
.hljs-ansi-background-205 { | |
background-color: #ff5faf; | |
} | |
.hljs-ansi-foreground-206 { | |
color: #ff5fdf; | |
} | |
.hljs-ansi-background-206 { | |
background-color: #ff5fdf; | |
} | |
.hljs-ansi-foreground-207 { | |
color: #ff5fff; | |
} | |
.hljs-ansi-background-207 { | |
background-color: #ff5fff; | |
} | |
.hljs-ansi-foreground-208 { | |
color: #ff8700; | |
} | |
.hljs-ansi-background-208 { | |
background-color: #ff8700; | |
} | |
.hljs-ansi-foreground-209 { | |
color: #ff875f; | |
} | |
.hljs-ansi-background-209 { | |
background-color: #ff875f; | |
} | |
.hljs-ansi-foreground-210 { | |
color: #ff8787; | |
} | |
.hljs-ansi-background-210 { | |
background-color: #ff8787; | |
} | |
.hljs-ansi-foreground-211 { | |
color: #ff87af; | |
} | |
.hljs-ansi-background-211 { | |
background-color: #ff87af; | |
} | |
.hljs-ansi-foreground-212 { | |
color: #ff87df; | |
} | |
.hljs-ansi-background-212 { | |
background-color: #ff87df; | |
} | |
.hljs-ansi-foreground-213 { | |
color: #ff87ff; | |
} | |
.hljs-ansi-background-213 { | |
background-color: #ff87ff; | |
} | |
.hljs-ansi-foreground-214 { | |
color: #ffaf00; | |
} | |
.hljs-ansi-background-214 { | |
background-color: #ffaf00; | |
} | |
.hljs-ansi-foreground-215 { | |
color: #ffaf5f; | |
} | |
.hljs-ansi-background-215 { | |
background-color: #ffaf5f; | |
} | |
.hljs-ansi-foreground-216 { | |
color: #ffaf87; | |
} | |
.hljs-ansi-background-216 { | |
background-color: #ffaf87; | |
} | |
.hljs-ansi-foreground-217 { | |
color: #ffafaf; | |
} | |
.hljs-ansi-background-217 { | |
background-color: #ffafaf; | |
} | |
.hljs-ansi-foreground-218 { | |
color: #ffafdf; | |
} | |
.hljs-ansi-background-218 { | |
background-color: #ffafdf; | |
} | |
.hljs-ansi-foreground-219 { | |
color: #ffafff; | |
} | |
.hljs-ansi-background-219 { | |
background-color: #ffafff; | |
} | |
.hljs-ansi-foreground-220 { | |
color: #ffdf00; | |
} | |
.hljs-ansi-background-220 { | |
background-color: #ffdf00; | |
} | |
.hljs-ansi-foreground-221 { | |
color: #ffdf5f; | |
} | |
.hljs-ansi-background-221 { | |
background-color: #ffdf5f; | |
} | |
.hljs-ansi-foreground-222 { | |
color: #ffdf87; | |
} | |
.hljs-ansi-background-222 { | |
background-color: #ffdf87; | |
} | |
.hljs-ansi-foreground-223 { | |
color: #ffdfaf; | |
} | |
.hljs-ansi-background-223 { | |
background-color: #ffdfaf; | |
} | |
.hljs-ansi-foreground-224 { | |
color: #ffdfdf; | |
} | |
.hljs-ansi-background-224 { | |
background-color: #ffdfdf; | |
} | |
.hljs-ansi-foreground-225 { | |
color: #ffdfff; | |
} | |
.hljs-ansi-background-225 { | |
background-color: #ffdfff; | |
} | |
.hljs-ansi-foreground-226 { | |
color: #ffff00; | |
} | |
.hljs-ansi-background-226 { | |
background-color: #ffff00; | |
} | |
.hljs-ansi-foreground-227 { | |
color: #ffff5f; | |
} | |
.hljs-ansi-background-227 { | |
background-color: #ffff5f; | |
} | |
.hljs-ansi-foreground-228 { | |
color: #ffff87; | |
} | |
.hljs-ansi-background-228 { | |
background-color: #ffff87; | |
} | |
.hljs-ansi-foreground-229 { | |
color: #ffffaf; | |
} | |
.hljs-ansi-background-229 { | |
background-color: #ffffaf; | |
} | |
.hljs-ansi-foreground-230 { | |
color: #ffffdf; | |
} | |
.hljs-ansi-background-230 { | |
background-color: #ffffdf; | |
} | |
.hljs-ansi-foreground-231 { | |
color: #ffffff; | |
} | |
.hljs-ansi-background-231 { | |
background-color: #ffffff; | |
} | |
.hljs-ansi-foreground-232 { | |
color: #080808; | |
} | |
.hljs-ansi-background-232 { | |
background-color: #080808; | |
} | |
.hljs-ansi-foreground-233 { | |
color: #121212; | |
} | |
.hljs-ansi-background-233 { | |
background-color: #121212; | |
} | |
.hljs-ansi-foreground-234 { | |
color: #1c1c1c; | |
} | |
.hljs-ansi-background-234 { | |
background-color: #1c1c1c; | |
} | |
.hljs-ansi-foreground-235 { | |
color: #262626; | |
} | |
.hljs-ansi-background-235 { | |
background-color: #262626; | |
} | |
.hljs-ansi-foreground-236 { | |
color: #303030; | |
} | |
.hljs-ansi-background-236 { | |
background-color: #303030; | |
} | |
.hljs-ansi-foreground-237 { | |
color: #3a3a3a; | |
} | |
.hljs-ansi-background-237 { | |
background-color: #3a3a3a; | |
} | |
.hljs-ansi-foreground-238 { | |
color: #444444; | |
} | |
.hljs-ansi-background-238 { | |
background-color: #444444; | |
} | |
.hljs-ansi-foreground-239 { | |
color: #4e4e4e; | |
} | |
.hljs-ansi-background-239 { | |
background-color: #4e4e4e; | |
} | |
.hljs-ansi-foreground-240 { | |
color: #585858; | |
} | |
.hljs-ansi-background-240 { | |
background-color: #585858; | |
} | |
.hljs-ansi-foreground-241 { | |
color: #626262; | |
} | |
.hljs-ansi-background-241 { | |
background-color: #626262; | |
} | |
.hljs-ansi-foreground-242 { | |
color: #6c6c6c; | |
} | |
.hljs-ansi-background-242 { | |
background-color: #6c6c6c; | |
} | |
.hljs-ansi-foreground-243 { | |
color: #767676; | |
} | |
.hljs-ansi-background-243 { | |
background-color: #767676; | |
} | |
.hljs-ansi-foreground-244 { | |
color: #808080; | |
} | |
.hljs-ansi-background-244 { | |
background-color: #808080; | |
} | |
.hljs-ansi-foreground-245 { | |
color: #8a8a8a; | |
} | |
.hljs-ansi-background-245 { | |
background-color: #8a8a8a; | |
} | |
.hljs-ansi-foreground-246 { | |
color: #949494; | |
} | |
.hljs-ansi-background-246 { | |
background-color: #949494; | |
} | |
.hljs-ansi-foreground-247 { | |
color: #9e9e9e; | |
} | |
.hljs-ansi-background-247 { | |
background-color: #9e9e9e; | |
} | |
.hljs-ansi-foreground-248 { | |
color: #a8a8a8; | |
} | |
.hljs-ansi-background-248 { | |
background-color: #a8a8a8; | |
} | |
.hljs-ansi-foreground-249 { | |
color: #b2b2b2; | |
} | |
.hljs-ansi-background-249 { | |
background-color: #b2b2b2; | |
} | |
.hljs-ansi-foreground-250 { | |
color: #bcbcbc; | |
} | |
.hljs-ansi-background-250 { | |
background-color: #bcbcbc; | |
} | |
.hljs-ansi-foreground-251 { | |
color: #c6c6c6; | |
} | |
.hljs-ansi-background-251 { | |
background-color: #c6c6c6; | |
} | |
.hljs-ansi-foreground-252 { | |
color: #d0d0d0; | |
} | |
.hljs-ansi-background-252 { | |
background-color: #d0d0d0; | |
} | |
.hljs-ansi-foreground-253 { | |
color: #dadada; | |
} | |
.hljs-ansi-background-253 { | |
background-color: #dadada; | |
} | |
.hljs-ansi-foreground-254 { | |
color: #e4e4e4; | |
} | |
.hljs-ansi-background-254 { | |
background-color: #e4e4e4; | |
} | |
.hljs-ansi-foreground-255 { | |
color: #eeeeee; | |
} | |
.hljs-ansi-background-255 { | |
background-color: #eeeeee; | |
} |
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
const ANSI_STYLES = { | |
1: "bold", | |
2: "dim", | |
4: "underline", | |
5: "blink", | |
8: "hidden", | |
9: "strike", | |
}; | |
const ANSI_FOREGROUND = { | |
30: "black", | |
31: "red", | |
32: "green", | |
33: "yellow", | |
34: "blue", | |
35: "magenta", | |
36: "cyan", | |
37: "white", | |
90: "black-bright", | |
91: "red-bright", | |
92: "green-bright", | |
93: "yellow-bright", | |
94: "blue-bright", | |
95: "magenta-bright", | |
96: "cyan-bright", | |
97: "white-bright", | |
}; | |
const ANSI_BACKGROUND = { | |
40: "black", | |
41: "red", | |
42: "green", | |
43: "yellow", | |
44: "blue", | |
45: "magenta", | |
46: "cyan", | |
47: "white", | |
100: "black-bright", | |
101: "red-bright", | |
102: "green-bright", | |
103: "yellow-bright", | |
104: "blue-bright", | |
105: "magenta-bright", | |
106: "cyan-bright", | |
107: "white-bright", | |
}; | |
const ANSI_INDEXES = { | |
0: "black", | |
1: "red", | |
2: "green", | |
3: "yellow", | |
4: "blue", | |
5: "magenta", | |
6: "cyan", | |
7: "white", | |
8: "black-bright", | |
9: "red-bright", | |
10: "green-bright", | |
11: "yellow-bright", | |
12: "blue-bright", | |
13: "magenta-bright", | |
14: "cyan-bright", | |
15: "white-bright", | |
}; | |
const REGEX_ANSI_CONTROL = /\x1B\[(\d+(?:[:;]\d+)*)m/; | |
const REGEX_ANSI_CONTROL_LOOKAHEAD = new RegExp( | |
`(?=${REGEX_ANSI_CONTROL.source})` | |
); | |
const REGEX_ANSI_CONTROL_SPLIT = /\x1B\[\d+(?:[:;]\d+)*m/; | |
const REGEX_ANSI_CONTROL_SPLIT_LOOKAHEAD = new RegExp( | |
`(?=${REGEX_ANSI_CONTROL_SPLIT.source})` | |
); | |
const REGEX_ANSI_CONTROL_SPLIT_GROUP = new RegExp( | |
`(${REGEX_ANSI_CONTROL_SPLIT.source})` | |
); | |
let lastCategory; | |
function openNode(emitter, nodes, key, scope) { | |
emitter.openNode(scope); | |
nodes[key] = emitter.top; | |
lastCategory = key; | |
} | |
function closeNode(emitter, nodes, key) { | |
const node = nodes[key]; | |
if (node == null) return; | |
emitter.stack.splice(emitter.stack.indexOf(node), 1); | |
nodes[key] = null; | |
} | |
export default function hljsAnsi() { | |
return { | |
contains: [ | |
{ | |
begin: REGEX_ANSI_CONTROL_LOOKAHEAD, | |
contains: [ | |
{ | |
className: "ansi-control-sequence", | |
begin: REGEX_ANSI_CONTROL, | |
starts: { | |
end: REGEX_ANSI_CONTROL_LOOKAHEAD, | |
endsParent: true, | |
}, | |
}, | |
], | |
}, | |
], | |
__emitTokens: (code, emitter) => { | |
const parts = code | |
.split(REGEX_ANSI_CONTROL_SPLIT_LOOKAHEAD) | |
.flatMap((part) => { | |
const split = part.split(REGEX_ANSI_CONTROL_SPLIT_GROUP); | |
const top = split.shift(); | |
if (top != "") split.splice(0, 0, top); | |
return split; | |
}); | |
const openNodes = { | |
foreground: null, | |
background: null, | |
bold: null, | |
dim: null, | |
underline: null, | |
blink: null, | |
hidden: null, | |
strike: null, | |
}; | |
for (const part of parts) { | |
const match = part.match(REGEX_ANSI_CONTROL); | |
if (match) { | |
const [orig, codes] = match; | |
const codeParts = codes.split(";"); | |
for (let i = 0; i < codeParts.length; i++) { | |
const code = codeParts[i]; | |
const prevCode = codeParts[i - 1]; | |
const prevPrevCode = codeParts[i - 2]; | |
const nextCode = codeParts[i + 1]; | |
const nextNextCode = codeParts[i + 2]; | |
const namedForeground = ANSI_FOREGROUND[code]; | |
const namedBackground = ANSI_BACKGROUND[code]; | |
const style = ANSI_STYLES[code]; | |
if ( | |
(code == "5" && (prevCode == "38" || prevCode == "48")) || | |
(prevCode == "5" && | |
(prevPrevCode == "38" || prevPrevCode == "48")) | |
) { | |
continue; | |
} else if (code == "0") { | |
for (const category of Object.keys(openNodes)) { | |
closeNode(emitter, openNodes, category); | |
} | |
} else if (code == "38" || code == "48") { | |
if (nextCode == "5") { | |
const category = code == "48" ? "background" : "foreground"; | |
let scope = `ansi-${category}-`; | |
const namedIndex = ANSI_INDEXES[nextNextCode]; | |
if (namedIndex) { | |
scope += namedIndex; | |
} else { | |
scope += nextNextCode; | |
} | |
let fgScope; | |
if ( | |
category == "background" && | |
openNodes.foreground != null && | |
lastCategory == "foreground" | |
) { | |
fgScope = openNodes.foreground.scope; | |
closeNode(emitter, openNodes, "foreground"); | |
} | |
closeNode(emitter, openNodes, category); | |
if (fgScope) | |
openNode(emitter, openNodes, "foreground", fgScope); | |
openNode(emitter, openNodes, category, scope); | |
} | |
} else if (namedForeground) { | |
closeNode(emitter, openNodes, "foreground"); | |
openNode( | |
emitter, | |
openNodes, | |
"foreground", | |
"ansi-foreground-" + namedForeground | |
); | |
} else if (code == "39" && openNodes.foreground != null) { | |
closeNode(emitter, openNodes, "foreground"); | |
} else if (namedBackground) { | |
closeNode(emitter, openNodes, "background"); | |
openNode( | |
emitter, | |
openNodes, | |
"background", | |
"ansi-background-" + namedBackground | |
); | |
} else if (code == "49" && openNodes.background != null) { | |
let fgScope; | |
if ( | |
openNodes.foreground != null && | |
lastCategory == "foreground" | |
) { | |
fgScope = openNodes.foreground.scope; | |
closeNode(emitter, openNodes, "foreground"); | |
} | |
closeNode(emitter, openNodes, "background"); | |
if (fgScope) | |
openNode(emitter, openNodes, "foreground", fgScope); | |
} else if (style) { | |
openNode(emitter, openNodes, style, "ansi-style-" + style); | |
} else if (code.length == 2 && code.startsWith("2")) { | |
const closeStyle = ANSI_STYLES[code.substring(1)]; | |
closeNode(emitter, openNodes, closeStyle); | |
} | |
} | |
emitter.startScope("ansi-control-sequence"); | |
emitter.addText(orig); | |
emitter.endScope(); | |
} else { | |
emitter.addText(part); | |
} | |
} | |
emitter.finalize(); | |
}, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment