From 18ea76d900416e9629c7a2dbc87d13e67dea8f4b Mon Sep 17 00:00:00 2001 From: mAAdhaTTah Date: Sat, 30 Jan 2016 15:00:55 -0500 Subject: [PATCH] Remove all the files from the bundle The show invisibles plugin needs to be handled differently. A PR is open upstream to resolve this issue: https://github.com/PrismJS/prism/pull/874 --- src/js/prism/compiled.js | 52 ---------------------------------------- src/js/web.js | 19 ++++++++++++++- 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/src/js/prism/compiled.js b/src/js/prism/compiled.js index ef9513011..6dc6be131 100644 --- a/src/js/prism/compiled.js +++ b/src/js/prism/compiled.js @@ -1,55 +1,3 @@ -var Prism = require('prismjs/components/prism-core'); -require('prismjs/components/prism-markup'); -require('prismjs/components/prism-css'); -require('prismjs/components/prism-clike'); -require('prismjs/components/prism-javascript'); -require('prismjs/components/prism-php'); -require('prismjs/components/prism-bash'); -require('prismjs/components/prism-groovy'); -require('prismjs/components/prism-java'); -require('prismjs/components/prism-python'); -require('prismjs/components/prism-ruby'); -require('prismjs/components/prism-scala'); -require('prismjs/components/prism-scss'); -require('prismjs/components/prism-sql'); -// New languages - v0.3.0 -require('prismjs/components/prism-c'); -require('prismjs/components/prism-coffeescript'); -require('prismjs/components/prism-csharp'); -require('prismjs/components/prism-go'); -require('prismjs/components/prism-http'); -require('prismjs/components/prism-ini'); -require('prismjs/components/prism-markup'); -require('prismjs/components/prism-objectivec'); -require('prismjs/components/prism-swift'); -require('prismjs/components/prism-twig'); -// New languages - v0.5.0 -require('prismjs/components/prism-actionscript'); -require('prismjs/components/prism-applescript'); -require('prismjs/components/prism-dart'); -require('prismjs/components/prism-eiffel'); -require('prismjs/components/prism-erlang'); -require('prismjs/components/prism-gherkin'); -require('prismjs/components/prism-git'); -require('prismjs/components/prism-haml'); -require('prismjs/components/prism-handlebars'); -require('prismjs/components/prism-jade'); -require('prismjs/components/prism-latex'); -require('prismjs/components/prism-less'); -require('prismjs/components/prism-markdown'); -require('prismjs/components/prism-matlab'); -require('prismjs/components/prism-nasm'); -require('prismjs/components/prism-perl'); -require('prismjs/components/prism-powershell'); -require('prismjs/components/prism-r'); -require('prismjs/components/prism-rust'); -require('prismjs/components/prism-scheme'); -require('prismjs/components/prism-smarty'); -// Plugins -require('prismjs/plugins/line-highlight/prism-line-highlight'); -require('prismjs/plugins/line-numbers/prism-line-numbers'); -require('prismjs/plugins/show-invisibles/prism-show-invisibles'); -document.removeEventListener('DOMContentLoaded', Prism.highlightAll); module.exports = Prism; diff --git a/src/js/web.js b/src/js/web.js index ba9bb1b15..3d28e5aa4 100644 --- a/src/js/web.js +++ b/src/js/web.js @@ -16,11 +16,28 @@ promises.push(Prism.loadTheme(Gistpen_Settings.prism.theme)); forOwn(Gistpen_Settings.prism.plugins, function(props, plugin) { if (props.enabled) { promises.push(Prism.loadPlugin(plugin)); + if ('show-invisibles' === plugin) { + showInvisibles = true; + } } }); Plite.all(promises) - .then(Prism.highlightAll) + .then(function() { + if (showInvisibles) { + // @todo https://github.com/PrismJS/prism/pull/874 + Prism.hooks.add('before-highlight', function(env) { + var tokens = env.grammar; + + tokens.tab = /\t/g; + tokens.crlf = /\r\n/g; + tokens.lf = /\n/g; + tokens.cr = /\r/g; + }); + } + + Prism.highlightAll(); + }) .catch(function(err) { console.error(err); });