summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-02-10 19:15:21 +0100
committerArmand Philippot <git@armandphilippot.com>2022-02-10 19:36:39 +0100
commitf8cfa5e6e3ae74b84bb94ca3f982554709d2f7d0 (patch)
treee4ac7e11e8016cbb323b26a0c44c785249464ea4 /README.md
parentdd0081f361b97abf54b958d4e04840cf84b9be3b (diff)
chore: improve widgets
* Make all widgets expanded by default. This way, without Javascript, thematics and topics are still available. * Improve collapse/expand transition. * Remove widget scrollbar: the height was sometimes weird because of that. Except for ToC on large devices.
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions
102'>102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
(function (Prism) {
  Prism.languages.puppet = {
    heredoc: [
      // Matches the content of a quoted heredoc string (subject to interpolation)
      {
        pattern:
          /(@\("([^"\r\n\/):]+)"(?:\/[nrts$uL]*)?\).*(?:\r?\n|\r))(?:.*(?:\r?\n|\r(?!\n)))*?[ \t]*(?:\|[ \t]*)?(?:-[ \t]*)?\2/,
        lookbehind: true,
        alias: 'string',
        inside: {
          // Matches the end tag
          punctuation: /(?=\S).*\S(?= *$)/,
          // See interpolation below
        },
      },
      // Matches the content of an unquoted heredoc string (no interpolation)
      {
        pattern:
          /(@\(([^"\r\n\/):]+)(?:\/[nrts$uL]*)?\).*(?:\r?\n|\r))(?:.*(?:\r?\n|\r(?!\n)))*?[ \t]*(?:\|[ \t]*)?(?:-[ \t]*)?\2/,
        lookbehind: true,
        greedy: true,
        alias: 'string',
        inside: {
          // Matches the end tag
          punctuation: /(?=\S).*\S(?= *$)/,
        },
      },
      // Matches the start tag of heredoc strings
      {
        pattern: /@\("?(?:[^"\r\n\/):]+)"?(?:\/[nrts$uL]*)?\)/,
        alias: 'string',
        inside: {
          punctuation: {
            pattern: /(\().+?(?=\))/,
            lookbehind: true,
          },
        },
      },
    ],
    'multiline-comment': {
      pattern: /(^|[^\\])\/\*[\s\S]*?\*\//,
      lookbehind: true,
      greedy: true,
      alias: 'comment',
    },
    regex: {
      // Must be prefixed with the keyword "node" or a non-word char
      pattern:
        /((?:\bnode\s+|[~=\(\[\{,]\s*|[=+]>\s*|^\s*))\/(?:[^\/\\]|\\[\s\S])+\/(?:[imx]+\b|\B)/,
      lookbehind: true,
      greedy: true,
      inside: {
        // Extended regexes must have the x flag. They can contain single-line comments.
        'extended-regex': {
          pattern: /^\/(?:[^\/\\]|\\[\s\S])+\/[im]*x[im]*$/,
          inside: {
            comment: /#.*/,
          },
        },
      },
    },
    comment: {
      pattern: /(^|[^\\])#.*/,
      lookbehind: true,
      greedy: true,
    },
    string: {
      // Allow for one nested level of double quotes inside interpolation
      pattern:
        /(["'])(?:\$\{(?:[^'"}]|(["'])(?:(?!\2)[^\\]|\\[\s\S])*\2)+\}|\$(?!\{)|(?!\1)[^\\$]|\\[\s\S])*\1/,
      greedy: true,
      inside: {
        'double-quoted': {
          pattern: /^"[\s\S]*"$/,
          inside: {
            // See interpolation below
          },
        },
      },
    },
    variable: {
      pattern: /\$(?:::)?\w+(?:::\w+)*/,
      inside: {
        punctuation: /::/,
      },
    },
    'attr-name': /(?:\b\w+|\*)(?=\s*=>)/,
    function: [
      {
        pattern: /(\.)(?!\d)\w+/,
        lookbehind: true,
      },
      /\b(?:contain|debug|err|fail|include|info|notice|realize|require|tag|warning)\b|\b(?!\d)\w+(?=\()/,
    ],
    number: /\b(?:0x[a-f\d]+|\d+(?:\.\d+)?(?:e-?\d+)?)\b/i,
    boolean: /\b(?:false|true)\b/,
    // Includes words reserved for future use
    keyword:
      /\b(?:application|attr|case|class|consumes|default|define|else|elsif|function|if|import|inherits|node|private|produces|type|undef|unless)\b/,
    datatype: {
      pattern:
        /\b(?:Any|Array|Boolean|Callable|Catalogentry|Class|Collection|Data|Default|Enum|Float|Hash|Integer|NotUndef|Numeric|Optional|Pattern|Regexp|Resource|Runtime|Scalar|String|Struct|Tuple|Type|Undef|Variant)\b/,
      alias: 'symbol',
    },
    operator:
      /=[=~>]?|![=~]?|<(?:<\|?|[=~|-])?|>[>=]?|->?|~>|\|>?>?|[*\/%+?]|\b(?:and|in|or)\b/,
    punctuation: /[\[\]{}().,;]|:+/,
  };

  var interpolation = [
    {
      // Allow for one nested level of braces inside interpolation
      pattern:
        /(^|[^\\])\$\{(?:[^'"{}]|\{[^}]*\}|(["'])(?:(?!\2)[^\\]|\\[\s\S])*\2)+\}/,
      lookbehind: true,
      inside: {
        'short-variable': {
          // Negative look-ahead prevent wrong highlighting of functions
          pattern: /(^\$\{)(?!\w+\()(?:::)?\w+(?:::\w+)*/,
          lookbehind: true,
          alias: 'variable',
          inside: {
            punctuation: /::/,
          },
        },
        delimiter: {
          pattern: /^\$/,
          alias: 'variable',
        },
        rest: Prism.languages.puppet,
      },
    },
    {
      pattern: /(^|[^\\])\$(?:::)?\w+(?:::\w+)*/,
      lookbehind: true,
      alias: 'variable',
      inside: {
        punctuation: /::/,
      },
    },
  ];
  Prism.languages.puppet['heredoc'][0].inside.interpolation = interpolation;
  Prism.languages.puppet['string'].inside[
    'double-quoted'
  ].inside.interpolation = interpolation;
})(Prism);