diff --git a/components/prism-elm.js b/components/prism-elm.js index 2e4a5fb2b9..ba712f97ab 100644 --- a/components/prism-elm.js +++ b/components/prism-elm.js @@ -1,10 +1,10 @@ Prism.languages.elm = { - comment: /--.*|{-[\s\S]*?-}/, - char: { + 'comment': /--.*|{-[\s\S]*?-}/, + 'char': { pattern: /'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/, greedy: true }, - string: [ + 'string': [ { // Multiline strings are wrapped in triple ". Quotes may appear unescaped. pattern: /"""[\s\S]*?"""/, @@ -15,20 +15,20 @@ Prism.languages.elm = { greedy: true } ], - import_statement: { + 'import-statement': { // The imported or hidden names are not included in this import // statement. This is because we want to highlight those exactly like // we do for the names in the program. pattern: /^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m, inside: { - keyword: /\b(?:import|as|exposing)\b/ + 'keyword': /\b(?:import|as|exposing)\b/ } }, - keyword: /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/, + 'keyword': /\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/, // These are builtin variables only. Constructors are highlighted later as a constant. - builtin: /\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/, + 'builtin': /\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/, // decimal integers and floating point numbers | hexadecimal integers - number: /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i, + 'number': /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i, // Most of this is needed because of the meaning of a single '.'. // If it stands alone freely, it is the function composition. // It may also be a separator between a module name and an identifier => no @@ -36,9 +36,9 @@ Prism.languages.elm = { // operator too. // Valid operator characters in 0.18: +-/*=.$<>:&|^?%#@~! // Ref: https://groups.google.com/forum/#!msg/elm-dev/0AHSnDdkSkQ/E0SVU70JEQAJ - operator: /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/, + 'operator': /\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/, // In Elm, nearly everything is a variable, do not highlight these. - hvariable: /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/, - constant: /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/, - punctuation: /[{}[\]|(),.:]/ + 'hvariable': /\b(?:[A-Z]\w*\.)*[a-z]\w*\b/, + 'constant': /\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/, + 'punctuation': /[{}[\]|(),.:]/ }; diff --git a/components/prism-elm.min.js b/components/prism-elm.min.js index ee9d8e811c..b574bf8c71 100644 --- a/components/prism-elm.min.js +++ b/components/prism-elm.min.js @@ -1 +1 @@ -Prism.languages.elm={comment:/--.*|{-[\s\S]*?-}/,char:{pattern:/'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/,greedy:!0},string:[{pattern:/"""[\s\S]*?"""/,greedy:!0},{pattern:/"(?:[^\\"\r\n]|\\.)*"/,greedy:!0}],import_statement:{pattern:/^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,inside:{keyword:/\b(?:import|as|exposing)\b/}},keyword:/\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,builtin:/\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/,number:/\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,operator:/\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,hvariable:/\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,constant:/\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,punctuation:/[{}[\]|(),.:]/}; \ No newline at end of file +Prism.languages.elm={comment:/--.*|{-[\s\S]*?-}/,char:{pattern:/'(?:[^\\'\r\n]|\\(?:[abfnrtv\\']|\d+|x[0-9a-fA-F]+))'/,greedy:!0},string:[{pattern:/"""[\s\S]*?"""/,greedy:!0},{pattern:/"(?:[^\\"\r\n]|\\.)*"/,greedy:!0}],"import-statement":{pattern:/^\s*import\s+[A-Z]\w*(?:\.[A-Z]\w*)*(?:\s+as\s+(?:[A-Z]\w*)(?:\.[A-Z]\w*)*)?(?:\s+exposing\s+)?/m,inside:{keyword:/\b(?:import|as|exposing)\b/}},keyword:/\b(?:alias|as|case|else|exposing|if|in|infixl|infixr|let|module|of|then|type)\b/,builtin:/\b(?:abs|acos|always|asin|atan|atan2|ceiling|clamp|compare|cos|curry|degrees|e|flip|floor|fromPolar|identity|isInfinite|isNaN|logBase|max|min|negate|never|not|pi|radians|rem|round|sin|sqrt|tan|toFloat|toPolar|toString|truncate|turns|uncurry|xor)\b/,number:/\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0x[0-9a-f]+)\b/i,operator:/\s\.\s|[+\-/*=.$<>:&|^?%#@~!]{2,}|[+\-/*=$<>:&|^?%#@~!]/,hvariable:/\b(?:[A-Z]\w*\.)*[a-z]\w*\b/,constant:/\b(?:[A-Z]\w*\.)*[A-Z]\w*\b/,punctuation:/[{}[\]|(),.:]/}; \ No newline at end of file diff --git a/components/prism-git.js b/components/prism-git.js index 54f5ea77a6..d9bee8fcb6 100644 --- a/components/prism-git.js +++ b/components/prism-git.js @@ -64,5 +64,5 @@ Prism.languages.git = { * * Add of a new line */ - 'commit_sha1': /^commit \w{40}$/m + 'commit-sha1': /^commit \w{40}$/m }; diff --git a/components/prism-git.min.js b/components/prism-git.min.js index 8166591050..3d5831a780 100644 --- a/components/prism-git.min.js +++ b/components/prism-git.min.js @@ -1 +1 @@ -Prism.languages.git={comment:/^#.*/m,deleted:/^[-–].*/m,inserted:/^\+.*/m,string:/("|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s--?\w+/m}},coord:/^@@.*@@$/m,commit_sha1:/^commit \w{40}$/m}; \ No newline at end of file +Prism.languages.git={comment:/^#.*/m,deleted:/^[-–].*/m,inserted:/^\+.*/m,string:/("|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s--?\w+/m}},coord:/^@@.*@@$/m,"commit-sha1":/^commit \w{40}$/m}; \ No newline at end of file diff --git a/components/prism-ocaml.js b/components/prism-ocaml.js index a13ded0a51..101c82b066 100644 --- a/components/prism-ocaml.js +++ b/components/prism-ocaml.js @@ -19,7 +19,7 @@ Prism.languages.ocaml = { pattern: /\B~\w+/, alias: 'function' }, - 'type_variable': { + 'type-variable': { pattern: /\B'\w+/, alias: 'function' }, diff --git a/components/prism-ocaml.min.js b/components/prism-ocaml.min.js index b4ea3c5b38..016c477dc6 100644 --- a/components/prism-ocaml.min.js +++ b/components/prism-ocaml.min.js @@ -1 +1 @@ -Prism.languages.ocaml={comment:/\(\*[\s\S]*?\*\)/,string:[{pattern:/"(?:\\.|[^\\\r\n"])*"/,greedy:!0},{pattern:/(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,greedy:!0}],number:/\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,directive:{pattern:/\B#\w+/,alias:"important"},label:{pattern:/\B~\w+/,alias:"function"},type_variable:{pattern:/\B'\w+/,alias:"function"},variant:{pattern:/`\w+/,alias:"variable"},module:{pattern:/\b[A-Z]\w+/,alias:"variable"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,boolean:/\b(?:false|true)\b/,operator:/:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,punctuation:/[(){}\[\]|.,:;]|\b_\b/}; \ No newline at end of file +Prism.languages.ocaml={comment:/\(\*[\s\S]*?\*\)/,string:[{pattern:/"(?:\\.|[^\\\r\n"])*"/,greedy:!0},{pattern:/(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,greedy:!0}],number:/\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*\.?[\d_]*(?:e[+-]?[\d_]+)?)/i,directive:{pattern:/\B#\w+/,alias:"important"},label:{pattern:/\B~\w+/,alias:"function"},"type-variable":{pattern:/\B'\w+/,alias:"function"},variant:{pattern:/`\w+/,alias:"variable"},module:{pattern:/\b[A-Z]\w+/,alias:"variable"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,boolean:/\b(?:false|true)\b/,operator:/:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,punctuation:/[(){}\[\]|.,:;]|\b_\b/}; \ No newline at end of file diff --git a/tests/languages/elm/import_statement_feature.test b/tests/languages/elm/import-statement_feature.test similarity index 82% rename from tests/languages/elm/import_statement_feature.test rename to tests/languages/elm/import-statement_feature.test index c2940362dc..467d25f88e 100644 --- a/tests/languages/elm/import_statement_feature.test +++ b/tests/languages/elm/import-statement_feature.test @@ -7,23 +7,23 @@ import Json.Decode as Json exposing (Decoder) ---------------------------------------------------- [ - ["import_statement", [ + ["import-statement", [ ["keyword", "import"], " Foo" ]], - ["import_statement", [ + ["import-statement", [ ["keyword", "import"], " Foo_42.Bar ", ["keyword", "as"], " Foobar" ]], - ["import_statement", [ + ["import-statement", [ ["keyword", "import"], " Foo.Bar ", ["keyword", "as"], " Foo.Baz" ]], - ["import_statement", [ + ["import-statement", [ ["keyword", "import"], " List ", ["keyword", "exposing"] @@ -31,7 +31,7 @@ import Json.Decode as Json exposing (Decoder) ["punctuation", "("], ["hvariable", "map"], ["punctuation", ")"], - ["import_statement", [ + ["import-statement", [ ["keyword", "import"], " Json.Decode ", ["keyword", "as"], diff --git a/tests/languages/git/commit_sha1_feature.test b/tests/languages/git/commit-sha1_feature.test similarity index 54% rename from tests/languages/git/commit_sha1_feature.test rename to tests/languages/git/commit-sha1_feature.test index fbc58ed2bd..62f3e02f54 100644 --- a/tests/languages/git/commit_sha1_feature.test +++ b/tests/languages/git/commit-sha1_feature.test @@ -5,11 +5,11 @@ commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d ---------------------------------------------------- [ - ["commit_sha1", "commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09"], - ["commit_sha1", "commit 87edc4ad8c71b95f6e46f736eb98b742859abd95"], - ["commit_sha1", "commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d"] + ["commit-sha1", "commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09"], + ["commit-sha1", "commit 87edc4ad8c71b95f6e46f736eb98b742859abd95"], + ["commit-sha1", "commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d"] ] ---------------------------------------------------- -Checks for commit SHA1. \ No newline at end of file +Checks for commit SHA1. diff --git a/tests/languages/ocaml/type_variable_feature.test b/tests/languages/ocaml/type-variable_feature.test similarity index 56% rename from tests/languages/ocaml/type_variable_feature.test rename to tests/languages/ocaml/type-variable_feature.test index 7f680e47fe..9c89b8acd4 100644 --- a/tests/languages/ocaml/type_variable_feature.test +++ b/tests/languages/ocaml/type-variable_feature.test @@ -4,10 +4,10 @@ ---------------------------------------------------- [ - ["type_variable", "'Foo"], - ["type_variable", "'bar_42"] + ["type-variable", "'Foo"], + ["type-variable", "'bar_42"] ] ---------------------------------------------------- -Checks for type variables. \ No newline at end of file +Checks for type variables. diff --git a/tests/pattern-tests.js b/tests/pattern-tests.js index cbf1d54eca..15272c9002 100644 --- a/tests/pattern-tests.js +++ b/tests/pattern-tests.js @@ -291,7 +291,7 @@ function testPatterns(Prism) { }); it('- should have nice names and aliases', function () { - const niceName = /^[a-z][a-z\d]*(?:[-_][a-z\d]+)*$/; + const niceName = /^[a-z][a-z\d]*(?:-[a-z\d]+)*$/; function testName(name, desc = 'token name') { if (!niceName.test(name)) { assert.fail(`The ${desc} '${name}' does not match ${niceName}.\n\n`