l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

scss.js (7912B)


      1 /*
      2 Language: SCSS
      3 Description: Scss is an extension of the syntax of CSS.
      4 Author: Kurt Emch <kurt@kurtemch.com>
      5 Website: https://sass-lang.com
      6 Category: common, css
      7 */
      8 function scss(hljs) {
      9   var AT_IDENTIFIER = '@[a-z-]+'; // @font-face
     10   var AT_MODIFIERS = "and or not only";
     11   var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
     12   var VARIABLE = {
     13     className: 'variable',
     14     begin: '(\\$' + IDENT_RE + ')\\b'
     15   };
     16   var HEXCOLOR = {
     17     className: 'number', begin: '#[0-9A-Fa-f]+'
     18   };
     19   var DEF_INTERNALS = {
     20     className: 'attribute',
     21     begin: '[A-Z\\_\\.\\-]+', end: ':',
     22     excludeEnd: true,
     23     illegal: '[^\\s]',
     24     starts: {
     25       endsWithParent: true, excludeEnd: true,
     26       contains: [
     27         HEXCOLOR,
     28         hljs.CSS_NUMBER_MODE,
     29         hljs.QUOTE_STRING_MODE,
     30         hljs.APOS_STRING_MODE,
     31         hljs.C_BLOCK_COMMENT_MODE,
     32         {
     33           className: 'meta', begin: '!important'
     34         }
     35       ]
     36     }
     37   };
     38   return {
     39     name: 'SCSS',
     40     case_insensitive: true,
     41     illegal: '[=/|\']',
     42     contains: [
     43       hljs.C_LINE_COMMENT_MODE,
     44       hljs.C_BLOCK_COMMENT_MODE,
     45       {
     46         className: 'selector-id', begin: '\\#[A-Za-z0-9_-]+',
     47         relevance: 0
     48       },
     49       {
     50         className: 'selector-class', begin: '\\.[A-Za-z0-9_-]+',
     51         relevance: 0
     52       },
     53       {
     54         className: 'selector-attr', begin: '\\[', end: '\\]',
     55         illegal: '$'
     56       },
     57       {
     58         className: 'selector-tag', // begin: IDENT_RE, end: '[,|\\s]'
     59         begin: '\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b',
     60         relevance: 0
     61       },
     62       {
     63         className: 'selector-pseudo',
     64         begin: ':(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)'
     65       },
     66       {
     67         className: 'selector-pseudo',
     68         begin: '::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)'
     69       },
     70       VARIABLE,
     71       {
     72         className: 'attribute',
     73         begin: '\\b(src|z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b',
     74         illegal: '[^\\s]'
     75       },
     76       {
     77         begin: '\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b'
     78       },
     79       {
     80         begin: ':', end: ';',
     81         contains: [
     82           VARIABLE,
     83           HEXCOLOR,
     84           hljs.CSS_NUMBER_MODE,
     85           hljs.QUOTE_STRING_MODE,
     86           hljs.APOS_STRING_MODE,
     87           {
     88             className: 'meta', begin: '!important'
     89           }
     90         ]
     91       },
     92       // matching these here allows us to treat them more like regular CSS
     93       // rules so everything between the {} gets regular rule highlighting,
     94       // which is what we want for page and font-face
     95       {
     96         begin: '@(page|font-face)',
     97         lexemes: AT_IDENTIFIER,
     98         keywords: '@page @font-face'
     99       },
    100       {
    101         begin: '@', end: '[{;]',
    102         returnBegin: true,
    103         keywords: AT_MODIFIERS,
    104         contains: [
    105           {
    106             begin: AT_IDENTIFIER,
    107             className: "keyword"
    108           },
    109           VARIABLE,
    110           hljs.QUOTE_STRING_MODE,
    111           hljs.APOS_STRING_MODE,
    112           HEXCOLOR,
    113           hljs.CSS_NUMBER_MODE,
    114           // {
    115           //   begin: '\\s[A-Za-z0-9_.-]+',
    116           //   relevance: 0
    117           // }
    118         ]
    119       }
    120     ]
    121   };
    122 }
    123 
    124 module.exports = scss;