Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 19, 2019
1 parent bfdc1f9 commit aae4dfd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
5 changes: 3 additions & 2 deletions components/prism-latte.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
'php': {
pattern: /\S(?:[\s\S]*\S)?/,
alias: 'language-php',
inside: Prism.languages.php
}
};
Expand All @@ -33,7 +34,7 @@
alias: 'important'
},
'attr-value': {
pattern: /=.+/i,
pattern: /=[\s\S]+/,
inside: {
'punctuation': [
/^=/,
Expand All @@ -56,7 +57,7 @@
if (env.language !== 'latte') {
return;
}
var lattePattern = /\{\*[\s\S]*?\*\}|\{[^'"\s{}*](?:[^"'/]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|\/\*[\s\S]*?(?:\*\/|$))*?\}/ig;
var lattePattern = /\{\*[\s\S]*?\*\}|\{[^'"\s{}*](?:[^"'/{}]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|\/\*[\s\S]*?\*\/)*?\}/g;
Prism.languages['markup-templating'].buildPlaceholders(env, 'latte', lattePattern);
env.grammar = markupLatte;
});
Expand Down
2 changes: 1 addition & 1 deletion components/prism-latte.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions components/prism-neon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Prism.languages.neon = {
greedy: true
},
'datetime': {
pattern: /(^|[[{(=,\s])\d\d\d\d-\d\d?-\d\d?(?:(?:[Tt]| +)\d\d?:\d\d:\d\d(?:\.\d*)? *(?:Z|[-+]\d\d?(?::?\d\d)?)?)?(?=$|[\]}),\s])/,
pattern: /(^|[[{(=:,\s])\d\d\d\d-\d\d?-\d\d?(?:(?:[Tt]| +)\d\d?:\d\d:\d\d(?:\.\d*)? *(?:Z|[-+]\d\d?(?::?\d\d)?)?)?(?=$|[\]}),\s])/,
lookbehind: true,
alias: 'number'
},
Expand All @@ -14,24 +14,26 @@ Prism.languages.neon = {
alias: 'atrule'
},
'number': {
pattern: /(^|[[{(=,\s])[+-]?(?:0x[\da-fA-F]+|0o[0-7]+|0b[01]+|(?:\d+\.?\d*|\.?\d+)(?:[eE][+-]?\d+)?)(?=$|[\]}),\s])/,
pattern: /(^|[[{(=:,\s])[+-]?(?:0x[\da-fA-F]+|0o[0-7]+|0b[01]+|(?:\d+\.?\d*|\.?\d+)(?:[eE][+-]?\d+)?)(?=$|[\]}),:=\s])/,
lookbehind: true
},
'boolean': {
pattern: /(^|[[{(=,\s])(?:true|false|yes|no)(?=$|[\]}),\s])/i,
pattern: /(^|[[{(=:,\s])(?:true|false|yes|no)(?=$|[\]}),:=\s])/i,
lookbehind: true
},
'null': {
pattern: /(^|[[{(=,\s])(?:null)(?=$|[\]}),\s])/i,
lookbehind: true
pattern: /(^|[[{(=:,\s])(?:null)(?=$|[\]}),:=\s])/i,
lookbehind: true,
alias: 'keyword'
},
'string': {
pattern: /(^|[[{(=,\s])(?:'''\r?\n(?:(?:[^\r\n]|\r?\n(?![\t\ ]*'''))*\r?\n)?[\t\ ]*'''|"""\r?\n(?:(?:[^\r\n]|\r?\n(?![\t\ ]*"""))*\r?\n)?[\t\ ]*"""|'[^'\n]*'|"(?:\\.|[^"\n])*")(?=$|[\]}),\s])/m,
pattern: /(^|[[{(=:,\s])(?:('''|""")\r?\n(?:(?:[^\r\n]|\r?\n(?![\t ]*\2))*\r?\n)?[\t ]*\2|'[^'\r\n]*'|"(?:\\.|[^"\r\n])*")(?=$|[\]}),:=\s])/,
lookbehind: true,
greedy: true
},
'literal': {
pattern: /(?:[^#"\',:=[\]{}()\x00-\x20`-]|[:-][^"\',\]})\s])(?:[^,:=\]})(\x00-\x20]+|:(?![\s,\]})]|$)|[\ \t]+[^#,:=\]})(\x00-\x20])*/,
pattern: /(^|[[{(=:,\s])(?:[^#"\',:=[\]{}()\s`-]|[:-][^"\',=[\]{}()\s])(?:[^,:=\]})(\s]+|:(?![\s,\]})]|$)|[ \t]+[^#,:=\]})(\s])*/,
lookbehind: true,
alias: 'string',
},
'punctuation': /[,:=[\]{}()-]/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-neon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/languages/neon/datetime_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ iso8601: 2001-12-14t21:59:43.10-05:00
spaced: 2001-12-14 21:59:43.10 -5
date: 2002-12-14
short: 2002-1-1
alt: 2016-06-03 19:00:00 +0200

----------------------------------------------------

Expand All @@ -16,7 +17,8 @@ short: 2002-1-1
["key", "date"], ["punctuation", ":"],
["datetime", "2002-12-14"],
["key", "short"], ["punctuation", ":"],
["datetime", "2002-1-1"]
["datetime", "2002-1-1"],
["key", "alt"], ["punctuation", ":"], ["datetime", "2016-06-03 19:00:00 +0200"]
]

----------------------------------------------------
Expand Down
39 changes: 39 additions & 0 deletions tests/languages/neon/json_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[
[true,false, null],
{
"A": "/*",
"B": "B",
"foo": 1,
"b\"ar":{"bar":1},
"baz":"\""
},
[0, 123, 3.14159, 5.0e8, 0.2E+2, 47e-5],
[
"" , "foo\"bar\"baz", "\u2642\\ "
]
]

----------------------------------------------------

[
["punctuation", "["],
["punctuation", "["], ["boolean", "true"], ["punctuation", ","], ["boolean", "false"], ["punctuation", ","], ["null", "null"], ["punctuation", "]"], ["punctuation", ","],
["punctuation", "{"],
["string", "\"A\""], ["punctuation", ":"], ["string", "\"/*\""], ["punctuation", ","],
["string", "\"B\""], ["punctuation", ":"], ["string", "\"B\""], ["punctuation", ","],
["string", "\"foo\""], ["punctuation", ":"], ["number", "1"], ["punctuation", ","],
["string", "\"b\\\"ar\""], ["punctuation", ":"],["punctuation", "{"], ["string", "\"bar\""], ["punctuation", ":"], ["number", "1"], ["punctuation", "}"], ["punctuation", ","],
["string", "\"baz\""], ["punctuation", ":"], ["string", "\"\\\"\""],
["punctuation", "}"], ["punctuation", ","],
["punctuation", "["],
["number", "0"], ["punctuation", ","], ["number", "123"], ["punctuation", ","], ["number", "3.14159"], ["punctuation", ","], ["number", "5.0e8"], ["punctuation", ","], ["number", "0.2E+2"], ["punctuation", ","], ["number", "47e-5"],
["punctuation", "]"], ["punctuation", ","],
["punctuation", "["],
["string", "\"\""], ["punctuation", ","], ["string", "\"foo\\\"bar\\\"baz\""], ["punctuation", ","], ["string", "\"\\u2642\\\\ \""], ["punctuation", "]"],
["punctuation", "]"]
]


----------------------------------------------------

Checks for JSON superset.

0 comments on commit aae4dfd

Please sign in to comment.