]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/css.js
1 /*! `css` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
5 const MODES
= (hljs
) => {
11 BLOCK_COMMENT: hljs
.C_BLOCK_COMMENT_MODE
,
14 begin: /#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/
17 className: "built_in",
20 ATTRIBUTE_SELECTOR_MODE: {
21 scope: 'selector-attr',
26 hljs
.APOS_STRING_MODE
,
27 hljs
.QUOTE_STRING_MODE
32 begin: hljs
.NUMBER_RE
+ '(' +
35 '|cm|mm|in|pt|pc|px' +
36 '|deg|grad|rad|turn' +
45 begin: /--[A-Za-z_][A-Za-z0-9_-]*/
141 'feComponentTransfer',
152 'feSpecularLighting',
179 // Sorting, then reversing makes sure longer attributes/elements like
180 // `font-weight` are matched fully instead of getting false positives on say `font`
182 const MEDIA_FEATURES
= [
189 'device-aspect-ratio',
203 'prefers-color-scheme',
205 'prefers-reduced-motion',
206 'prefers-reduced-transparency',
212 // TODO: find a better solution?
219 // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
220 const PSEUDO_CLASSES
= [
242 'host', // host or host()
243 'host-context', // host-context()
256 'nth-child', // nth-child()
257 'nth-col', // nth-col()
258 'nth-last-child', // nth-last-child()
259 'nth-last-col', // nth-last-col()
260 'nth-last-of-type', //nth-last-of-type()
261 'nth-of-type', //nth-of-type()
282 // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
283 const PSEUDO_ELEMENTS
= [
305 'alignment-baseline',
309 'animation-composition',
311 'animation-direction',
312 'animation-duration',
313 'animation-fill-mode',
314 'animation-iteration-count',
316 'animation-play-state',
318 'animation-range-end',
319 'animation-range-start',
320 'animation-timeline',
321 'animation-timing-function',
325 'backface-visibility',
327 'background-attachment',
328 'background-blend-mode',
333 'background-position',
334 'background-position-x',
335 'background-position-y',
342 'border-block-color',
344 'border-block-end-color',
345 'border-block-end-style',
346 'border-block-end-width',
347 'border-block-start',
348 'border-block-start-color',
349 'border-block-start-style',
350 'border-block-start-width',
351 'border-block-style',
352 'border-block-width',
354 'border-bottom-color',
355 'border-bottom-left-radius',
356 'border-bottom-right-radius',
357 'border-bottom-style',
358 'border-bottom-width',
361 'border-end-end-radius',
362 'border-end-start-radius',
364 'border-image-outset',
365 'border-image-repeat',
366 'border-image-slice',
367 'border-image-source',
368 'border-image-width',
370 'border-inline-color',
372 'border-inline-end-color',
373 'border-inline-end-style',
374 'border-inline-end-width',
375 'border-inline-start',
376 'border-inline-start-color',
377 'border-inline-start-style',
378 'border-inline-start-width',
379 'border-inline-style',
380 'border-inline-width',
387 'border-right-color',
388 'border-right-style',
389 'border-right-width',
391 'border-start-end-radius',
392 'border-start-start-radius',
396 'border-top-left-radius',
397 'border-top-right-radius',
403 'box-decoration-break',
423 'color-interpolation',
424 'color-interpolation-filters',
439 'contain-intrinsic-block-size',
440 'contain-intrinsic-height',
441 'contain-intrinsic-inline-size',
442 'contain-intrinsic-size',
443 'contain-intrinsic-width',
448 'content-visibility',
482 'font-feature-settings',
484 'font-language-override',
485 'font-optical-sizing',
494 'font-synthesis-position',
495 'font-synthesis-small-caps',
496 'font-synthesis-style',
497 'font-synthesis-weight',
499 'font-variant-alternates',
501 'font-variant-east-asian',
502 'font-variant-emoji',
503 'font-variant-ligatures',
504 'font-variant-numeric',
505 'font-variant-position',
506 'font-variation-settings',
508 'forced-color-adjust',
510 'glyph-orientation-horizontal',
511 'glyph-orientation-vertical',
525 'grid-template-areas',
526 'grid-template-columns',
527 'grid-template-rows',
528 'hanging-punctuation',
530 'hyphenate-character',
531 'hyphenate-limit-chars',
539 'initial-letter-align',
548 'inset-inline-start',
562 'list-style-position',
567 'margin-block-start',
571 'margin-inline-start',
584 'mask-border-outset',
585 'mask-border-repeat',
587 'mask-border-source',
637 'overflow-clip-margin',
643 'overscroll-behavior',
644 'overscroll-behavior-block',
645 'overscroll-behavior-inline',
646 'overscroll-behavior-x',
647 'overscroll-behavior-y',
651 'padding-block-start',
654 'padding-inline-end',
655 'padding-inline-start',
668 'perspective-origin',
675 'position-visibility',
676 'print-color-adjust',
691 'scroll-margin-block',
692 'scroll-margin-block-end',
693 'scroll-margin-block-start',
694 'scroll-margin-bottom',
695 'scroll-margin-inline',
696 'scroll-margin-inline-end',
697 'scroll-margin-inline-start',
698 'scroll-margin-left',
699 'scroll-margin-right',
702 'scroll-padding-block',
703 'scroll-padding-block-end',
704 'scroll-padding-block-start',
705 'scroll-padding-bottom',
706 'scroll-padding-inline',
707 'scroll-padding-inline-end',
708 'scroll-padding-inline-start',
709 'scroll-padding-left',
710 'scroll-padding-right',
711 'scroll-padding-top',
716 'scroll-timeline-axis',
717 'scroll-timeline-name',
721 'shape-image-threshold',
744 'text-combine-upright',
746 'text-decoration-color',
747 'text-decoration-line',
748 'text-decoration-skip',
749 'text-decoration-skip-ink',
750 'text-decoration-style',
751 'text-decoration-thickness',
753 'text-emphasis-color',
754 'text-emphasis-position',
755 'text-emphasis-style',
764 'text-underline-offset',
765 'text-underline-position',
777 'transition-behavior',
779 'transition-duration',
780 'transition-property',
781 'transition-timing-function',
789 'view-timeline-axis',
790 'view-timeline-inset',
791 'view-timeline-name',
792 'view-transition-name',
803 'white-space-collapse',
819 Category: common, css, web
820 Website: https://developer.mozilla.org/en-US/docs/Web/CSS
824 /** @type LanguageFn */
826 const regex
= hljs
.regex
;
827 const modes
= MODES(hljs
);
828 const VENDOR_PREFIX
= { begin: /-(webkit|moz|ms|o)-(?=[a-z])/ };
829 const AT_MODIFIERS
= "and or not only";
830 const AT_PROPERTY_RE
= /@-?\w[\w]*(-\w+)*/; // @-webkit-keyframes
831 const IDENT_RE
= '[a-zA-Z-][a-zA-Z0-9_-]*';
833 hljs
.APOS_STRING_MODE
,
834 hljs
.QUOTE_STRING_MODE
839 case_insensitive: true,
841 keywords: { keyframePosition: "from to" },
843 // for visual continuity with `tag {}` and because we
844 // don't have a great class for this?
845 keyframePosition: "selector-tag" },
849 // to recognize keyframe 40% etc which are outside the scope of our
850 // attribute value mode
851 modes
.CSS_NUMBER_MODE
,
853 className: 'selector-id',
854 begin: /#[A-Za-z0-9_-]+/,
858 className: 'selector-class',
859 begin: '\\.' + IDENT_RE
,
862 modes
.ATTRIBUTE_SELECTOR_MODE
,
864 className: 'selector-pseudo',
866 { begin: ':(' + PSEUDO_CLASSES
.join('|') + ')' },
867 { begin: ':(:)?(' + PSEUDO_ELEMENTS
.join('|') + ')' }
870 // we may actually need this (12/2020)
871 // { // pseudo-selector params
874 // contains: [ hljs.CSS_NUMBER_MODE ]
878 className: 'attribute',
879 begin: '\\b(' + ATTRIBUTES
.join('|') + ')\\b'
889 modes
.CSS_NUMBER_MODE
,
891 // needed to highlight these as strings and to avoid issues with
892 // illegal characters that might be inside urls that would tigger the
893 // languages illegal stack
895 begin: /(url|data-uri)\(/,
897 relevance: 0, // from keywords
898 keywords: { built_in: "url data-uri" },
903 // any character other than `)` as in `url()` will be the start
904 // of a string, which ends with `)` (from the parent mode)
906 endsWithParent: true,
911 modes
.FUNCTION_DISPATCH
915 begin: regex
.lookahead(/@/),
918 illegal: /:/, // break on Less variables
@var: ...
921 className: 'keyword',
922 begin: AT_PROPERTY_RE
926 endsWithParent: true,
931 keyword: AT_MODIFIERS
,
932 attribute: MEDIA_FEATURES
.join(" ")
936 begin: /[a-z-]+(?=:)/,
937 className: "attribute"
940 modes
.CSS_NUMBER_MODE
946 className: 'selector-tag',
947 begin: '\\b(' + TAGS
.join('|') + ')\\b'
957 export default hljsGrammar
;