diff --git a/docs/en/doc-markdown.md b/docs/doc-markdown.md similarity index 93% rename from docs/en/doc-markdown.md rename to docs/doc-markdown.md index 10c14efde3..760d74d992 100644 --- a/docs/en/doc-markdown.md +++ b/docs/doc-markdown.md @@ -1,11 +1,6 @@ --- id: doc-markdown title: Documentation Markdown Features -layout: docs -category: Docusaurus -permalink: docs/en/doc-markdown.html -previous: site-config -next: translation --- Docusaurus supports some extra features when writing documentation in markdown. diff --git a/docs/en/getting-started.md b/docs/getting-started.md similarity index 98% rename from docs/en/getting-started.md rename to docs/getting-started.md index 213eea2d43..0425edc88f 100644 --- a/docs/en/getting-started.md +++ b/docs/getting-started.md @@ -1,10 +1,6 @@ --- id: getting-started title: Docusaurus -layout: docs -category: Docusaurus -permalink: docs/en/getting-started.html -next: site-config --- ## Getting Started diff --git a/docs/en/search.md b/docs/search.md similarity index 90% rename from docs/en/search.md rename to docs/search.md index 23f4237e44..71b78bbd66 100644 --- a/docs/en/search.md +++ b/docs/search.md @@ -1,10 +1,6 @@ --- id: search title: Documentation Search -layout: docs -category: Docusaurus -permalink: docs/en/search.html -previous: translation --- ## Algolia Search Integration diff --git a/docs/en/site-config.md b/docs/site-config.md similarity index 97% rename from docs/en/site-config.md rename to docs/site-config.md index c63026375f..6297ebec57 100644 --- a/docs/en/site-config.md +++ b/docs/site-config.md @@ -1,11 +1,6 @@ --- id: site-config title: Customizing siteConfig -layout: docs -category: Docusaurus -permalink: docs/en/site-config.html -previous: getting-started -next: doc-markdown --- A large part of site configuration is done by editing the `siteConfig.js` file. diff --git a/docs/en/translation.md b/docs/translation.md similarity index 98% rename from docs/en/translation.md rename to docs/translation.md index 2c989e416a..24d8ded293 100644 --- a/docs/en/translation.md +++ b/docs/translation.md @@ -1,11 +1,6 @@ --- id: translation title: Translations with Docusaurus -layout: docs -category: Docusaurus -permalink: docs/en/translation.html -previous: doc-markdown -next: search --- ## Overview diff --git a/lib/build-files.js b/lib/build-files.js old mode 100644 new mode 100755 index 5d8c5e47fe..f67b3ebb48 --- a/lib/build-files.js +++ b/lib/build-files.js @@ -10,10 +10,9 @@ */ require("babel-register")({ - ignore: false, babelrc: false, plugins: [require("./server/translate-plugin.js")], - presets: ["react"] + presets: ["react", "latest", "stage-0"] }); const generate = require("./server/generate.js"); diff --git a/lib/copy-examples.js b/lib/copy-examples.js old mode 100644 new mode 100755 diff --git a/lib/core/Prism.js b/lib/core/Prism.js index 64940726ff..24743a082d 100644 --- a/lib/core/Prism.js +++ b/lib/core/Prism.js @@ -18,17 +18,17 @@ const React = require("react"); // Private helper vars const lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; -const _ = (Prism = { +const Prism = { util: { encode(tokens) { if (tokens instanceof Token) { return new Token( tokens.type, - _.util.encode(tokens.content), + Prism.util.encode(tokens.content), tokens.alias ); - } else if (_.util.type(tokens) === "Array") { - return tokens.map(_.util.encode); + } else if (Prism.util.type(tokens) === "Array") { + return tokens.map(Prism.util.encode); } else { return tokens .replace(/&/g, "&") @@ -43,7 +43,7 @@ const _ = (Prism = { // Deep clone a language definition (e.g. to extend it) clone(o) { - const type = _.util.type(o); + const type = Prism.util.type(o); switch (type) { case "Object": @@ -51,7 +51,7 @@ const _ = (Prism = { for (const key in o) { if (o.hasOwnProperty(key)) { - clone[key] = _.util.clone(o[key]); + clone[key] = Prism.util.clone(o[key]); } } @@ -62,7 +62,7 @@ const _ = (Prism = { return ( o.map && o.map(v => { - return _.util.clone(v); + return Prism.util.clone(v); }) ); } @@ -73,7 +73,7 @@ const _ = (Prism = { languages: { extend(id, redef) { - const lang = _.util.clone(_.languages[id]); + const lang = Prism.util.clone(Prism.languages[id]); for (const key in redef) { lang[key] = redef[key]; @@ -92,7 +92,7 @@ const _ = (Prism = { * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted. */ insertBefore(inside, before, insert, root) { - root = root || _.languages; + root = root || Prism.languages; const grammar = root[inside]; if (arguments.length == 2) { @@ -124,7 +124,7 @@ const _ = (Prism = { } // Update references in other language definitions - _.languages.DFS(_.languages, function(key, value) { + Prism.languages.DFS(Prism.languages, function(key, value) { if (value === root[inside] && key != inside) { this[key] = ret; } @@ -139,10 +139,10 @@ const _ = (Prism = { if (o.hasOwnProperty(i)) { callback.call(o, i, o[i], type || i); - if (_.util.type(o[i]) === "Object") { - _.languages.DFS(o[i], callback); - } else if (_.util.type(o[i]) === "Array") { - _.languages.DFS(o[i], callback, i); + if (Prism.util.type(o[i]) === "Object") { + Prism.languages.DFS(o[i], callback); + } else if (Prism.util.type(o[i]) === "Array") { + Prism.languages.DFS(o[i], callback, i); } } } @@ -155,7 +155,7 @@ const _ = (Prism = { ); for (let i = 0, element; (element = elements[i++]); ) { - _.highlightElement(element, async === true, callback); + Prism.highlightElement(element, async === true, callback); } }, @@ -171,7 +171,7 @@ const _ = (Prism = { if (parent) { language = (parent.className.match(lang) || [, ""])[1]; - grammar = _.languages[language]; + grammar = Prism.languages[language]; } // Set language on the element, if not present @@ -209,20 +209,20 @@ const _ = (Prism = { code }; - _.hooks.run("before-highlight", env); + Prism.hooks.run("before-highlight", env); - if (async && _self.Worker) { - const worker = new Worker(_.filename); + if (async && Prismself.Worker) { + const worker = new Worker(Prism.filename); worker.onmessage = function(evt) { env.highlightedCode = Token.stringify(JSON.parse(evt.data), language); - _.hooks.run("before-insert", env); + Prism.hooks.run("before-insert", env); env.element.innerHTML = env.highlightedCode; callback && callback.call(env.element); - _.hooks.run("after-highlight", env); + Prism.hooks.run("after-highlight", env); }; worker.postMessage( @@ -232,25 +232,25 @@ const _ = (Prism = { }) ); } else { - env.highlightedCode = _.highlight(env.code, env.grammar, env.language); + env.highlightedCode = Prism.highlight(env.code, env.grammar, env.language); - _.hooks.run("before-insert", env); + Prism.hooks.run("before-insert", env); env.element.innerHTML = env.highlightedCode; callback && callback.call(element); - _.hooks.run("after-highlight", env); + Prism.hooks.run("after-highlight", env); } }, highlight(text, grammar, language) { - const tokens = _.tokenize(text, grammar); - return Token.stringify(_.util.encode(tokens), language); + const tokens = Prism.tokenize(text, grammar); + return Token.stringify(Prism.util.encode(tokens), language); }, tokenize(text, grammar, language) { - const Token = _.Token; + const Token = Prism.Token; const strarr = [text]; @@ -270,7 +270,7 @@ const _ = (Prism = { } let patterns = grammar[token]; - patterns = _.util.type(patterns) === "Array" ? patterns : [patterns]; + patterns = Prism.util.type(patterns) === "Array" ? patterns : [patterns]; for (let j = 0; j < patterns.length; ++j) { let pattern = patterns[j], @@ -319,7 +319,7 @@ const _ = (Prism = { const wrapped = new Token( token, - inside ? _.tokenize(match, inside) : match, + inside ? Prism.tokenize(match, inside) : match, alias ); @@ -342,7 +342,7 @@ const _ = (Prism = { all: {}, add(name, callback) { - const hooks = _.hooks.all; + const hooks = Prism.hooks.all; hooks[name] = hooks[name] || []; @@ -350,7 +350,7 @@ const _ = (Prism = { }, run(name, env) { - const callbacks = _.hooks.all[name]; + const callbacks = Prism.hooks.all[name]; if (!callbacks || !callbacks.length) { return; @@ -361,9 +361,9 @@ const _ = (Prism = { } } } -}); +}; -const Token = (_.Token = function(type, content, alias) { +const Token = (Prism.Token = function(type, content, alias) { this.type = type; this.content = content; this.alias = alias; @@ -374,7 +374,7 @@ Token.reactify = function(o, language, parent, key) { return o; } - if (_.util.type(o) === "Array") { + if (Prism.util.type(o) === "Array") { return o.map((element, i) => { return Token.reactify(element, language, o, i); }); @@ -395,11 +395,11 @@ Token.reactify = function(o, language, parent, key) { } if (o.alias) { - const aliases = _.util.type(o.alias) === "Array" ? o.alias : [o.alias]; + const aliases = Prism.util.type(o.alias) === "Array" ? o.alias : [o.alias]; Array.prototype.push.apply(env.classes, aliases); } - _.hooks.run("wrap", env); + Prism.hooks.run("wrap", env); env.attributes.className = env.classes.join(" "); @@ -1100,7 +1100,7 @@ Prism.languages.yaml = { const PrismComponent = React.createClass({ statics: { - _ + Prism }, getDefaultProps() { return { @@ -1123,10 +1123,10 @@ const PrismComponent = React.createClass({ } }); } - const grammar = _.languages[this.props.language]; + const grammar = Prism.languages[this.props.language]; return (
- {Token.reactify(_.tokenize(this.props.children, grammar))} + {Token.reactify(Prism.tokenize(this.props.children, grammar))} {lines.map((line, ii) => { return (