Skip to content

Commit

Permalink
Merge branch 'master' into add-rego-support
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Mar 5, 2021
2 parents 390a4da + bf4e7ba commit a830a7e
Show file tree
Hide file tree
Showing 18 changed files with 900 additions and 16 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@
"title": "Icon",
"owner": "Golmote"
},
"icu-message-format": {
"title": "ICU Message Format",
"owner": "RunDevelopment"
},
"idris": {
"title": "Idris",
"alias": "idr",
Expand Down
4 changes: 2 additions & 2 deletions components/prism-asciidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
'function': /^[a-z\d-]+(?=:)/,
'punctuation': /^::?/,
'attributes': {
pattern: /(?:\[(?:[^\]\\"]|(["'])(?:(?!\1)[^\\]|\\.)*\1|\\.)*\])/,
pattern: /(?:\[(?:[^\]\\"']|(["'])(?:(?!\1)[^\\]|\\.)*\1|\\.)*\])/,
inside: attributes.inside
}
}
Expand All @@ -149,7 +149,7 @@
Those do not have the restrictions of the constrained quotes.
They are, in order: __emphasis__, **strong**, ++monospace++, +++passthrough+++, ##unquoted##, $$passthrough$$, ~subscript~, ^superscript^, {attribute-reference}, [[anchor]], [[[bibliography anchor]]], <<xref>>, (((indexes))) and ((indexes))
*/
pattern: /(^|[^\\])(?:(?:\B\[(?:[^\]\\"]|(["'])(?:(?!\2)[^\\]|\\.)*\2|\\.)*\])?(?:\b_(?!\s)(?: _|[^_\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: _|[^_\\\r\n]|\\.)+)*_\b|\B``(?!\s).+?(?:(?:\r?\n|\r).+?)*''\B|\B`(?!\s)(?:[^`'\s]|\s+\S)+['`]\B|\B(['*+#])(?!\s)(?: \3|(?!\3)[^\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: \3|(?!\3)[^\\\r\n]|\\.)+)*\3\B)|(?:\[(?:[^\]\\"]|(["'])(?:(?!\4)[^\\]|\\.)*\4|\\.)*\])?(?:(__|\*\*|\+\+\+?|##|\$\$|[~^]).+?(?:(?:\r?\n|\r).+?)*\5|\{[^}\r\n]+\}|\[\[\[?.+?(?:(?:\r?\n|\r).+?)*\]?\]\]|<<.+?(?:(?:\r?\n|\r).+?)*>>|\(\(\(?.+?(?:(?:\r?\n|\r).+?)*\)?\)\)))/m,
pattern: /(^|[^\\])(?:(?:\B\[(?:[^\]\\"']|(["'])(?:(?!\2)[^\\]|\\.)*\2|\\.)*\])?(?:\b_(?!\s)(?: _|[^_\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: _|[^_\\\r\n]|\\.)+)*_\b|\B``(?!\s).+?(?:(?:\r?\n|\r).+?)*''\B|\B`(?!\s)(?:[^`'\s]|\s+\S)+['`]\B|\B(['*+#])(?!\s)(?: \3|(?!\3)[^\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: \3|(?!\3)[^\\\r\n]|\\.)+)*\3\B)|(?:\[(?:[^\]\\"']|(["'])(?:(?!\4)[^\\]|\\.)*\4|\\.)*\])?(?:(__|\*\*|\+\+\+?|##|\$\$|[~^]).+?(?:(?:\r?\n|\r).+?)*\5|\{[^}\r\n]+\}|\[\[\[?.+?(?:(?:\r?\n|\r).+?)*\]?\]\]|<<.+?(?:(?:\r?\n|\r).+?)*>>|\(\(\(?.+?(?:(?:\r?\n|\r).+?)*\)?\)\)))/m,
lookbehind: true,
inside: {
'attributes': attributes,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-asciidoc.min.js

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

148 changes: 148 additions & 0 deletions components/prism-icu-message-format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// https://unicode-org.github.io/icu/userguide/format_parse/messages/
// https://unicode-org.github.io/icu-docs/apidoc/released/icu4j/com/ibm/icu/text/MessageFormat.html

(function (Prism) {

/**
* @param {string} source
* @param {number} level
* @returns {string}
*/
function nested(source, level) {
if (level <= 0) {
return /[]/.source;
} else {
return source.replace(/<SELF>/g, function () { return nested(source, level - 1) });
}
}

var stringPattern = /'[{}:=,](?:[^']|'')*'(?!')/;

var escape = {
pattern: /''/,
greedy: true,
alias: 'operator'
};
var string = {
pattern: stringPattern,
greedy: true,
inside: {
'escape': escape
}
};

var argumentSource = nested(
/\{(?:[^{}']|'(?![{},'])|''|<STR>|<SELF>)*\}/.source
.replace(/<STR>/g, function () { return stringPattern.source; }),
8
);

var nestedMessage = {
pattern: RegExp(argumentSource),
inside: {
'message': {
pattern: /^(\{)[\s\S]+(?=\}$)/,
lookbehind: true,
inside: null // see below
},
'message-delimiter': {
pattern: /./,
alias: 'punctuation'
}
}
};

Prism.languages['icu-message-format'] = {
'argument': {
pattern: RegExp(argumentSource),
greedy: true,
inside: {
'content': {
pattern: /^(\{)[\s\S]+(?=\}$)/,
lookbehind: true,
inside: {
'argument-name': {
pattern: /^(\s*)[^{}:=,\s]+/,
lookbehind: true
},
'choice-style': {
// https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1ChoiceFormat.html#details
pattern: /^(\s*,\s*choice\s*,\s*)\S(?:[\s\S]*\S)?/,
lookbehind: true,
inside: {
'punctuation': /\|/,
'range': {
pattern: /^(\s*)[+-]?(?:\d+(?:\.\d*)?|\u221e)\s*[<#\u2264]/,
lookbehind: true,
inside: {
'operator': /[<#\u2264]/,
'number': /\S+/
}
},
rest: null // see below
}
},
'plural-style': {
// https://unicode-org.github.io/icu-docs/apidoc/released/icu4j/com/ibm/icu/text/PluralFormat.html#:~:text=Patterns%20and%20Their%20Interpretation
pattern: /^(\s*,\s*(?:plural|selectordinal)\s*,\s*)\S(?:[\s\S]*\S)?/,
lookbehind: true,
inside: {
'offset': /^offset:\s*\d+/,
'nested-message': nestedMessage,
'selector': {
pattern: /=\d+|[^{}:=,\s]+/,
inside: {
'keyword': /^(?:zero|one|two|few|many|other)$/
}
}
}
},
'select-style': {
// https://unicode-org.github.io/icu-docs/apidoc/released/icu4j/com/ibm/icu/text/SelectFormat.html#:~:text=Patterns%20and%20Their%20Interpretation
pattern: /^(\s*,\s*select\s*,\s*)\S(?:[\s\S]*\S)?/,
lookbehind: true,
inside: {
'nested-message': nestedMessage,
'selector': {
pattern: /[^{}:=,\s]+/,
inside: {
'keyword': /^other$/
}
}
}
},
'keyword': /\b(?:choice|plural|select|selectordinal)\b/,
'arg-type': {
pattern: /\b(?:number|date|time|spellout|ordinal|duration)\b/,
alias: 'keyword'
},
'arg-skeleton': {
pattern: /(,\s*)::[^{}:=,\s]+/,
lookbehind: true
},
'arg-style': {
pattern: /(,\s*)(?:short|medium|long|full|integer|currency|percent)(?=\s*$)/,
lookbehind: true
},
'arg-style-text': {
pattern: RegExp(/(^\s*,\s*(?=\S))/.source + nested(/(?:[^{}']|'[^']*'|\{(?:<SELF>)?\})+/.source, 8) + '$'),
lookbehind: true,
alias: 'string'
},
'punctuation': /,/
}
},
'argument-delimiter': {
pattern: /./,
alias: 'operator'
}
}
},
'escape': escape,
'string': string
};

nestedMessage.inside.message.inside = Prism.languages['icu-message-format'];
Prism.languages['icu-message-format'].argument.inside.content.inside['choice-style'].inside.rest = Prism.languages['icu-message-format'];

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

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

2 changes: 1 addition & 1 deletion components/prism-perl.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Prism.languages.perl = {
// ${...}
/[&*$@%]#?(?=\{)/,
// $foo
/[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+)+(?:::)*/i,
/[&*$@%]#?(?:(?:::)*'?(?!\d)[\w$]+(?![\w$]))+(?:::)*/i,
// $1
/[&*$@%]\d+/,
// $_, @_, %!
Expand Down
Loading

0 comments on commit a830a7e

Please sign in to comment.