mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-24 14:36:59 +02:00
Add Reason support to Prism.js (#92)
This commit is contained in:
parent
effd1113ad
commit
0c66a898b6
1 changed files with 19 additions and 2 deletions
|
@ -234,7 +234,11 @@ const Prism = {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
env.highlightedCode = Prism.highlight(env.code, env.grammar, env.language);
|
env.highlightedCode = Prism.highlight(
|
||||||
|
env.code,
|
||||||
|
env.grammar,
|
||||||
|
env.language
|
||||||
|
);
|
||||||
|
|
||||||
Prism.hooks.run("before-insert", env);
|
Prism.hooks.run("before-insert", env);
|
||||||
|
|
||||||
|
@ -256,7 +260,6 @@ const Prism = {
|
||||||
|
|
||||||
const strarr = [text];
|
const strarr = [text];
|
||||||
|
|
||||||
|
|
||||||
if (grammar && grammar.rest) {
|
if (grammar && grammar.rest) {
|
||||||
const rest = grammar.rest;
|
const rest = grammar.rest;
|
||||||
for (var token in rest) {
|
for (var token in rest) {
|
||||||
|
@ -1099,6 +1102,20 @@ Prism.languages.yaml = {
|
||||||
important: /[&*][\w]+/,
|
important: /[&*][\w]+/,
|
||||||
punctuation: /---|[:[\]{}\-,|>?]|\.\.\./
|
punctuation: /---|[:[\]{}\-,|>?]|\.\.\./
|
||||||
};
|
};
|
||||||
|
(Prism.languages.reason = Prism.languages.extend("clike", {
|
||||||
|
comment: { pattern: /(^|[^\\])\/\*[\s\S]*?\*\//, lookbehind: !0 },
|
||||||
|
string: { pattern: /"(\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/, greedy: !0 },
|
||||||
|
"class-name": /\b[A-Z]\w*/,
|
||||||
|
keyword: /\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/,
|
||||||
|
operator: /\.{3}|:[:=]|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:mod|land|lor|lxor|lsl|lsr|asr)\b/
|
||||||
|
})), Prism.languages.insertBefore("reason", "class-name", {
|
||||||
|
character: {
|
||||||
|
pattern: /'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'])'/,
|
||||||
|
alias: "string"
|
||||||
|
},
|
||||||
|
constructor: { pattern: /\b[A-Z]\w*\b(?!\s*\.)/, alias: "variable" },
|
||||||
|
label: { pattern: /\b[a-z]\w*(?=::)/, alias: "symbol" }
|
||||||
|
}), delete Prism.languages.reason.function;
|
||||||
|
|
||||||
const PrismComponent = React.createClass({
|
const PrismComponent = React.createClass({
|
||||||
statics: {
|
statics: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue