]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/less.js
1 /*! `less` 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',
817 // some grammars use them all as a single group
818 const PSEUDO_SELECTORS
= PSEUDO_CLASSES
.concat(PSEUDO_ELEMENTS
).sort().reverse();
822 Description: It's CSS, with just a little more.
823 Author: Max Mikhailov <seven.phases.max@gmail.com>
824 Website: http://lesscss.org
825 Category: common, css, web
829 /** @type LanguageFn */
830 function less(hljs
) {
831 const modes
= MODES(hljs
);
832 const PSEUDO_SELECTORS
$1 = PSEUDO_SELECTORS
;
834 const AT_MODIFIERS
= "and or not only";
835 const IDENT_RE
= '[\\w-]+'; // yes, Less identifiers may begin with a digit
836 const INTERP_IDENT_RE
= '(' + IDENT_RE
+ '|@\\{' + IDENT_RE
+ '\\})';
840 const RULES
= []; const VALUE_MODES
= []; // forward def. for recursive modes
842 const STRING_MODE = function(c
) {
844 // Less strings are not multiline (also include '~' for more consistent coloring of "escaped" strings)
846 begin: '~?' + c
+ '.*?' + c
850 const IDENT_MODE = function(name
, begin
, relevance
) {
858 const AT_KEYWORDS
= {
860 keyword: AT_MODIFIERS
,
861 attribute: MEDIA_FEATURES
.join(" ")
864 const PARENS_MODE
= {
865 // used only to properly balance nested parens inside mixin call, def. arg list
868 contains: VALUE_MODES
,
869 keywords: AT_KEYWORDS
,
873 // generic Less highlighter (used almost everywhere except selectors):
875 hljs
.C_LINE_COMMENT_MODE
,
876 hljs
.C_BLOCK_COMMENT_MODE
,
879 modes
.CSS_NUMBER_MODE
, // fixme: it does not include dot for numbers like .5em :(
881 begin: '(url|data-uri)\\(',
890 IDENT_MODE('variable', '@@?' + IDENT_RE
, 10),
891 IDENT_MODE('variable', '@\\{' + IDENT_RE
+ '\\}'),
892 IDENT_MODE('built_in', '~?`[^`]*?`'), // inline javascript (or whatever host language) *multiline* string
893 { // @media features (it’s here to not duplicate things in AT_RULE_MODE with extra PARENS_MODE overriding):
894 className: 'attribute',
895 begin: IDENT_RE
+ '\\s*:',
901 { beginKeywords: 'and not' },
902 modes
.FUNCTION_DISPATCH
905 const VALUE_WITH_RULESETS
= VALUE_MODES
.concat({
911 const MIXIN_GUARD_MODE
= {
912 beginKeywords: 'when',
913 endsWithParent: true,
914 contains: [ { beginKeywords: 'and not' } ].concat(VALUE_MODES
) // using this form to override VALUE’s 'function' match
917 /* Rule-Level Modes */
920 begin: INTERP_IDENT_RE
+ '\\s*:',
925 { begin: /-(webkit|moz|ms|o)-/ },
928 className: 'attribute',
929 begin: '\\b(' + ATTRIBUTES
.join('|') + ')\\b',
932 endsWithParent: true,
935 contains: VALUE_MODES
941 const AT_RULE_MODE
= {
942 className: 'keyword',
943 begin: '@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b',
946 keywords: AT_KEYWORDS
,
948 contains: VALUE_MODES
,
953 // variable definitions and calls
954 const VAR_RULE_MODE
= {
955 className: 'variable',
957 // using more strict pattern for higher relevance to increase chances of Less detection.
958 // this is *the only* Less specific statement used in most of the sources, so...
959 // (we’ll still often loose to the css-parser unless there's '//' comment,
960 // simply because 1 variable just can't beat 99 properties :)
962 begin: '@' + IDENT_RE
+ '\\s*:',
965 { begin: '@' + IDENT_RE
}
970 contains: VALUE_WITH_RULESETS
974 const SELECTOR_MODE
= {
975 // first parse unambiguous selectors (i.e. those not starting with tag)
976 // then fall into the scary lookahead-discriminator variant.
977 // this mode also handles mixin definitions and calls
980 begin: '[\\.#:&\\[>]',
981 end: '[;{}]' // mixin calls end with ';'
984 begin: INTERP_IDENT_RE
,
993 hljs
.C_LINE_COMMENT_MODE
,
994 hljs
.C_BLOCK_COMMENT_MODE
,
996 IDENT_MODE('keyword', 'all\\b'),
997 IDENT_MODE('variable', '@\\{' + IDENT_RE
+ '\\}'), // otherwise it’s identified as tag
1000 begin: '\\b(' + TAGS
.join('|') + ')\\b',
1001 className: 'selector-tag'
1003 modes
.CSS_NUMBER_MODE
,
1004 IDENT_MODE('selector-tag', INTERP_IDENT_RE
, 0),
1005 IDENT_MODE('selector-id', '#' + INTERP_IDENT_RE
),
1006 IDENT_MODE('selector-class', '\\.' + INTERP_IDENT_RE
, 0),
1007 IDENT_MODE('selector-tag', '&', 0),
1008 modes
.ATTRIBUTE_SELECTOR_MODE
,
1010 className: 'selector-pseudo',
1011 begin: ':(' + PSEUDO_CLASSES
.join('|') + ')'
1014 className: 'selector-pseudo',
1015 begin: ':(:)?(' + PSEUDO_ELEMENTS
.join('|') + ')'
1021 contains: VALUE_WITH_RULESETS
1022 }, // argument list of parametric mixins
1023 { begin: '!important' }, // eat !important after mixin call or it will be colored as tag
1024 modes
.FUNCTION_DISPATCH
1028 const PSEUDO_SELECTOR_MODE
= {
1029 begin: IDENT_RE
+ ':(:)?' + `(${PSEUDO_SELECTORS$1.join('|')})`,
1031 contains: [ SELECTOR_MODE
]
1035 hljs
.C_LINE_COMMENT_MODE
,
1036 hljs
.C_BLOCK_COMMENT_MODE
,
1039 PSEUDO_SELECTOR_MODE
,
1043 modes
.FUNCTION_DISPATCH
1048 case_insensitive: true,
1049 illegal: '[=>\'/<($"]',
1058 export default hljsGrammar
;