Skip to content

Commit

Permalink
Release: 1.10.1-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Jul 17, 2019
1 parent 481a9ac commit 2dc62c6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 21 deletions.
37 changes: 28 additions & 9 deletions js/lib/beautifier.js

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

2 changes: 1 addition & 1 deletion js/lib/beautifier.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/lib/beautifier.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/lib/beautifier.min.js.map

Large diffs are not rendered by default.

37 changes: 28 additions & 9 deletions js/lib/beautify-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2837,7 +2837,7 @@ var Tokenizer = function(input_string, options) {
handlebars_open: pattern_reader.until(/[\n\r\t }]/),
handlebars_raw_close: pattern_reader.until(/}}/),
comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
cdata: pattern_reader.starting_with(/<!\[CDATA\[/).until_after(/]]>/),
// https://en.wikipedia.org/wiki/Conditional_comment
conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
Expand Down Expand Up @@ -2891,24 +2891,24 @@ Tokenizer.prototype._get_next_token = function(previous_token, open_token) { //
token = token || this._read_raw_content(c, previous_token, open_token);
token = token || this._read_close(c, open_token);
token = token || this._read_content_word(c);
token = token || this._read_comment(c);
token = token || this._read_comment_or_cdata(c);
token = token || this._read_processing(c);
token = token || this._read_open(c, open_token);
token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());

return token;
};

Tokenizer.prototype._read_comment = function(c) { // jshint unused:false
Tokenizer.prototype._read_comment_or_cdata = function(c) { // jshint unused:false
var token = null;
var resulting_string = null;
var directives = null;

if (c === '<') {
var peek1 = this._input.peek(1);
//if we're in a comment, do something special
// We treat all comments as literals, even more than preformatted tags
// we just look for the appropriate close tag
if (c === '<' && (peek1 === '!' || peek1 === '?')) {
// we only look for the appropriate closing marker
if (peek1 === '!') {
resulting_string = this.__patterns.comment.read();

// only process directive on html comments
Expand All @@ -2919,8 +2919,6 @@ Tokenizer.prototype._read_comment = function(c) { // jshint unused:false
}
} else {
resulting_string = this.__patterns.cdata.read();
resulting_string = resulting_string || this.__patterns.conditional_comment.read();
resulting_string = resulting_string || this.__patterns.processing.read();
}
}

Expand All @@ -2933,6 +2931,27 @@ Tokenizer.prototype._read_comment = function(c) { // jshint unused:false
return token;
};

Tokenizer.prototype._read_processing = function(c) { // jshint unused:false
var token = null;
var resulting_string = null;
var directives = null;

if (c === '<') {
var peek1 = this._input.peek(1);
if (peek1 === '!' || peek1 === '?') {
resulting_string = this.__patterns.conditional_comment.read();
resulting_string = resulting_string || this.__patterns.processing.read();
}

if (resulting_string) {
token = this._create_token(TOKEN.COMMENT, resulting_string);
token.directives = directives;
}
}

return token;
};

Tokenizer.prototype._read_open = function(c, open_token) {
var resulting_string = null;
var token = null;
Expand Down Expand Up @@ -3038,7 +3057,7 @@ Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token)
if (tag_name === 'script' || tag_name === 'style') {
// Script and style tags are allowed to have comments wrapping their content
// or just have regular content.
var token = this._read_comment(c);
var token = this._read_comment_or_cdata(c);
if (token) {
token.type = TOKEN.TEXT;
return token;
Expand Down

0 comments on commit 2dc62c6

Please sign in to comment.