]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/css.js
1 /*! `css` 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 Category: common, css, web
821 Website: https://developer.mozilla.org/en-US/docs/Web/CSS
825 /** @type LanguageFn */
827 const regex
= hljs
.regex
;
828 const modes
= MODES(hljs
);
829 const VENDOR_PREFIX
= { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ };
830 const AT_MODIFIERS
= "and or not only";
831 const AT_PROPERTY_RE
= /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
832 const IDENT_RE
= '[a-zA-Z-][a-zA-Z0-9_-]*';
834 hljs
.APOS_STRING_MODE
,
835 hljs
.QUOTE_STRING_MODE
840 case_insensitive: true,
842 keywords: { keyframePosition: "from to" },
844 // for visual continuity with `tag {}` and because we
845 // don't have a great class for this?
846 keyframePosition: "selector-tag" },
850 // to recognize keyframe 40% etc which are outside the scope of our
851 // attribute value mode
852 modes
.CSS_NUMBER_MODE
,
854 className: 'selector-id',
855 begin: /#[A-Za-z0-9_-]+/,
859 className: 'selector-class',
860 begin: '\\.' + IDENT_RE
,
863 modes
.ATTRIBUTE_SELECTOR_MODE
,
865 className: 'selector-pseudo',
867 { begin: ':(' + PSEUDO_CLASSES
.join('|') + ')' },
868 { begin: ':(:)?(' + PSEUDO_ELEMENTS
.join('|') + ')' }
871 // we may actually need this (12/2020)
872 // { // pseudo-selector params
875 // contains: [ hljs.CSS_NUMBER_MODE ]
879 className: 'attribute',
880 begin: '\\b(' + ATTRIBUTES
.join('|') + ')\\b'
890 modes
.CSS_NUMBER_MODE
,
892 // needed to highlight these as strings and to avoid issues with
893 // illegal characters that might be inside urls that would tigger the
894 // languages illegal stack
896 begin: /(url|data-uri)\(/,
898 relevance: 0, // from keywords
899 keywords: { built_in: "url data-uri" },
904 // any character other than `)` as in `url()` will be the start
905 // of a string, which ends with `)` (from the parent mode)
907 endsWithParent: true,
912 modes
.FUNCTION_DISPATCH
916 begin: regex
.lookahead(/@/),
919 illegal: /:/, // break on Less variables
@var: ...
922 className: 'keyword',
923 begin: AT_PROPERTY_RE
927 endsWithParent: true,
932 keyword: AT_MODIFIERS
,
933 attribute: MEDIA_FEATURES
.join(" ")
937 begin: /[a-z-]+(?=:)/,
938 className: "attribute"
941 modes
.CSS_NUMBER_MODE
947 className: 'selector-tag',
948 begin: '\\b(' + TAGS
.join('|') + ')\\b'
958 hljs
.registerLanguage('css', hljsGrammar
);