]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/stylus.js
1 /*! `stylus` grammar compiled for Highlight.js 11.11.1 */
3 var hljsGrammar
= (function () {
6 const MODES
= (hljs
) => {
12 BLOCK_COMMENT: hljs
.C_BLOCK_COMMENT_MODE
,
15 begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
18 className: "built_in",
21 ATTRIBUTE_SELECTOR_MODE: {
22 scope: 'selector-attr',
27 hljs
.APOS_STRING_MODE
,
28 hljs
.QUOTE_STRING_MODE
33 begin: hljs
.NUMBER_RE
+ '(' +
36 '|cm|mm|in|pt|pc|px' +
37 '|deg|grad|rad|turn' +
46 begin: /--[A-Za-z_][A-Za-z0-9_-]*/
142 'feComponentTransfer',
153 'feSpecularLighting',
180 // Sorting, then reversing makes sure longer attributes/elements like
181 // `font-weight` are matched fully instead of getting false positives on say `font`
183 const MEDIA_FEATURES
= [
190 'device-aspect-ratio',
204 'prefers-color-scheme',
206 'prefers-reduced-motion',
207 'prefers-reduced-transparency',
213 // TODO: find a better solution?
220 // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
221 const PSEUDO_CLASSES
= [
243 'host', // host or host()
244 'host-context', // host-context()
257 'nth-child', // nth-child()
258 'nth-col', // nth-col()
259 'nth-last-child', // nth-last-child()
260 'nth-last-col', // nth-last-col()
261 'nth-last-of-type', //nth-last-of-type()
262 'nth-of-type', //nth-of-type()
283 // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
284 const PSEUDO_ELEMENTS
= [
306 'alignment-baseline',
310 'animation-composition',
312 'animation-direction',
313 'animation-duration',
314 'animation-fill-mode',
315 'animation-iteration-count',
317 'animation-play-state',
319 'animation-range-end',
320 'animation-range-start',
321 'animation-timeline',
322 'animation-timing-function',
326 'backface-visibility',
328 'background-attachment',
329 'background-blend-mode',
334 'background-position',
335 'background-position-x',
336 'background-position-y',
343 'border-block-color',
345 'border-block-end-color',
346 'border-block-end-style',
347 'border-block-end-width',
348 'border-block-start',
349 'border-block-start-color',
350 'border-block-start-style',
351 'border-block-start-width',
352 'border-block-style',
353 'border-block-width',
355 'border-bottom-color',
356 'border-bottom-left-radius',
357 'border-bottom-right-radius',
358 'border-bottom-style',
359 'border-bottom-width',
362 'border-end-end-radius',
363 'border-end-start-radius',
365 'border-image-outset',
366 'border-image-repeat',
367 'border-image-slice',
368 'border-image-source',
369 'border-image-width',
371 'border-inline-color',
373 'border-inline-end-color',
374 'border-inline-end-style',
375 'border-inline-end-width',
376 'border-inline-start',
377 'border-inline-start-color',
378 'border-inline-start-style',
379 'border-inline-start-width',
380 'border-inline-style',
381 'border-inline-width',
388 'border-right-color',
389 'border-right-style',
390 'border-right-width',
392 'border-start-end-radius',
393 'border-start-start-radius',
397 'border-top-left-radius',
398 'border-top-right-radius',
404 'box-decoration-break',
424 'color-interpolation',
425 'color-interpolation-filters',
440 'contain-intrinsic-block-size',
441 'contain-intrinsic-height',
442 'contain-intrinsic-inline-size',
443 'contain-intrinsic-size',
444 'contain-intrinsic-width',
449 'content-visibility',
483 'font-feature-settings',
485 'font-language-override',
486 'font-optical-sizing',
495 'font-synthesis-position',
496 'font-synthesis-small-caps',
497 'font-synthesis-style',
498 'font-synthesis-weight',
500 'font-variant-alternates',
502 'font-variant-east-asian',
503 'font-variant-emoji',
504 'font-variant-ligatures',
505 'font-variant-numeric',
506 'font-variant-position',
507 'font-variation-settings',
509 'forced-color-adjust',
511 'glyph-orientation-horizontal',
512 'glyph-orientation-vertical',
526 'grid-template-areas',
527 'grid-template-columns',
528 'grid-template-rows',
529 'hanging-punctuation',
531 'hyphenate-character',
532 'hyphenate-limit-chars',
540 'initial-letter-align',
549 'inset-inline-start',
563 'list-style-position',
568 'margin-block-start',
572 'margin-inline-start',
585 'mask-border-outset',
586 'mask-border-repeat',
588 'mask-border-source',
638 'overflow-clip-margin',
644 'overscroll-behavior',
645 'overscroll-behavior-block',
646 'overscroll-behavior-inline',
647 'overscroll-behavior-x',
648 'overscroll-behavior-y',
652 'padding-block-start',
655 'padding-inline-end',
656 'padding-inline-start',
669 'perspective-origin',
676 'position-visibility',
677 'print-color-adjust',
692 'scroll-margin-block',
693 'scroll-margin-block-end',
694 'scroll-margin-block-start',
695 'scroll-margin-bottom',
696 'scroll-margin-inline',
697 'scroll-margin-inline-end',
698 'scroll-margin-inline-start',
699 'scroll-margin-left',
700 'scroll-margin-right',
703 'scroll-padding-block',
704 'scroll-padding-block-end',
705 'scroll-padding-block-start',
706 'scroll-padding-bottom',
707 'scroll-padding-inline',
708 'scroll-padding-inline-end',
709 'scroll-padding-inline-start',
710 'scroll-padding-left',
711 'scroll-padding-right',
712 'scroll-padding-top',
717 'scroll-timeline-axis',
718 'scroll-timeline-name',
722 'shape-image-threshold',
745 'text-combine-upright',
747 'text-decoration-color',
748 'text-decoration-line',
749 'text-decoration-skip',
750 'text-decoration-skip-ink',
751 'text-decoration-style',
752 'text-decoration-thickness',
754 'text-emphasis-color',
755 'text-emphasis-position',
756 'text-emphasis-style',
765 'text-underline-offset',
766 'text-underline-position',
778 'transition-behavior',
780 'transition-duration',
781 'transition-property',
782 'transition-timing-function',
790 'view-timeline-axis',
791 'view-timeline-inset',
792 'view-timeline-name',
793 'view-transition-name',
804 'white-space-collapse',
820 Author: Bryant Williams <b.n.williams@gmail.com>
821 Description: Stylus is an expressive, robust, feature-rich CSS language built for nodejs.
822 Website: https://github.com/stylus/stylus
827 /** @type LanguageFn */
828 function stylus(hljs
) {
829 const modes
= MODES(hljs
);
831 const AT_MODIFIERS
= "and or not only";
833 className: 'variable',
834 begin: '\\$' + hljs
.IDENT_RE
837 const AT_KEYWORDS
= [
854 const LOOKAHEAD_TAG_END
= '(?=[.\\s\\n[:,(])';
859 '(\\bReturn\\b)', // monkey
860 '(\\bEnd\\b)', // monkey
861 '(\\bend\\b)', // vbscript
862 '(\\bdef\\b)', // gradle
863 ';', // a whole lot of languages
865 '\\*\\s', // markdown
866 '===\\s', // markdown
874 case_insensitive: false,
875 keywords: 'if else for in',
876 illegal: '(' + ILLEGAL
.join('|') + ')',
880 hljs
.QUOTE_STRING_MODE
,
881 hljs
.APOS_STRING_MODE
,
884 hljs
.C_LINE_COMMENT_MODE
,
885 hljs
.C_BLOCK_COMMENT_MODE
,
892 begin: '\\.[a-zA-Z][a-zA-Z0-9_-]*' + LOOKAHEAD_TAG_END
,
893 className: 'selector-class'
898 begin: '#[a-zA-Z][a-zA-Z0-9_-]*' + LOOKAHEAD_TAG_END
,
899 className: 'selector-id'
904 begin: '\\b(' + TAGS
.join('|') + ')' + LOOKAHEAD_TAG_END
,
905 className: 'selector-tag'
910 className: 'selector-pseudo',
911 begin: '&?:(' + PSEUDO_CLASSES
.join('|') + ')' + LOOKAHEAD_TAG_END
914 className: 'selector-pseudo',
915 begin: '&?:(:)?(' + PSEUDO_ELEMENTS
.join('|') + ')' + LOOKAHEAD_TAG_END
918 modes
.ATTRIBUTE_SELECTOR_MODE
,
921 className: "keyword",
927 keyword: AT_MODIFIERS
,
928 attribute: MEDIA_FEATURES
.join(" ")
930 contains: [ modes
.CSS_NUMBER_MODE
]
936 className: 'keyword',
937 begin: '\@((-(o|moz|ms|webkit)-)?(' + AT_KEYWORDS
.join('|') + '))\\b'
944 modes
.CSS_NUMBER_MODE
,
947 // - only from beginning of line + whitespace
949 className: 'function',
950 begin: '^[a-zA-Z][a-zA-Z0-9_\-]*\\(.*\\)',
956 begin: '\\b[a-zA-Z][a-zA-Z0-9_\-]*'
965 hljs
.APOS_STRING_MODE
,
966 modes
.CSS_NUMBER_MODE
,
967 hljs
.QUOTE_STRING_MODE
977 // - only from beginning of line + whitespace
978 // - must have whitespace after it
980 className: 'attribute',
981 begin: '\\b(' + ATTRIBUTES
.join('|') + ')\\b',
988 hljs
.APOS_STRING_MODE
,
989 hljs
.QUOTE_STRING_MODE
,
990 modes
.CSS_NUMBER_MODE
,
991 hljs
.C_BLOCK_COMMENT_MODE
,
993 modes
.FUNCTION_DISPATCH
999 modes
.FUNCTION_DISPATCH
1008 hljs
.registerLanguage('stylus', hljsGrammar
);