Skip to content

Commit

Permalink
Added support for Latte & NEON (#2140)
Browse files Browse the repository at this point in the history
- Added support for templating system Latte https://latte.nette.org
- Added support for NEON https://ne-on.org
  • Loading branch information
dg authored and RunDevelopment committed Jan 5, 2020
1 parent 401d4b0 commit 694a81b
Show file tree
Hide file tree
Showing 25 changed files with 544 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@
},
"owner": "japborst"
},
"latte": {
"title": "Latte",
"require": ["clike", "markup-templating", "php"],
"owner": "nette"
},
"less": {
"title": "Less",
"require": "css",
Expand Down Expand Up @@ -650,6 +655,10 @@
"title": "NASM",
"owner": "rbmj"
},
"neon": {
"title": "NEON",
"owner": "nette"
},
"nginx": {
"title": "nginx",
"owner": "westonganger",
Expand Down
69 changes: 69 additions & 0 deletions components/prism-latte.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
(function (Prism) {
Prism.languages.latte = {
'comment': /^\{\*[\s\S]*/,
'ld': {
pattern: /^\{(?:[=_]|\/?(?!\d|\w+\()\w+|)/,
inside: {
'punctuation': /^\{\/?/,
'tag': {
pattern: /.+/,
alias: 'important'
}
}
},
'rd': {
pattern: /\}$/,
inside: {
'punctuation': /.+/
}
},
'php': {
pattern: /\S(?:[\s\S]*\S)?/,
alias: 'language-php',
inside: Prism.languages.php
}
};

var markupLatte = Prism.languages.extend('markup', {});
Prism.languages.insertBefore('inside', 'attr-value', {
'n-attr': {
pattern: /n:[\w-]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+))?/,
inside: {
'attr-name': {
pattern: /^[^\s=]+/,
alias: 'important'
},
'attr-value': {
pattern: /=[\s\S]+/,
inside: {
'punctuation': [
/^=/,
{
pattern: /^(\s*)["']|["']$/,
lookbehind: true
}
],
'php': {
pattern: /\S(?:[\s\S]*\S)?/,
inside: Prism.languages.php
}
}
},
}
},
}, markupLatte.tag);

Prism.hooks.add('before-tokenize', function(env) {
if (env.language !== 'latte') {
return;
}
var lattePattern = /\{\*[\s\S]*?\*\}|\{[^'"\s{}*](?:[^"'/{}]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|\/\*[\s\S]*?\*\/)*?\}/g;
Prism.languages['markup-templating'].buildPlaceholders(env, 'latte', lattePattern);
env.grammar = markupLatte;
});

Prism.hooks.add('after-tokenize', function(env) {
Prism.languages['markup-templating'].tokenizePlaceholders(env, 'latte');
});

}(Prism));
1 change: 1 addition & 0 deletions components/prism-latte.min.js

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

41 changes: 41 additions & 0 deletions components/prism-neon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Prism.languages.neon = {
'comment': {
pattern: /#.*/,
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])/,
lookbehind: true,
alias: 'number'
},
'key': {
pattern: /(^|[[{(,\s])[^,:=[\]{}()'"\s]+(?=\s*:(?:$|[\]}),\s])|\s*=)/,
lookbehind: true,
alias: 'atrule'
},
'number': {
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,
lookbehind: true
},
'null': {
pattern: /(^|[[{(=:,\s])(?:null)(?=$|[\]}),:=\s])/i,
lookbehind: true,
alias: 'keyword'
},
'string': {
pattern: /(^|[[{(=:,\s])(?:('''|""")\r?\n(?:(?:[^\r\n]|\r?\n(?![\t ]*\2))*\r?\n)?[\t ]*\2|'[^'\r\n]*'|"(?:\\.|[^"\r\n])*")/,
lookbehind: true,
greedy: true
},
'literal': {
pattern: /(^|[[{(=:,\s])(?:[^#"\',:=[\]{}()\s`-]|[:-][^"\',=[\]{}()\s])(?:[^,:=\]})(\s]+|:(?![\s,\]})]|$)|[ \t]+[^#,:=\]})(\s])*/,
lookbehind: true,
alias: 'string',
},
'punctuation': /[,:=[\]{}()-]/,
};

1 change: 1 addition & 0 deletions components/prism-neon.min.js

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

5 changes: 5 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
"jsonp": "json",
"json5": "json",
"kotlin": "clike",
"latte": [
"clike",
"markup-templating",
"php"
],
"less": "css",
"lilypond": "scheme",
"markdown": "markup",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

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

1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"n4jsd": "N4JS",
"nand2tetris-hdl": "Nand To Tetris HDL",
"nasm": "NASM",
"neon": "NEON",
"nginx": "nginx",
"nsis": "NSIS",
"objectivec": "Objective-C",
Expand Down
Loading

0 comments on commit 694a81b

Please sign in to comment.