Skip to content

Commit

Permalink
Merge branch 'autoloader-path1' of https://github.com/bazooka07/prism
Browse files Browse the repository at this point in the history
…into bazooka07-autoloader-path1

# Conflicts:
#	plugins/autoloader/prism-autoloader.min.js
  • Loading branch information
Golmote committed Dec 7, 2017
2 parents 05cc391 + e66de38 commit 39360d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@

var ignored_language = 'none';

var script = document.getElementsByTagName('script');
script = script[script.length - 1];
var languages_path = 'components/';
if(script.hasAttribute('data-autoloader-path')) {
var path = script.getAttribute('data-autoloader-path').trim();
if(path.length > 0 && !/^[a-z]+:\/\//i.test(script.src)) {
languages_path = path.replace(/\/?$/, '/');
}
} else if (/[\w-]+\.js$/.test(script.src)) {
languages_path = script.src.replace(/[\w-]+\.js$/, 'components/');
}
var config = Prism.plugins.autoloader = {
languages_path: 'components/',
languages_path: languages_path,
use_minified: true
};

Expand Down Expand Up @@ -195,4 +206,4 @@
}
});

}());
}());
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

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

0 comments on commit 39360d6

Please sign in to comment.