basant307/AI_Governance_Project
048
1const MODES = (hljs) => {2 return {3 IMPORTANT: {4 scope: 'meta',5 begin: '!important'6 },7 BLOCK_COMMENT: hljs.C_BLOCK_COMMENT_MODE,8 HEXCOLOR: {9 scope: 'number',10 begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/11 },12 FUNCTION_DISPATCH: {13 className: "built_in",14 begin: /[\w-]+(?=\()/15 },16 ATTRIBUTE_SELECTOR_MODE: {17 scope: 'selector-attr',18 begin: /\[/,19 end: /\]/,20 illegal: '$',21 contains: [22 hljs.APOS_STRING_MODE,23 hljs.QUOTE_STRING_MODE24 ]25 },26 CSS_NUMBER_MODE: {27 scope: 'number',28 begin: hljs.NUMBER_RE + '(' +29 '%|em|ex|ch|rem' +30 '|vw|vh|vmin|vmax' +31 '|cm|mm|in|pt|pc|px' +32 '|deg|grad|rad|turn' +33 '|s|ms' +34 '|Hz|kHz' +35 '|dpi|dpcm|dppx' +36 ')?',37 relevance: 038 },39 CSS_VARIABLE: {40 className: "attr",41 begin: /--[A-Za-z_][A-Za-z0-9_-]*/42 }43 };44};45 46const HTML_TAGS = [47 'a',48 'abbr',49 'address',50 'article',51 'aside',52 'audio',53 'b',54 'blockquote',55 'body',56 'button',57 'canvas',58 'caption',59 'cite',60 'code',61 'dd',62 'del',63 'details',64 'dfn',65 'div',66 'dl',67 'dt',68 'em',69 'fieldset',70 'figcaption',71 'figure',72 'footer',73 'form',74 'h1',75 'h2',76 'h3',77 'h4',78 'h5',79 'h6',80 'header',81 'hgroup',82 'html',83 'i',84 'iframe',85 'img',86 'input',87 'ins',88 'kbd',89 'label',90 'legend',91 'li',92 'main',93 'mark',94 'menu',95 'nav',96 'object',97 'ol',98 'optgroup',99 'option',100 'p',101 'picture',102 'q',103 'quote',104 'samp',105 'section',106 'select',107 'source',108 'span',109 'strong',110 'summary',111 'sup',112 'table',113 'tbody',114 'td',115 'textarea',116 'tfoot',117 'th',118 'thead',119 'time',120 'tr',121 'ul',122 'var',123 'video'124];125 126const SVG_TAGS = [127 'defs',128 'g',129 'marker',130 'mask',131 'pattern',132 'svg',133 'switch',134 'symbol',135 'feBlend',136 'feColorMatrix',137 'feComponentTransfer',138 'feComposite',139 'feConvolveMatrix',140 'feDiffuseLighting',141 'feDisplacementMap',142 'feFlood',143 'feGaussianBlur',144 'feImage',145 'feMerge',146 'feMorphology',147 'feOffset',148 'feSpecularLighting',149 'feTile',150 'feTurbulence',151 'linearGradient',152 'radialGradient',153 'stop',154 'circle',155 'ellipse',156 'image',157 'line',158 'path',159 'polygon',160 'polyline',161 'rect',162 'text',163 'use',164 'textPath',165 'tspan',166 'foreignObject',167 'clipPath'168];169 170const TAGS = [171 ...HTML_TAGS,172 ...SVG_TAGS,173];174 175// Sorting, then reversing makes sure longer attributes/elements like176// `font-weight` are matched fully instead of getting false positives on say `font`177 178const MEDIA_FEATURES = [179 'any-hover',180 'any-pointer',181 'aspect-ratio',182 'color',183 'color-gamut',184 'color-index',185 'device-aspect-ratio',186 'device-height',187 'device-width',188 'display-mode',189 'forced-colors',190 'grid',191 'height',192 'hover',193 'inverted-colors',194 'monochrome',195 'orientation',196 'overflow-block',197 'overflow-inline',198 'pointer',199 'prefers-color-scheme',200 'prefers-contrast',201 'prefers-reduced-motion',202 'prefers-reduced-transparency',203 'resolution',204 'scan',205 'scripting',206 'update',207 'width',208 // TODO: find a better solution?209 'min-width',210 'max-width',211 'min-height',212 'max-height'213].sort().reverse();214 215// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes216const PSEUDO_CLASSES = [217 'active',218 'any-link',219 'blank',220 'checked',221 'current',222 'default',223 'defined',224 'dir', // dir()225 'disabled',226 'drop',227 'empty',228 'enabled',229 'first',230 'first-child',231 'first-of-type',232 'fullscreen',233 'future',234 'focus',235 'focus-visible',236 'focus-within',237 'has', // has()238 'host', // host or host()239 'host-context', // host-context()240 'hover',241 'indeterminate',242 'in-range',243 'invalid',244 'is', // is()245 'lang', // lang()246 'last-child',247 'last-of-type',248 'left',249 'link',250 'local-link',251 'not', // not()252 'nth-child', // nth-child()253 'nth-col', // nth-col()254 'nth-last-child', // nth-last-child()255 'nth-last-col', // nth-last-col()256 'nth-last-of-type', //nth-last-of-type()257 'nth-of-type', //nth-of-type()258 'only-child',259 'only-of-type',260 'optional',261 'out-of-range',262 'past',263 'placeholder-shown',264 'read-only',265 'read-write',266 'required',267 'right',268 'root',269 'scope',270 'target',271 'target-within',272 'user-invalid',273 'valid',274 'visited',275 'where' // where()276].sort().reverse();277 278// https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements279const PSEUDO_ELEMENTS = [280 'after',281 'backdrop',282 'before',283 'cue',284 'cue-region',285 'first-letter',286 'first-line',287 'grammar-error',288 'marker',289 'part',290 'placeholder',291 'selection',292 'slotted',293 'spelling-error'294].sort().reverse();295 296const ATTRIBUTES = [297 'accent-color',298 'align-content',299 'align-items',300 'align-self',301 'alignment-baseline',302 'all',303 'anchor-name',304 'animation',305 'animation-composition',306 'animation-delay',307 'animation-direction',308 'animation-duration',309 'animation-fill-mode',310 'animation-iteration-count',311 'animation-name',312 'animation-play-state',313 'animation-range',314 'animation-range-end',315 'animation-range-start',316 'animation-timeline',317 'animation-timing-function',318 'appearance',319 'aspect-ratio',320 'backdrop-filter',321 'backface-visibility',322 'background',323 'background-attachment',324 'background-blend-mode',325 'background-clip',326 'background-color',327 'background-image',328 'background-origin',329 'background-position',330 'background-position-x',331 'background-position-y',332 'background-repeat',333 'background-size',334 'baseline-shift',335 'block-size',336 'border',337 'border-block',338 'border-block-color',339 'border-block-end',340 'border-block-end-color',341 'border-block-end-style',342 'border-block-end-width',343 'border-block-start',344 'border-block-start-color',345 'border-block-start-style',346 'border-block-start-width',347 'border-block-style',348 'border-block-width',349 'border-bottom',350 'border-bottom-color',351 'border-bottom-left-radius',352 'border-bottom-right-radius',353 'border-bottom-style',354 'border-bottom-width',355 'border-collapse',356 'border-color',357 'border-end-end-radius',358 'border-end-start-radius',359 'border-image',360 'border-image-outset',361 'border-image-repeat',362 'border-image-slice',363 'border-image-source',364 'border-image-width',365 'border-inline',366 'border-inline-color',367 'border-inline-end',368 'border-inline-end-color',369 'border-inline-end-style',370 'border-inline-end-width',371 'border-inline-start',372 'border-inline-start-color',373 'border-inline-start-style',374 'border-inline-start-width',375 'border-inline-style',376 'border-inline-width',377 'border-left',378 'border-left-color',379 'border-left-style',380 'border-left-width',381 'border-radius',382 'border-right',383 'border-right-color',384 'border-right-style',385 'border-right-width',386 'border-spacing',387 'border-start-end-radius',388 'border-start-start-radius',389 'border-style',390 'border-top',391 'border-top-color',392 'border-top-left-radius',393 'border-top-right-radius',394 'border-top-style',395 'border-top-width',396 'border-width',397 'bottom',398 'box-align',399 'box-decoration-break',400 'box-direction',401 'box-flex',402 'box-flex-group',403 'box-lines',404 'box-ordinal-group',405 'box-orient',406 'box-pack',407 'box-shadow',408 'box-sizing',409 'break-after',410 'break-before',411 'break-inside',412 'caption-side',413 'caret-color',414 'clear',415 'clip',416 'clip-path',417 'clip-rule',418 'color',419 'color-interpolation',420 'color-interpolation-filters',421 'color-profile',422 'color-rendering',423 'color-scheme',424 'column-count',425 'column-fill',426 'column-gap',427 'column-rule',428 'column-rule-color',429 'column-rule-style',430 'column-rule-width',431 'column-span',432 'column-width',433 'columns',434 'contain',435 'contain-intrinsic-block-size',436 'contain-intrinsic-height',437 'contain-intrinsic-inline-size',438 'contain-intrinsic-size',439 'contain-intrinsic-width',440 'container',441 'container-name',442 'container-type',443 'content',444 'content-visibility',445 'counter-increment',446 'counter-reset',447 'counter-set',448 'cue',449 'cue-after',450 'cue-before',451 'cursor',452 'cx',453 'cy',454 'direction',455 'display',456 'dominant-baseline',457 'empty-cells',458 'enable-background',459 'field-sizing',460 'fill',461 'fill-opacity',462 'fill-rule',463 'filter',464 'flex',465 'flex-basis',466 'flex-direction',467 'flex-flow',468 'flex-grow',469 'flex-shrink',470 'flex-wrap',471 'float',472 'flood-color',473 'flood-opacity',474 'flow',475 'font',476 'font-display',477 'font-family',478 'font-feature-settings',479 'font-kerning',480 'font-language-override',481 'font-optical-sizing',482 'font-palette',483 'font-size',484 'font-size-adjust',485 'font-smooth',486 'font-smoothing',487 'font-stretch',488 'font-style',489 'font-synthesis',490 'font-synthesis-position',491 'font-synthesis-small-caps',492 'font-synthesis-style',493 'font-synthesis-weight',494 'font-variant',495 'font-variant-alternates',496 'font-variant-caps',497 'font-variant-east-asian',498 'font-variant-emoji',499 'font-variant-ligatures',500 'font-variant-numeric',501 'font-variant-position',502 'font-variation-settings',503 'font-weight',504 'forced-color-adjust',505 'gap',506 'glyph-orientation-horizontal',507 'glyph-orientation-vertical',508 'grid',509 'grid-area',510 'grid-auto-columns',511 'grid-auto-flow',512 'grid-auto-rows',513 'grid-column',514 'grid-column-end',515 'grid-column-start',516 'grid-gap',517 'grid-row',518 'grid-row-end',519 'grid-row-start',520 'grid-template',521 'grid-template-areas',522 'grid-template-columns',523 'grid-template-rows',524 'hanging-punctuation',525 'height',526 'hyphenate-character',527 'hyphenate-limit-chars',528 'hyphens',529 'icon',530 'image-orientation',531 'image-rendering',532 'image-resolution',533 'ime-mode',534 'initial-letter',535 'initial-letter-align',536 'inline-size',537 'inset',538 'inset-area',539 'inset-block',540 'inset-block-end',541 'inset-block-start',542 'inset-inline',543 'inset-inline-end',544 'inset-inline-start',545 'isolation',546 'justify-content',547 'justify-items',548 'justify-self',549 'kerning',550 'left',551 'letter-spacing',552 'lighting-color',553 'line-break',554 'line-height',555 'line-height-step',556 'list-style',557 'list-style-image',558 'list-style-position',559 'list-style-type',560 'margin',561 'margin-block',562 'margin-block-end',563 'margin-block-start',564 'margin-bottom',565 'margin-inline',566 'margin-inline-end',567 'margin-inline-start',568 'margin-left',569 'margin-right',570 'margin-top',571 'margin-trim',572 'marker',573 'marker-end',574 'marker-mid',575 'marker-start',576 'marks',577 'mask',578 'mask-border',579 'mask-border-mode',580 'mask-border-outset',581 'mask-border-repeat',582 'mask-border-slice',583 'mask-border-source',584 'mask-border-width',585 'mask-clip',586 'mask-composite',587 'mask-image',588 'mask-mode',589 'mask-origin',590 'mask-position',591 'mask-repeat',592 'mask-size',593 'mask-type',594 'masonry-auto-flow',595 'math-depth',596 'math-shift',597 'math-style',598 'max-block-size',599 'max-height',600 'max-inline-size',601 'max-width',602 'min-block-size',603 'min-height',604 'min-inline-size',605 'min-width',606 'mix-blend-mode',607 'nav-down',608 'nav-index',609 'nav-left',610 'nav-right',611 'nav-up',612 'none',613 'normal',614 'object-fit',615 'object-position',616 'offset',617 'offset-anchor',618 'offset-distance',619 'offset-path',620 'offset-position',621 'offset-rotate',622 'opacity',623 'order',624 'orphans',625 'outline',626 'outline-color',627 'outline-offset',628 'outline-style',629 'outline-width',630 'overflow',631 'overflow-anchor',632 'overflow-block',633 'overflow-clip-margin',634 'overflow-inline',635 'overflow-wrap',636 'overflow-x',637 'overflow-y',638 'overlay',639 'overscroll-behavior',640 'overscroll-behavior-block',641 'overscroll-behavior-inline',642 'overscroll-behavior-x',643 'overscroll-behavior-y',644 'padding',645 'padding-block',646 'padding-block-end',647 'padding-block-start',648 'padding-bottom',649 'padding-inline',650 'padding-inline-end',651 'padding-inline-start',652 'padding-left',653 'padding-right',654 'padding-top',655 'page',656 'page-break-after',657 'page-break-before',658 'page-break-inside',659 'paint-order',660 'pause',661 'pause-after',662 'pause-before',663 'perspective',664 'perspective-origin',665 'place-content',666 'place-items',667 'place-self',668 'pointer-events',669 'position',670 'position-anchor',671 'position-visibility',672 'print-color-adjust',673 'quotes',674 'r',675 'resize',676 'rest',677 'rest-after',678 'rest-before',679 'right',680 'rotate',681 'row-gap',682 'ruby-align',683 'ruby-position',684 'scale',685 'scroll-behavior',686 'scroll-margin',687 'scroll-margin-block',688 'scroll-margin-block-end',689 'scroll-margin-block-start',690 'scroll-margin-bottom',691 'scroll-margin-inline',692 'scroll-margin-inline-end',693 'scroll-margin-inline-start',694 'scroll-margin-left',695 'scroll-margin-right',696 'scroll-margin-top',697 'scroll-padding',698 'scroll-padding-block',699 'scroll-padding-block-end',700 'scroll-padding-block-start',701 'scroll-padding-bottom',702 'scroll-padding-inline',703 'scroll-padding-inline-end',704 'scroll-padding-inline-start',705 'scroll-padding-left',706 'scroll-padding-right',707 'scroll-padding-top',708 'scroll-snap-align',709 'scroll-snap-stop',710 'scroll-snap-type',711 'scroll-timeline',712 'scroll-timeline-axis',713 'scroll-timeline-name',714 'scrollbar-color',715 'scrollbar-gutter',716 'scrollbar-width',717 'shape-image-threshold',718 'shape-margin',719 'shape-outside',720 'shape-rendering',721 'speak',722 'speak-as',723 'src', // @font-face724 'stop-color',725 'stop-opacity',726 'stroke',727 'stroke-dasharray',728 'stroke-dashoffset',729 'stroke-linecap',730 'stroke-linejoin',731 'stroke-miterlimit',732 'stroke-opacity',733 'stroke-width',734 'tab-size',735 'table-layout',736 'text-align',737 'text-align-all',738 'text-align-last',739 'text-anchor',740 'text-combine-upright',741 'text-decoration',742 'text-decoration-color',743 'text-decoration-line',744 'text-decoration-skip',745 'text-decoration-skip-ink',746 'text-decoration-style',747 'text-decoration-thickness',748 'text-emphasis',749 'text-emphasis-color',750 'text-emphasis-position',751 'text-emphasis-style',752 'text-indent',753 'text-justify',754 'text-orientation',755 'text-overflow',756 'text-rendering',757 'text-shadow',758 'text-size-adjust',759 'text-transform',760 'text-underline-offset',761 'text-underline-position',762 'text-wrap',763 'text-wrap-mode',764 'text-wrap-style',765 'timeline-scope',766 'top',767 'touch-action',768 'transform',769 'transform-box',770 'transform-origin',771 'transform-style',772 'transition',773 'transition-behavior',774 'transition-delay',775 'transition-duration',776 'transition-property',777 'transition-timing-function',778 'translate',779 'unicode-bidi',780 'user-modify',781 'user-select',782 'vector-effect',783 'vertical-align',784 'view-timeline',785 'view-timeline-axis',786 'view-timeline-inset',787 'view-timeline-name',788 'view-transition-name',789 'visibility',790 'voice-balance',791 'voice-duration',792 'voice-family',793 'voice-pitch',794 'voice-range',795 'voice-rate',796 'voice-stress',797 'voice-volume',798 'white-space',799 'white-space-collapse',800 'widows',801 'width',802 'will-change',803 'word-break',804 'word-spacing',805 'word-wrap',806 'writing-mode',807 'x',808 'y',809 'z-index',810 'zoom'811].sort().reverse();812 813/*814Language: Stylus815Author: Bryant Williams <b.n.williams@gmail.com>816Description: Stylus is an expressive, robust, feature-rich CSS language built for nodejs.817Website: https://github.com/stylus/stylus818Category: css, web819*/820 821 822/** @type LanguageFn */823function stylus(hljs) {824 const modes = MODES(hljs);825 826 const AT_MODIFIERS = "and or not only";827 const VARIABLE = {828 className: 'variable',829 begin: '\\$' + hljs.IDENT_RE830 };831 832 const AT_KEYWORDS = [833 'charset',834 'css',835 'debug',836 'extend',837 'font-face',838 'for',839 'import',840 'include',841 'keyframes',842 'media',843 'mixin',844 'page',845 'warn',846 'while'847 ];848 849 const LOOKAHEAD_TAG_END = '(?=[.\\s\\n[:,(])';850 851 // illegals852 const ILLEGAL = [853 '\\?',854 '(\\bReturn\\b)', // monkey855 '(\\bEnd\\b)', // monkey856 '(\\bend\\b)', // vbscript857 '(\\bdef\\b)', // gradle858 ';', // a whole lot of languages859 '#\\s', // markdown860 '\\*\\s', // markdown861 '===\\s', // markdown862 '\\|',863 '%' // prolog864 ];865 866 return {867 name: 'Stylus',868 aliases: [ 'styl' ],869 case_insensitive: false,870 keywords: 'if else for in',871 illegal: '(' + ILLEGAL.join('|') + ')',872 contains: [873 874 // strings875 hljs.QUOTE_STRING_MODE,876 hljs.APOS_STRING_MODE,877 878 // comments879 hljs.C_LINE_COMMENT_MODE,880 hljs.C_BLOCK_COMMENT_MODE,881 882 // hex colors883 modes.HEXCOLOR,884 885 // class tag886 {887 begin: '\\.[a-zA-Z][a-zA-Z0-9_-]*' + LOOKAHEAD_TAG_END,888 className: 'selector-class'889 },890 891 // id tag892 {893 begin: '#[a-zA-Z][a-zA-Z0-9_-]*' + LOOKAHEAD_TAG_END,894 className: 'selector-id'895 },896 897 // tags898 {899 begin: '\\b(' + TAGS.join('|') + ')' + LOOKAHEAD_TAG_END,900 className: 'selector-tag'901 },902 903 // psuedo selectors904 {905 className: 'selector-pseudo',906 begin: '&?:(' + PSEUDO_CLASSES.join('|') + ')' + LOOKAHEAD_TAG_END907 },908 {909 className: 'selector-pseudo',910 begin: '&?:(:)?(' + PSEUDO_ELEMENTS.join('|') + ')' + LOOKAHEAD_TAG_END911 },912 913 modes.ATTRIBUTE_SELECTOR_MODE,914 915 {916 className: "keyword",917 begin: /@media/,918 starts: {919 end: /[{;}]/,920 keywords: {921 $pattern: /[a-z-]+/,922 keyword: AT_MODIFIERS,923 attribute: MEDIA_FEATURES.join(" ")924 },925 contains: [ modes.CSS_NUMBER_MODE ]926 }927 },928 929 // @ keywords930 {931 className: 'keyword',932 begin: '\@((-(o|moz|ms|webkit)-)?(' + AT_KEYWORDS.join('|') + '))\\b'933 },934 935 // variables936 VARIABLE,937 938 // dimension939 modes.CSS_NUMBER_MODE,940 941 // functions942 // - only from beginning of line + whitespace943 {944 className: 'function',945 begin: '^[a-zA-Z][a-zA-Z0-9_\-]*\\(.*\\)',946 illegal: '[\\n]',947 returnBegin: true,948 contains: [949 {950 className: 'title',951 begin: '\\b[a-zA-Z][a-zA-Z0-9_\-]*'952 },953 {954 className: 'params',955 begin: /\(/,956 end: /\)/,957 contains: [958 modes.HEXCOLOR,959 VARIABLE,960 hljs.APOS_STRING_MODE,961 modes.CSS_NUMBER_MODE,962 hljs.QUOTE_STRING_MODE963 ]964 }965 ]966 },967 968 // css variables969 modes.CSS_VARIABLE,970 971 // attributes972 // - only from beginning of line + whitespace973 // - must have whitespace after it974 {975 className: 'attribute',976 begin: '\\b(' + ATTRIBUTES.join('|') + ')\\b',977 starts: {978 // value container979 end: /;|$/,980 contains: [981 modes.HEXCOLOR,982 VARIABLE,983 hljs.APOS_STRING_MODE,984 hljs.QUOTE_STRING_MODE,985 modes.CSS_NUMBER_MODE,986 hljs.C_BLOCK_COMMENT_MODE,987 modes.IMPORTANT,988 modes.FUNCTION_DISPATCH989 ],990 illegal: /\./,991 relevance: 0992 }993 },994 modes.FUNCTION_DISPATCH995 ]996 };997}998 999export { stylus as default };1000 