Skip to content

Commit

Permalink
Merge branch 'gh-pages' into prism-keep-markup
Browse files Browse the repository at this point in the history
Conflicts:
	components.js
  • Loading branch information
Golmote committed Sep 22, 2015
2 parents aec312b + ed4ccfe commit 391b440
Show file tree
Hide file tree
Showing 17 changed files with 369 additions and 23 deletions.
5 changes: 5 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ var components = {
"require": "previewer-base",
"owner": "Golmote"
},
"autoloader": {
"title": "Autoloader",
"owner": "Golmote",
"noCSS": true
},
"keep-markup": {
"title": "Keep Markup",
"owner": "Golmote",
Expand Down
2 changes: 1 addition & 1 deletion components/prism-clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Prism.languages.clike = {
lookbehind: true
}
],
'string': /("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
'string': /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
'class-name': {
pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
lookbehind: true,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-clike.min.js

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

3 changes: 2 additions & 1 deletion components/prism-handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
}

for (var i = 0, t; t = env.tokenStack[i]; i++) {
env.highlightedCode = env.highlightedCode.replace('___HANDLEBARS' + (i + 1) + '___', Prism.highlight(t, env.grammar, 'handlebars'));
// The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
env.highlightedCode = env.highlightedCode.replace('___HANDLEBARS' + (i + 1) + '___', Prism.highlight(t, env.grammar, 'handlebars').replace(/\$/g, '$$$$'));
}

env.element.innerHTML = env.highlightedCode;
Expand Down
2 changes: 1 addition & 1 deletion components/prism-handlebars.min.js

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

3 changes: 2 additions & 1 deletion components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ if (Prism.languages.markup) {
}

for (var i = 0, t; t = env.tokenStack[i]; i++) {
env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php'));
// The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$'));
}

env.element.innerHTML = env.highlightedCode;
Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

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

8 changes: 7 additions & 1 deletion components/prism-sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@


var variable = /((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i;
var operator = /[-+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/;
var operator = [
/[+*\/%]|[=!]=|<=?|>=?|\b(?:and|or|not)\b/,
{
pattern: /(\s+)-(?=\s)/,
lookbehind: true
}
];

Prism.languages.insertBefore('sass', 'property', {
// We want to consume the whole line
Expand Down
2 changes: 1 addition & 1 deletion components/prism-sass.min.js

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

3 changes: 2 additions & 1 deletion components/prism-smarty.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
}

for (var i = 0, t; t = env.tokenStack[i]; i++) {
env.highlightedCode = env.highlightedCode.replace('___SMARTY' + (i + 1) + '___', Prism.highlight(t, env.grammar, 'smarty'));
// The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
env.highlightedCode = env.highlightedCode.replace('___SMARTY' + (i + 1) + '___', Prism.highlight(t, env.grammar, 'smarty').replace(/\$/g, '$$$$'));
}

env.element.innerHTML = env.highlightedCode;
Expand Down
2 changes: 1 addition & 1 deletion components/prism-smarty.min.js

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

49 changes: 37 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var gulp = require('gulp'),
'plugins/file-highlight/prism-file-highlight.js'
],
plugins: ['plugins/**/*.js', '!plugins/**/*.min.js'],
showLanguagePlugin: 'plugins/show-language/prism-show-language.js'
showLanguagePlugin: 'plugins/show-language/prism-show-language.js',
autoloaderPlugin: 'plugins/autoloader/prism-autoloader.js'
};

gulp.task('components', function() {
Expand All @@ -37,7 +38,7 @@ gulp.task('build', function() {
.pipe(gulp.dest('./'));
});

gulp.task('plugins', ['show-language-plugin'], function() {
gulp.task('plugins', ['languages-plugins'], function() {
return gulp.src(paths.plugins)
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
Expand All @@ -49,7 +50,7 @@ gulp.task('watch', function() {
gulp.watch(paths.plugins, ['plugins', 'build']);
});

gulp.task('show-language-plugin', function (cb) {
gulp.task('languages-plugins', function (cb) {
fs.readFile(paths.componentsFile, {
encoding: 'utf-8'
}, function (err, data) {
Expand All @@ -59,25 +60,49 @@ gulp.task('show-language-plugin', function (cb) {
data = JSON.parse(data);

var languagesMap = {};
var dependenciesMap = {};
for (var p in data.languages) {
if (p !== 'meta') {
var title = data.languages[p].displayTitle || data.languages[p].title;
var ucfirst = p.substring(0, 1).toUpperCase() + p.substring(1);
if (title !== ucfirst) {
languagesMap[p] = title;
}

if(data.languages[p].require) {
dependenciesMap[p] = data.languages[p].require;
}
}
}

var jsonLanguages = JSON.stringify(languagesMap);
var stream = gulp.src(paths.showLanguagePlugin)
.pipe(replace(
/\/\*languages_placeholder\[\*\/[\s\S]*?\/\*\]\*\//,
'/*languages_placeholder[*/' + jsonLanguages + '/*]*/'
))
.pipe(gulp.dest(paths.showLanguagePlugin.substring(0, paths.showLanguagePlugin.lastIndexOf('/'))));
stream.on('error', cb);
stream.on('end', cb);
var jsonLanguagesMap = JSON.stringify(languagesMap);
var jsonDependenciesMap = JSON.stringify(dependenciesMap);

var tasks = [
{plugin: paths.showLanguagePlugin, map: jsonLanguagesMap},
{plugin: paths.autoloaderPlugin, map: jsonDependenciesMap}
];

var cpt = 0;
var l = tasks.length;
var done = function() {
cpt++;
if(cpt === l) {
cb && cb();
}
};

tasks.forEach(function(task) {
var stream = gulp.src(task.plugin)
.pipe(replace(
/\/\*languages_placeholder\[\*\/[\s\S]*?\/\*\]\*\//,
'/*languages_placeholder[*/' + task.map + '/*]*/'
))
.pipe(gulp.dest(task.plugin.substring(0, task.plugin.lastIndexOf('/'))));

stream.on('error', done);
stream.on('end', done);
});

} catch (e) {
cb(e);
Expand Down
Loading

0 comments on commit 391b440

Please sign in to comment.