Skip to content

Commit

Permalink
update dist
Browse files Browse the repository at this point in the history
  • Loading branch information
dealfonso committed Sep 5, 2023
1 parent 9c022b1 commit 94c1089
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
29 changes: 21 additions & 8 deletions dist/showsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
hidePlugin: true,
removeAttributes: null,
class: "showsource",
tagLengthLimit: 100,
maxAttributesInRow: 3,
separateElements: "data-*"
tagLineBreak: null,
maxAttributesPerLine: null,
separateElements: null
};
function beautify(el, userOptions = {}, indent = "") {
let elOptions = {};
Expand All @@ -57,14 +57,26 @@
if (el.dataset.showsourceHidePlugin !== undefined) {
elOptions.hidePlugin = el.dataset.showsourceHidePlugin.toLowerCase() != "false";
}
let options = Object.assign({}, defaultOptions, elOptions, userOptions);
if (el.dataset.showsourceTagLineBreak != undefined) {
elOptions.tagLineBreak = parseInt(el.dataset.showsourceTagLineBreak);
}
if (el.dataset.showsourceMaxAttributesPerLine != undefined) {
elOptions.maxAttributesPerLine = parseInt(el.dataset.showsourceMaxAttributesPerLine);
}
if (el.dataset.showsourceSeparateElements != undefined) {
elOptions.separateElements = el.dataset.showsourceSeparateElements;
}
let options = Object.assign({}, defaultOptions, window.showsource.defaults, elOptions, userOptions);
if (options.skip) {
return [];
}
el = el.cloneNode(true);
let childOptions = Object.assign({}, userOptions, {
indentation: options.indentation,
hidePlugin: options.hidePlugin
hidePlugin: options.hidePlugin,
tagLineBreak: options.tagLineBreak,
maxAttributesPerLine: options.maxAttributesPerLine,
separateElements: options.separateElements
});
if (typeof options.remove === "string") {
let elementsRemove = options.remove.split(" ").join(",");
Expand Down Expand Up @@ -122,12 +134,12 @@
separatingRegex = null;
continue;
}
if (attributesInRow >= options.maxAttributesInRow) {
if (options.maxAttributesPerLine !== null && attributesInRow >= options.maxAttributesPerLine) {
beautifulElement.push(" " + indent + attributeString);
attributesInRow = 1;
continue;
}
if (attributeString.length + beautifulElement[beautifulElement.length - 1].length > options.tagLengthLimit) {
if (options.tagLineBreak !== null && attributeString.length + beautifulElement[beautifulElement.length - 1].length > options.tagLineBreak) {
beautifulElement.push(" " + indent + attributeString);
attributesInRow = 1;
continue;
Expand Down Expand Up @@ -214,8 +226,9 @@
});
}
window.showsource = {
defaults: Object.assign({}, defaultOptions),
beautify: beautify,
init: init,
version: "1.1.0"
version: "1.1.1"
};
})(window, document);
2 changes: 1 addition & 1 deletion dist/showsource.min.js

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

0 comments on commit 94c1089

Please sign in to comment.