Skip to content

Commit

Permalink
Merge 02df8ed into 85c2713
Browse files Browse the repository at this point in the history
  • Loading branch information
cfischer committed May 17, 2016
2 parents 85c2713 + 02df8ed commit 4915400
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions js/lib/beautify-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
0;
indent_handlebars = (options.indent_handlebars === undefined) ? false : options.indent_handlebars;
wrap_attributes = (options.wrap_attributes === undefined) ? 'auto' : options.wrap_attributes;
wrap_attributes_indent_size = (isNaN(parseInt(options.wrap_attributes_indent_size, 10))) ? indent_size : parseInt(options.wrap_attributes_indent_size, 10);
wrap_attributes_indent_size = options.wrap_attributes_indent_size ? options.wrap_attributes_indent_size : indent_size;
reformat_unformatted_tags = options.reformat_unformatted_tags ? options.reformat_unformatted_tags : false;
end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline;
extra_liners = (typeof options.extra_liners === 'object') && options.extra_liners ?
options.extra_liners.concat() : (typeof options.extra_liners === 'string') ?
Expand Down Expand Up @@ -347,6 +348,16 @@
this.indent_level = this.tags[tag + this.tags[tag + 'count']];
}
};

this.get_indent_to_align_with_tag = function(arr) {
var indention = 0;
for (var i = 0; i < arr.length; i++) {
indention++;
if (arr[i] === ' ') {
return indention;
}
}
};

this.get_tag = function(peek) { //function to get a full tag and parse its type
var input_char = '',
Expand Down Expand Up @@ -399,8 +410,12 @@
indentAttrs = true;
}
if (indentAttrs) {
var indent_attr_size = wrap_attributes_indent_size;
if (wrap_attributes_indent_size === 'align') {
indent_attr_size = this.get_indent_to_align_with_tag(content);
}
//indent attributes an auto or forced line-wrap
for (var count = 0; count < wrap_attributes_indent_size; count++) {
for (var count = 0; count < indent_attr_size; count++) {
content.push(indent_character);
}
}
Expand Down Expand Up @@ -491,7 +506,7 @@
this.indent_content = true;
this.traverse_whitespace();
}
} else if (this.is_unformatted(tag_check, unformatted)) { // do not reformat the "unformatted" tags
} else if (this.is_unformatted(tag_check, unformatted) && !reformat_unformatted_tags) { // do not reformat the "unformatted" tags
comment = this.get_unformatted('</' + tag_check + '>', tag_complete); //...delegate to get_unformatted function
content.push(comment);
tag_end = this.pos - 1;
Expand Down

0 comments on commit 4915400

Please sign in to comment.