diff --git a/dist/diff2html-ui.js b/dist/diff2html-ui.js
index bd2aba3..b5ea749 100644
--- a/dist/diff2html-ui.js
+++ b/dist/diff2html-ui.js
@@ -105,21 +105,16 @@
Diff2HtmlUI.prototype.highlightCode = function(targetId) {
var that = this;
- // collect all the file extensions in the json
- var allFileLanguages = diffJson.map(function(line) {
- return line.language;
- });
+ var $target = that._getTarget(targetId);
- // remove duplicated languages
- var distinctLanguages = allFileLanguages.filter(function(v, i) {
- return allFileLanguages.indexOf(v) === i;
- });
+ var languages = that._getLanguages($target);
+
+ console.log(languages);
// pass the languages to the highlightjs plugin
- hljs.configure({languages: distinctLanguages});
+ hljs.configure({languages: languages});
// collect all the code lines and execute the highlight on them
- var $target = that._getTarget(targetId);
var $codeLines = $target.find(".d2h-code-line-ctn");
$codeLines.map(function(i, line) {
hljs.highlightBlock(line);
@@ -137,6 +132,29 @@
return $target;
};
+ Diff2HtmlUI.prototype._getLanguages = function($target) {
+ var allFileLanguages = [];
+
+ if (diffJson) {
+ // collect all the file extensions in the json
+ allFileLanguages = diffJson.map(function(line) {
+ return line.language;
+ });
+ } else {
+ console.log($target.find(".d2h-file-wrapper"));
+ $target.find(".d2h-file-wrapper").map(function(i, file) {
+ allFileLanguages.push($(file).data("lang"));
+ });
+ }
+
+ // remove duplicated languages
+ var distinctLanguages = allFileLanguages.filter(function(v, i) {
+ return allFileLanguages.indexOf(v) === i;
+ });
+
+ return distinctLanguages;
+ };
+
module.exports.Diff2HtmlUI = Diff2HtmlUI;
// Expose diff2html in the browser
diff --git a/dist/diff2html-ui.min.js b/dist/diff2html-ui.min.js
index b1548d8..7b5adfe 100644
--- a/dist/diff2html-ui.min.js
+++ b/dist/diff2html-ui.min.js
@@ -1 +1 @@
-!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports){(function(global){!function(){function Diff2HtmlUI(config){var cfg=config||{};cfg.diff?diffJson=Diff2Html.getJsonFromDiff(cfg.diff):cfg.json&&(diffJson=cfg.json)}var diffJson=null,defaultTarget="body";Diff2HtmlUI.prototype.draw=function(targetId,config){var cfg=config||{},$target=this._getTarget(targetId);$target.html(Diff2Html.getPrettyHtml(diffJson,cfg))},Diff2HtmlUI.prototype.fileListCloseable=function(targetId,startVisible){function show(){$showBtn.hide(),$hideBtn.show(),$fileList.show()}function hide(){$hideBtn.hide(),$showBtn.show(),$fileList.hide()}var $target=this._getTarget(targetId),$showBtn=$target.find(".d2h-show"),$hideBtn=$target.find(".d2h-hide"),$fileList=$target.find(".d2h-file-list");startVisible?show():hide(),$showBtn.click(show),$hideBtn.click(hide)},Diff2HtmlUI.prototype.highlightCode=function(targetId){var that=this,allFileLanguages=diffJson.map(function(line){return line.language}),distinctLanguages=allFileLanguages.filter(function(v,i){return allFileLanguages.indexOf(v)===i});hljs.configure({languages:distinctLanguages});var $target=that._getTarget(targetId),$codeLines=$target.find(".d2h-code-line-ctn");$codeLines.map(function(i,line){hljs.highlightBlock(line)})},Diff2HtmlUI.prototype._getTarget=function(targetId){var $target;return $target=$(targetId?targetId:defaultTarget)},module.exports.Diff2HtmlUI=Diff2HtmlUI,global.Diff2HtmlUI=Diff2HtmlUI}()}).call(exports,function(){return this}())}]);
\ No newline at end of file
+!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports){(function(global){!function(){function Diff2HtmlUI(config){var cfg=config||{};cfg.diff?diffJson=Diff2Html.getJsonFromDiff(cfg.diff):cfg.json&&(diffJson=cfg.json)}var diffJson=null,defaultTarget="body";Diff2HtmlUI.prototype.draw=function(targetId,config){var cfg=config||{},$target=this._getTarget(targetId);$target.html(Diff2Html.getPrettyHtml(diffJson,cfg))},Diff2HtmlUI.prototype.fileListCloseable=function(targetId,startVisible){function show(){$showBtn.hide(),$hideBtn.show(),$fileList.show()}function hide(){$hideBtn.hide(),$showBtn.show(),$fileList.hide()}var $target=this._getTarget(targetId),$showBtn=$target.find(".d2h-show"),$hideBtn=$target.find(".d2h-hide"),$fileList=$target.find(".d2h-file-list");startVisible?show():hide(),$showBtn.click(show),$hideBtn.click(hide)},Diff2HtmlUI.prototype.highlightCode=function(targetId){var that=this,$target=that._getTarget(targetId),languages=that._getLanguages($target);console.log(languages),hljs.configure({languages:languages});var $codeLines=$target.find(".d2h-code-line-ctn");$codeLines.map(function(i,line){hljs.highlightBlock(line)})},Diff2HtmlUI.prototype._getTarget=function(targetId){var $target;return $target=$(targetId?targetId:defaultTarget)},Diff2HtmlUI.prototype._getLanguages=function($target){var allFileLanguages=[];diffJson?allFileLanguages=diffJson.map(function(line){return line.language}):(console.log($target.find(".d2h-file-wrapper")),$target.find(".d2h-file-wrapper").map(function(i,file){allFileLanguages.push($(file).data("lang"))}));var distinctLanguages=allFileLanguages.filter(function(v,i){return allFileLanguages.indexOf(v)===i});return distinctLanguages},module.exports.Diff2HtmlUI=Diff2HtmlUI,global.Diff2HtmlUI=Diff2HtmlUI}()}).call(exports,function(){return this}())}]);
\ No newline at end of file
diff --git a/package.json b/package.json
index 5845f0d..8073fc4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "diff2html",
- "version": "1.3.0",
+ "version": "1.3.1",
"homepage": "http://rtfpessoa.github.io/diff2html/",
"description": "Fast Diff to colorized HTML",
"keywords": [
@@ -58,6 +58,6 @@
"license": "MIT",
"files": [
"src",
- "css"
+ "dist"
]
}
diff --git a/src/ui/js/diff2html-ui.js b/src/ui/js/diff2html-ui.js
index 6e1cec4..856a9e6 100644
--- a/src/ui/js/diff2html-ui.js
+++ b/src/ui/js/diff2html-ui.js
@@ -59,21 +59,16 @@
Diff2HtmlUI.prototype.highlightCode = function(targetId) {
var that = this;
- // collect all the file extensions in the json
- var allFileLanguages = diffJson.map(function(line) {
- return line.language;
- });
+ var $target = that._getTarget(targetId);
- // remove duplicated languages
- var distinctLanguages = allFileLanguages.filter(function(v, i) {
- return allFileLanguages.indexOf(v) === i;
- });
+ var languages = that._getLanguages($target);
+
+ console.log(languages);
// pass the languages to the highlightjs plugin
- hljs.configure({languages: distinctLanguages});
+ hljs.configure({languages: languages});
// collect all the code lines and execute the highlight on them
- var $target = that._getTarget(targetId);
var $codeLines = $target.find(".d2h-code-line-ctn");
$codeLines.map(function(i, line) {
hljs.highlightBlock(line);
@@ -91,6 +86,29 @@
return $target;
};
+ Diff2HtmlUI.prototype._getLanguages = function($target) {
+ var allFileLanguages = [];
+
+ if (diffJson) {
+ // collect all the file extensions in the json
+ allFileLanguages = diffJson.map(function(line) {
+ return line.language;
+ });
+ } else {
+ console.log($target.find(".d2h-file-wrapper"));
+ $target.find(".d2h-file-wrapper").map(function(i, file) {
+ allFileLanguages.push($(file).data("lang"));
+ });
+ }
+
+ // remove duplicated languages
+ var distinctLanguages = allFileLanguages.filter(function(v, i) {
+ return allFileLanguages.indexOf(v) === i;
+ });
+
+ return distinctLanguages;
+ };
+
module.exports.Diff2HtmlUI = Diff2HtmlUI;
// Expose diff2html in the browser