2022-01-21 08:28:41 +00:00
/* AUTO-GENERATED. DO NOT MODIFY. */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
Style HTML
-- -- -- -- -- -- -- -
Written by Nochum Sossonko , ( nsossonko @ hotmail . com )
Based on code initially developed by : Einar Lielmanis , < einar @ beautifier . io >
https : //beautifier.io/
Usage :
style _html ( html _source ) ;
style _html ( html _source , options ) ;
The options are :
indent _inner _html ( default false ) — indent < head > and < body > sections ,
indent _size ( default 4 ) — indentation size ,
indent _char ( default space ) — character to indent with ,
wrap _line _length ( default 250 ) - maximum amount of characters per line ( 0 = disable )
brace _style ( default "collapse" ) - "collapse" | "expand" | "end-expand" | "none"
put braces on the same line as control statements ( default ) , or put braces on own line ( Allman / ANSI style ) , or just put end braces on own line , or attempt to keep them where they are .
inline ( defaults to inline tags ) - list of tags to be considered inline tags
unformatted ( defaults to inline tags ) - list of tags , that shouldn ' t be reformatted
content _unformatted ( defaults to [ "pre" , "textarea" ] tags ) - list of tags , whose content shouldn ' t be reformatted
indent _scripts ( default normal ) - "keep" | "separate" | "normal"
preserve _newlines ( default true ) - whether existing line breaks before elements should be preserved
Only works before elements , not inside tags or for text .
max _preserve _newlines ( default unlimited ) - maximum number of line breaks to be preserved in one chunk
indent _handlebars ( default false ) - format and indent { { # foo } } and { { / f o o } }
end _with _newline ( false ) - end with a newline
extra _liners ( default [ head , body , / h t m l ] ) - L i s t o f t a g s t h a t s h o u l d h a v e a n e x t r a n e w l i n e b e f o r e t h e m .
e . g .
style _html ( html _source , {
'indent_inner_html' : false ,
'indent_size' : 2 ,
'indent_char' : ' ' ,
'wrap_line_length' : 78 ,
'brace_style' : 'expand' ,
'preserve_newlines' : true ,
'max_preserve_newlines' : 5 ,
'indent_handlebars' : false ,
'extra_liners' : [ '/html' ]
} ) ;
* /
( function ( ) {
/* GENERATED_BUILD_OUTPUT */
var legacy _beautify _html ;
/******/ ( function ( ) { // webpackBootstrap
/******/ "use strict" ;
/******/ var _ _webpack _modules _ _ = ( [
/* 0 */ ,
/* 1 */ ,
/* 2 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function OutputLine ( parent ) {
this . _ _parent = parent ;
this . _ _character _count = 0 ;
// use indent_count as a marker for this.__lines that have preserved indentation
this . _ _indent _count = - 1 ;
this . _ _alignment _count = 0 ;
this . _ _wrap _point _index = 0 ;
this . _ _wrap _point _character _count = 0 ;
this . _ _wrap _point _indent _count = - 1 ;
this . _ _wrap _point _alignment _count = 0 ;
this . _ _items = [ ] ;
}
OutputLine . prototype . clone _empty = function ( ) {
var line = new OutputLine ( this . _ _parent ) ;
line . set _indent ( this . _ _indent _count , this . _ _alignment _count ) ;
return line ;
} ;
OutputLine . prototype . item = function ( index ) {
if ( index < 0 ) {
return this . _ _items [ this . _ _items . length + index ] ;
} else {
return this . _ _items [ index ] ;
}
} ;
OutputLine . prototype . has _match = function ( pattern ) {
for ( var lastCheckedOutput = this . _ _items . length - 1 ; lastCheckedOutput >= 0 ; lastCheckedOutput -- ) {
if ( this . _ _items [ lastCheckedOutput ] . match ( pattern ) ) {
return true ;
}
}
return false ;
} ;
OutputLine . prototype . set _indent = function ( indent , alignment ) {
if ( this . is _empty ( ) ) {
this . _ _indent _count = indent || 0 ;
this . _ _alignment _count = alignment || 0 ;
this . _ _character _count = this . _ _parent . get _indent _size ( this . _ _indent _count , this . _ _alignment _count ) ;
}
} ;
OutputLine . prototype . _set _wrap _point = function ( ) {
if ( this . _ _parent . wrap _line _length ) {
this . _ _wrap _point _index = this . _ _items . length ;
this . _ _wrap _point _character _count = this . _ _character _count ;
this . _ _wrap _point _indent _count = this . _ _parent . next _line . _ _indent _count ;
this . _ _wrap _point _alignment _count = this . _ _parent . next _line . _ _alignment _count ;
}
} ;
OutputLine . prototype . _should _wrap = function ( ) {
return this . _ _wrap _point _index &&
this . _ _character _count > this . _ _parent . wrap _line _length &&
this . _ _wrap _point _character _count > this . _ _parent . next _line . _ _character _count ;
} ;
OutputLine . prototype . _allow _wrap = function ( ) {
if ( this . _should _wrap ( ) ) {
this . _ _parent . add _new _line ( ) ;
var next = this . _ _parent . current _line ;
next . set _indent ( this . _ _wrap _point _indent _count , this . _ _wrap _point _alignment _count ) ;
next . _ _items = this . _ _items . slice ( this . _ _wrap _point _index ) ;
this . _ _items = this . _ _items . slice ( 0 , this . _ _wrap _point _index ) ;
next . _ _character _count += this . _ _character _count - this . _ _wrap _point _character _count ;
this . _ _character _count = this . _ _wrap _point _character _count ;
if ( next . _ _items [ 0 ] === " " ) {
next . _ _items . splice ( 0 , 1 ) ;
next . _ _character _count -= 1 ;
}
return true ;
}
return false ;
} ;
OutputLine . prototype . is _empty = function ( ) {
return this . _ _items . length === 0 ;
} ;
OutputLine . prototype . last = function ( ) {
if ( ! this . is _empty ( ) ) {
return this . _ _items [ this . _ _items . length - 1 ] ;
} else {
return null ;
}
} ;
OutputLine . prototype . push = function ( item ) {
this . _ _items . push ( item ) ;
var last _newline _index = item . lastIndexOf ( '\n' ) ;
if ( last _newline _index !== - 1 ) {
this . _ _character _count = item . length - last _newline _index ;
} else {
this . _ _character _count += item . length ;
}
} ;
OutputLine . prototype . pop = function ( ) {
var item = null ;
if ( ! this . is _empty ( ) ) {
item = this . _ _items . pop ( ) ;
this . _ _character _count -= item . length ;
}
return item ;
} ;
OutputLine . prototype . _remove _indent = function ( ) {
if ( this . _ _indent _count > 0 ) {
this . _ _indent _count -= 1 ;
this . _ _character _count -= this . _ _parent . indent _size ;
}
} ;
OutputLine . prototype . _remove _wrap _indent = function ( ) {
if ( this . _ _wrap _point _indent _count > 0 ) {
this . _ _wrap _point _indent _count -= 1 ;
}
} ;
OutputLine . prototype . trim = function ( ) {
while ( this . last ( ) === ' ' ) {
this . _ _items . pop ( ) ;
this . _ _character _count -= 1 ;
}
} ;
OutputLine . prototype . toString = function ( ) {
var result = '' ;
if ( this . is _empty ( ) ) {
if ( this . _ _parent . indent _empty _lines ) {
result = this . _ _parent . get _indent _string ( this . _ _indent _count ) ;
}
} else {
result = this . _ _parent . get _indent _string ( this . _ _indent _count , this . _ _alignment _count ) ;
result += this . _ _items . join ( '' ) ;
}
return result ;
} ;
function IndentStringCache ( options , baseIndentString ) {
this . _ _cache = [ '' ] ;
this . _ _indent _size = options . indent _size ;
this . _ _indent _string = options . indent _char ;
if ( ! options . indent _with _tabs ) {
this . _ _indent _string = new Array ( options . indent _size + 1 ) . join ( options . indent _char ) ;
}
// Set to null to continue support for auto detection of base indent
baseIndentString = baseIndentString || '' ;
if ( options . indent _level > 0 ) {
baseIndentString = new Array ( options . indent _level + 1 ) . join ( this . _ _indent _string ) ;
}
this . _ _base _string = baseIndentString ;
this . _ _base _string _length = baseIndentString . length ;
}
IndentStringCache . prototype . get _indent _size = function ( indent , column ) {
var result = this . _ _base _string _length ;
column = column || 0 ;
if ( indent < 0 ) {
result = 0 ;
}
result += indent * this . _ _indent _size ;
result += column ;
return result ;
} ;
IndentStringCache . prototype . get _indent _string = function ( indent _level , column ) {
var result = this . _ _base _string ;
column = column || 0 ;
if ( indent _level < 0 ) {
indent _level = 0 ;
result = '' ;
}
column += indent _level * this . _ _indent _size ;
this . _ _ensure _cache ( column ) ;
result += this . _ _cache [ column ] ;
return result ;
} ;
IndentStringCache . prototype . _ _ensure _cache = function ( column ) {
while ( column >= this . _ _cache . length ) {
this . _ _add _column ( ) ;
}
} ;
IndentStringCache . prototype . _ _add _column = function ( ) {
var column = this . _ _cache . length ;
var indent = 0 ;
var result = '' ;
if ( this . _ _indent _size && column >= this . _ _indent _size ) {
indent = Math . floor ( column / this . _ _indent _size ) ;
column -= indent * this . _ _indent _size ;
result = new Array ( indent + 1 ) . join ( this . _ _indent _string ) ;
}
if ( column ) {
result += new Array ( column + 1 ) . join ( ' ' ) ;
}
this . _ _cache . push ( result ) ;
} ;
function Output ( options , baseIndentString ) {
this . _ _indent _cache = new IndentStringCache ( options , baseIndentString ) ;
this . raw = false ;
this . _end _with _newline = options . end _with _newline ;
this . indent _size = options . indent _size ;
this . wrap _line _length = options . wrap _line _length ;
this . indent _empty _lines = options . indent _empty _lines ;
this . _ _lines = [ ] ;
this . previous _line = null ;
this . current _line = null ;
this . next _line = new OutputLine ( this ) ;
this . space _before _token = false ;
this . non _breaking _space = false ;
this . previous _token _wrapped = false ;
// initialize
this . _ _add _outputline ( ) ;
}
Output . prototype . _ _add _outputline = function ( ) {
this . previous _line = this . current _line ;
this . current _line = this . next _line . clone _empty ( ) ;
this . _ _lines . push ( this . current _line ) ;
} ;
Output . prototype . get _line _number = function ( ) {
return this . _ _lines . length ;
} ;
Output . prototype . get _indent _string = function ( indent , column ) {
return this . _ _indent _cache . get _indent _string ( indent , column ) ;
} ;
Output . prototype . get _indent _size = function ( indent , column ) {
return this . _ _indent _cache . get _indent _size ( indent , column ) ;
} ;
Output . prototype . is _empty = function ( ) {
return ! this . previous _line && this . current _line . is _empty ( ) ;
} ;
Output . prototype . add _new _line = function ( force _newline ) {
// never newline at the start of file
// otherwise, newline only if we didn't just add one or we're forced
if ( this . is _empty ( ) ||
( ! force _newline && this . just _added _newline ( ) ) ) {
return false ;
}
// if raw output is enabled, don't print additional newlines,
// but still return True as though you had
if ( ! this . raw ) {
this . _ _add _outputline ( ) ;
}
return true ;
} ;
Output . prototype . get _code = function ( eol ) {
this . trim ( true ) ;
// handle some edge cases where the last tokens
// has text that ends with newline(s)
var last _item = this . current _line . pop ( ) ;
if ( last _item ) {
if ( last _item [ last _item . length - 1 ] === '\n' ) {
last _item = last _item . replace ( /\n+$/g , '' ) ;
}
this . current _line . push ( last _item ) ;
}
if ( this . _end _with _newline ) {
this . _ _add _outputline ( ) ;
}
var sweet _code = this . _ _lines . join ( '\n' ) ;
if ( eol !== '\n' ) {
sweet _code = sweet _code . replace ( /[\n]/g , eol ) ;
}
return sweet _code ;
} ;
Output . prototype . set _wrap _point = function ( ) {
this . current _line . _set _wrap _point ( ) ;
} ;
Output . prototype . set _indent = function ( indent , alignment ) {
indent = indent || 0 ;
alignment = alignment || 0 ;
// Next line stores alignment values
this . next _line . set _indent ( indent , alignment ) ;
// Never indent your first output indent at the start of the file
if ( this . _ _lines . length > 1 ) {
this . current _line . set _indent ( indent , alignment ) ;
return true ;
}
this . current _line . set _indent ( ) ;
return false ;
} ;
Output . prototype . add _raw _token = function ( token ) {
for ( var x = 0 ; x < token . newlines ; x ++ ) {
this . _ _add _outputline ( ) ;
}
this . current _line . set _indent ( - 1 ) ;
this . current _line . push ( token . whitespace _before ) ;
this . current _line . push ( token . text ) ;
this . space _before _token = false ;
this . non _breaking _space = false ;
this . previous _token _wrapped = false ;
} ;
Output . prototype . add _token = function ( printable _token ) {
this . _ _add _space _before _token ( ) ;
this . current _line . push ( printable _token ) ;
this . space _before _token = false ;
this . non _breaking _space = false ;
this . previous _token _wrapped = this . current _line . _allow _wrap ( ) ;
} ;
Output . prototype . _ _add _space _before _token = function ( ) {
if ( this . space _before _token && ! this . just _added _newline ( ) ) {
if ( ! this . non _breaking _space ) {
this . set _wrap _point ( ) ;
}
this . current _line . push ( ' ' ) ;
}
} ;
Output . prototype . remove _indent = function ( index ) {
var output _length = this . _ _lines . length ;
while ( index < output _length ) {
this . _ _lines [ index ] . _remove _indent ( ) ;
index ++ ;
}
this . current _line . _remove _wrap _indent ( ) ;
} ;
Output . prototype . trim = function ( eat _newlines ) {
eat _newlines = ( eat _newlines === undefined ) ? false : eat _newlines ;
this . current _line . trim ( ) ;
while ( eat _newlines && this . _ _lines . length > 1 &&
this . current _line . is _empty ( ) ) {
this . _ _lines . pop ( ) ;
this . current _line = this . _ _lines [ this . _ _lines . length - 1 ] ;
this . current _line . trim ( ) ;
}
this . previous _line = this . _ _lines . length > 1 ?
this . _ _lines [ this . _ _lines . length - 2 ] : null ;
} ;
Output . prototype . just _added _newline = function ( ) {
return this . current _line . is _empty ( ) ;
} ;
Output . prototype . just _added _blankline = function ( ) {
return this . is _empty ( ) ||
( this . current _line . is _empty ( ) && this . previous _line . is _empty ( ) ) ;
} ;
Output . prototype . ensure _empty _line _above = function ( starts _with , ends _with ) {
var index = this . _ _lines . length - 2 ;
while ( index >= 0 ) {
var potentialEmptyLine = this . _ _lines [ index ] ;
if ( potentialEmptyLine . is _empty ( ) ) {
break ;
} else if ( potentialEmptyLine . item ( 0 ) . indexOf ( starts _with ) !== 0 &&
potentialEmptyLine . item ( - 1 ) !== ends _with ) {
this . _ _lines . splice ( index + 1 , 0 , new OutputLine ( this ) ) ;
this . previous _line = this . _ _lines [ this . _ _lines . length - 2 ] ;
break ;
}
index -- ;
}
} ;
module . exports . Output = Output ;
/***/ } ) ,
/* 3 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Token ( type , text , newlines , whitespace _before ) {
this . type = type ;
this . text = text ;
// comments_before are
// comments that have a new line before them
// and may or may not have a newline after
// this is a set of comments before
this . comments _before = null ; /* inline comment*/
// this.comments_after = new TokenStream(); // no new line before and newline after
this . newlines = newlines || 0 ;
this . whitespace _before = whitespace _before || '' ;
this . parent = null ;
this . next = null ;
this . previous = null ;
this . opened = null ;
this . closed = null ;
this . directives = null ;
}
module . exports . Token = Token ;
/***/ } ) ,
/* 4 */ ,
/* 5 */ ,
/* 6 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Options ( options , merge _child _field ) {
this . raw _options = _mergeOpts ( options , merge _child _field ) ;
// Support passing the source text back with no change
this . disabled = this . _get _boolean ( 'disabled' ) ;
this . eol = this . _get _characters ( 'eol' , 'auto' ) ;
this . end _with _newline = this . _get _boolean ( 'end_with_newline' ) ;
this . indent _size = this . _get _number ( 'indent_size' , 4 ) ;
this . indent _char = this . _get _characters ( 'indent_char' , ' ' ) ;
this . indent _level = this . _get _number ( 'indent_level' ) ;
this . preserve _newlines = this . _get _boolean ( 'preserve_newlines' , true ) ;
this . max _preserve _newlines = this . _get _number ( 'max_preserve_newlines' , 32786 ) ;
if ( ! this . preserve _newlines ) {
this . max _preserve _newlines = 0 ;
}
this . indent _with _tabs = this . _get _boolean ( 'indent_with_tabs' , this . indent _char === '\t' ) ;
if ( this . indent _with _tabs ) {
this . indent _char = '\t' ;
// indent_size behavior changed after 1.8.6
// It used to be that indent_size would be
// set to 1 for indent_with_tabs. That is no longer needed and
// actually doesn't make sense - why not use spaces? Further,
// that might produce unexpected behavior - tabs being used
// for single-column alignment. So, when indent_with_tabs is true
// and indent_size is 1, reset indent_size to 4.
if ( this . indent _size === 1 ) {
this . indent _size = 4 ;
}
}
// Backwards compat with 1.3.x
this . wrap _line _length = this . _get _number ( 'wrap_line_length' , this . _get _number ( 'max_char' ) ) ;
this . indent _empty _lines = this . _get _boolean ( 'indent_empty_lines' ) ;
// valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty']
// For now, 'auto' = all off for javascript, all on for html (and inline javascript).
// other values ignored
this . templating = this . _get _selection _list ( 'templating' , [ 'auto' , 'none' , 'django' , 'erb' , 'handlebars' , 'php' , 'smarty' ] , [ 'auto' ] ) ;
}
Options . prototype . _get _array = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
var result = default _value || [ ] ;
if ( typeof option _value === 'object' ) {
if ( option _value !== null && typeof option _value . concat === 'function' ) {
result = option _value . concat ( ) ;
}
} else if ( typeof option _value === 'string' ) {
result = option _value . split ( /[^a-zA-Z0-9_\/\-]+/ ) ;
}
return result ;
} ;
Options . prototype . _get _boolean = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
var result = option _value === undefined ? ! ! default _value : ! ! option _value ;
return result ;
} ;
Options . prototype . _get _characters = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
var result = default _value || '' ;
if ( typeof option _value === 'string' ) {
result = option _value . replace ( /\\r/ , '\r' ) . replace ( /\\n/ , '\n' ) . replace ( /\\t/ , '\t' ) ;
}
return result ;
} ;
Options . prototype . _get _number = function ( name , default _value ) {
var option _value = this . raw _options [ name ] ;
default _value = parseInt ( default _value , 10 ) ;
if ( isNaN ( default _value ) ) {
default _value = 0 ;
}
var result = parseInt ( option _value , 10 ) ;
if ( isNaN ( result ) ) {
result = default _value ;
}
return result ;
} ;
Options . prototype . _get _selection = function ( name , selection _list , default _value ) {
var result = this . _get _selection _list ( name , selection _list , default _value ) ;
if ( result . length !== 1 ) {
throw new Error (
"Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
selection _list + "\nYou passed in: '" + this . raw _options [ name ] + "'" ) ;
}
return result [ 0 ] ;
} ;
Options . prototype . _get _selection _list = function ( name , selection _list , default _value ) {
if ( ! selection _list || selection _list . length === 0 ) {
throw new Error ( "Selection list cannot be empty." ) ;
}
default _value = default _value || [ selection _list [ 0 ] ] ;
if ( ! this . _is _valid _selection ( default _value , selection _list ) ) {
throw new Error ( "Invalid Default Value!" ) ;
}
var result = this . _get _array ( name , default _value ) ;
if ( ! this . _is _valid _selection ( result , selection _list ) ) {
throw new Error (
"Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
selection _list + "\nYou passed in: '" + this . raw _options [ name ] + "'" ) ;
}
return result ;
} ;
Options . prototype . _is _valid _selection = function ( result , selection _list ) {
return result . length && selection _list . length &&
! result . some ( function ( item ) { return selection _list . indexOf ( item ) === - 1 ; } ) ;
} ;
// merges child options up with the parent options object
// Example: obj = {a: 1, b: {a: 2}}
// mergeOpts(obj, 'b')
//
// Returns: {a: 2}
function _mergeOpts ( allOptions , childFieldName ) {
var finalOpts = { } ;
allOptions = _normalizeOpts ( allOptions ) ;
var name ;
for ( name in allOptions ) {
if ( name !== childFieldName ) {
finalOpts [ name ] = allOptions [ name ] ;
}
}
//merge in the per type settings for the childFieldName
if ( childFieldName && allOptions [ childFieldName ] ) {
for ( name in allOptions [ childFieldName ] ) {
finalOpts [ name ] = allOptions [ childFieldName ] [ name ] ;
}
}
return finalOpts ;
}
function _normalizeOpts ( options ) {
var convertedOpts = { } ;
var key ;
for ( key in options ) {
var newKey = key . replace ( /-/g , "_" ) ;
convertedOpts [ newKey ] = options [ key ] ;
}
return convertedOpts ;
}
module . exports . Options = Options ;
module . exports . normalizeOpts = _normalizeOpts ;
module . exports . mergeOpts = _mergeOpts ;
/***/ } ) ,
/* 7 */ ,
/* 8 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
var regexp _has _sticky = RegExp . prototype . hasOwnProperty ( 'sticky' ) ;
function InputScanner ( input _string ) {
this . _ _input = input _string || '' ;
this . _ _input _length = this . _ _input . length ;
this . _ _position = 0 ;
}
InputScanner . prototype . restart = function ( ) {
this . _ _position = 0 ;
} ;
InputScanner . prototype . back = function ( ) {
if ( this . _ _position > 0 ) {
this . _ _position -= 1 ;
}
} ;
InputScanner . prototype . hasNext = function ( ) {
return this . _ _position < this . _ _input _length ;
} ;
InputScanner . prototype . next = function ( ) {
var val = null ;
if ( this . hasNext ( ) ) {
val = this . _ _input . charAt ( this . _ _position ) ;
this . _ _position += 1 ;
}
return val ;
} ;
InputScanner . prototype . peek = function ( index ) {
var val = null ;
index = index || 0 ;
index += this . _ _position ;
if ( index >= 0 && index < this . _ _input _length ) {
val = this . _ _input . charAt ( index ) ;
}
return val ;
} ;
// This is a JavaScript only helper function (not in python)
// Javascript doesn't have a match method
// and not all implementation support "sticky" flag.
// If they do not support sticky then both this.match() and this.test() method
// must get the match and check the index of the match.
// If sticky is supported and set, this method will use it.
// Otherwise it will check that global is set, and fall back to the slower method.
InputScanner . prototype . _ _match = function ( pattern , index ) {
pattern . lastIndex = index ;
var pattern _match = pattern . exec ( this . _ _input ) ;
if ( pattern _match && ! ( regexp _has _sticky && pattern . sticky ) ) {
if ( pattern _match . index !== index ) {
pattern _match = null ;
}
}
return pattern _match ;
} ;
InputScanner . prototype . test = function ( pattern , index ) {
index = index || 0 ;
index += this . _ _position ;
if ( index >= 0 && index < this . _ _input _length ) {
return ! ! this . _ _match ( pattern , index ) ;
} else {
return false ;
}
} ;
InputScanner . prototype . testChar = function ( pattern , index ) {
// test one character regex match
var val = this . peek ( index ) ;
pattern . lastIndex = 0 ;
return val !== null && pattern . test ( val ) ;
} ;
InputScanner . prototype . match = function ( pattern ) {
var pattern _match = this . _ _match ( pattern , this . _ _position ) ;
if ( pattern _match ) {
this . _ _position += pattern _match [ 0 ] . length ;
} else {
pattern _match = null ;
}
return pattern _match ;
} ;
InputScanner . prototype . read = function ( starting _pattern , until _pattern , until _after ) {
var val = '' ;
var match ;
if ( starting _pattern ) {
match = this . match ( starting _pattern ) ;
if ( match ) {
val += match [ 0 ] ;
}
}
if ( until _pattern && ( match || ! starting _pattern ) ) {
val += this . readUntil ( until _pattern , until _after ) ;
}
return val ;
} ;
InputScanner . prototype . readUntil = function ( pattern , until _after ) {
var val = '' ;
var match _index = this . _ _position ;
pattern . lastIndex = this . _ _position ;
var pattern _match = pattern . exec ( this . _ _input ) ;
if ( pattern _match ) {
match _index = pattern _match . index ;
if ( until _after ) {
match _index += pattern _match [ 0 ] . length ;
}
} else {
match _index = this . _ _input _length ;
}
val = this . _ _input . substring ( this . _ _position , match _index ) ;
this . _ _position = match _index ;
return val ;
} ;
InputScanner . prototype . readUntilAfter = function ( pattern ) {
return this . readUntil ( pattern , true ) ;
} ;
InputScanner . prototype . get _regexp = function ( pattern , match _from ) {
var result = null ;
var flags = 'g' ;
if ( match _from && regexp _has _sticky ) {
flags = 'y' ;
}
// strings are converted to regexp
if ( typeof pattern === "string" && pattern !== '' ) {
// result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
result = new RegExp ( pattern , flags ) ;
} else if ( pattern ) {
result = new RegExp ( pattern . source , flags ) ;
}
return result ;
} ;
InputScanner . prototype . get _literal _regexp = function ( literal _string ) {
return RegExp ( literal _string . replace ( /[-\/\\^$*+?.()|[\]{}]/g , '\\$&' ) ) ;
} ;
/* css beautifier legacy helpers */
InputScanner . prototype . peekUntilAfter = function ( pattern ) {
var start = this . _ _position ;
var val = this . readUntilAfter ( pattern ) ;
this . _ _position = start ;
return val ;
} ;
InputScanner . prototype . lookBack = function ( testVal ) {
var start = this . _ _position - 1 ;
return start >= testVal . length && this . _ _input . substring ( start - testVal . length , start )
. toLowerCase ( ) === testVal ;
} ;
module . exports . InputScanner = InputScanner ;
/***/ } ) ,
/* 9 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var InputScanner = ( _ _webpack _require _ _ ( 8 ) . InputScanner ) ;
var Token = ( _ _webpack _require _ _ ( 3 ) . Token ) ;
var TokenStream = ( _ _webpack _require _ _ ( 10 ) . TokenStream ) ;
var WhitespacePattern = ( _ _webpack _require _ _ ( 11 ) . WhitespacePattern ) ;
2022-01-21 08:28:41 +00:00
var TOKEN = {
START : 'TK_START' ,
RAW : 'TK_RAW' ,
EOF : 'TK_EOF'
} ;
var Tokenizer = function ( input _string , options ) {
this . _input = new InputScanner ( input _string ) ;
this . _options = options || { } ;
this . _ _tokens = null ;
this . _patterns = { } ;
this . _patterns . whitespace = new WhitespacePattern ( this . _input ) ;
} ;
Tokenizer . prototype . tokenize = function ( ) {
this . _input . restart ( ) ;
this . _ _tokens = new TokenStream ( ) ;
this . _reset ( ) ;
var current ;
var previous = new Token ( TOKEN . START , '' ) ;
var open _token = null ;
var open _stack = [ ] ;
var comments = new TokenStream ( ) ;
while ( previous . type !== TOKEN . EOF ) {
current = this . _get _next _token ( previous , open _token ) ;
while ( this . _is _comment ( current ) ) {
comments . add ( current ) ;
current = this . _get _next _token ( previous , open _token ) ;
}
if ( ! comments . isEmpty ( ) ) {
current . comments _before = comments ;
comments = new TokenStream ( ) ;
}
current . parent = open _token ;
if ( this . _is _opening ( current ) ) {
open _stack . push ( open _token ) ;
open _token = current ;
} else if ( open _token && this . _is _closing ( current , open _token ) ) {
current . opened = open _token ;
open _token . closed = current ;
open _token = open _stack . pop ( ) ;
current . parent = open _token ;
}
current . previous = previous ;
previous . next = current ;
this . _ _tokens . add ( current ) ;
previous = current ;
}
return this . _ _tokens ;
} ;
Tokenizer . prototype . _is _first _token = function ( ) {
return this . _ _tokens . isEmpty ( ) ;
} ;
Tokenizer . prototype . _reset = function ( ) { } ;
Tokenizer . prototype . _get _next _token = function ( previous _token , open _token ) { // jshint unused:false
this . _readWhitespace ( ) ;
var resulting _string = this . _input . read ( /.+/g ) ;
if ( resulting _string ) {
return this . _create _token ( TOKEN . RAW , resulting _string ) ;
} else {
return this . _create _token ( TOKEN . EOF , '' ) ;
}
} ;
Tokenizer . prototype . _is _comment = function ( current _token ) { // jshint unused:false
return false ;
} ;
Tokenizer . prototype . _is _opening = function ( current _token ) { // jshint unused:false
return false ;
} ;
Tokenizer . prototype . _is _closing = function ( current _token , open _token ) { // jshint unused:false
return false ;
} ;
Tokenizer . prototype . _create _token = function ( type , text ) {
var token = new Token ( type , text ,
this . _patterns . whitespace . newline _count ,
this . _patterns . whitespace . whitespace _before _token ) ;
return token ;
} ;
Tokenizer . prototype . _readWhitespace = function ( ) {
return this . _patterns . whitespace . read ( ) ;
} ;
module . exports . Tokenizer = Tokenizer ;
module . exports . TOKEN = TOKEN ;
/***/ } ) ,
/* 10 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function TokenStream ( parent _token ) {
// private
this . _ _tokens = [ ] ;
this . _ _tokens _length = this . _ _tokens . length ;
this . _ _position = 0 ;
this . _ _parent _token = parent _token ;
}
TokenStream . prototype . restart = function ( ) {
this . _ _position = 0 ;
} ;
TokenStream . prototype . isEmpty = function ( ) {
return this . _ _tokens _length === 0 ;
} ;
TokenStream . prototype . hasNext = function ( ) {
return this . _ _position < this . _ _tokens _length ;
} ;
TokenStream . prototype . next = function ( ) {
var val = null ;
if ( this . hasNext ( ) ) {
val = this . _ _tokens [ this . _ _position ] ;
this . _ _position += 1 ;
}
return val ;
} ;
TokenStream . prototype . peek = function ( index ) {
var val = null ;
index = index || 0 ;
index += this . _ _position ;
if ( index >= 0 && index < this . _ _tokens _length ) {
val = this . _ _tokens [ index ] ;
}
return val ;
} ;
TokenStream . prototype . add = function ( token ) {
if ( this . _ _parent _token ) {
token . parent = this . _ _parent _token ;
}
this . _ _tokens . push ( token ) ;
this . _ _tokens _length += 1 ;
} ;
module . exports . TokenStream = TokenStream ;
/***/ } ) ,
/* 11 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Pattern = ( _ _webpack _require _ _ ( 12 ) . Pattern ) ;
2022-01-21 08:28:41 +00:00
function WhitespacePattern ( input _scanner , parent ) {
Pattern . call ( this , input _scanner , parent ) ;
if ( parent ) {
this . _line _regexp = this . _input . get _regexp ( parent . _line _regexp ) ;
} else {
this . _ _set _whitespace _patterns ( '' , '' ) ;
}
this . newline _count = 0 ;
this . whitespace _before _token = '' ;
}
WhitespacePattern . prototype = new Pattern ( ) ;
WhitespacePattern . prototype . _ _set _whitespace _patterns = function ( whitespace _chars , newline _chars ) {
whitespace _chars += '\\t ' ;
newline _chars += '\\n\\r' ;
this . _match _pattern = this . _input . get _regexp (
'[' + whitespace _chars + newline _chars + ']+' , true ) ;
this . _newline _regexp = this . _input . get _regexp (
'\\r\\n|[' + newline _chars + ']' ) ;
} ;
WhitespacePattern . prototype . read = function ( ) {
this . newline _count = 0 ;
this . whitespace _before _token = '' ;
var resulting _string = this . _input . read ( this . _match _pattern ) ;
if ( resulting _string === ' ' ) {
this . whitespace _before _token = ' ' ;
} else if ( resulting _string ) {
var matches = this . _ _split ( this . _newline _regexp , resulting _string ) ;
this . newline _count = matches . length - 1 ;
this . whitespace _before _token = matches [ this . newline _count ] ;
}
return resulting _string ;
} ;
WhitespacePattern . prototype . matching = function ( whitespace _chars , newline _chars ) {
var result = this . _create ( ) ;
result . _ _set _whitespace _patterns ( whitespace _chars , newline _chars ) ;
result . _update ( ) ;
return result ;
} ;
WhitespacePattern . prototype . _create = function ( ) {
return new WhitespacePattern ( this . _input , this ) ;
} ;
WhitespacePattern . prototype . _ _split = function ( regexp , input _string ) {
regexp . lastIndex = 0 ;
var start _index = 0 ;
var result = [ ] ;
var next _match = regexp . exec ( input _string ) ;
while ( next _match ) {
result . push ( input _string . substring ( start _index , next _match . index ) ) ;
start _index = next _match . index + next _match [ 0 ] . length ;
next _match = regexp . exec ( input _string ) ;
}
if ( start _index < input _string . length ) {
result . push ( input _string . substring ( start _index , input _string . length ) ) ;
} else {
result . push ( '' ) ;
}
return result ;
} ;
module . exports . WhitespacePattern = WhitespacePattern ;
/***/ } ) ,
/* 12 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Pattern ( input _scanner , parent ) {
this . _input = input _scanner ;
this . _starting _pattern = null ;
this . _match _pattern = null ;
this . _until _pattern = null ;
this . _until _after = false ;
if ( parent ) {
this . _starting _pattern = this . _input . get _regexp ( parent . _starting _pattern , true ) ;
this . _match _pattern = this . _input . get _regexp ( parent . _match _pattern , true ) ;
this . _until _pattern = this . _input . get _regexp ( parent . _until _pattern ) ;
this . _until _after = parent . _until _after ;
}
}
Pattern . prototype . read = function ( ) {
var result = this . _input . read ( this . _starting _pattern ) ;
if ( ! this . _starting _pattern || result ) {
result += this . _input . read ( this . _match _pattern , this . _until _pattern , this . _until _after ) ;
}
return result ;
} ;
Pattern . prototype . read _match = function ( ) {
return this . _input . match ( this . _match _pattern ) ;
} ;
Pattern . prototype . until _after = function ( pattern ) {
var result = this . _create ( ) ;
result . _until _after = true ;
result . _until _pattern = this . _input . get _regexp ( pattern ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . until = function ( pattern ) {
var result = this . _create ( ) ;
result . _until _after = false ;
result . _until _pattern = this . _input . get _regexp ( pattern ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . starting _with = function ( pattern ) {
var result = this . _create ( ) ;
result . _starting _pattern = this . _input . get _regexp ( pattern , true ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . matching = function ( pattern ) {
var result = this . _create ( ) ;
result . _match _pattern = this . _input . get _regexp ( pattern , true ) ;
result . _update ( ) ;
return result ;
} ;
Pattern . prototype . _create = function ( ) {
return new Pattern ( this . _input , this ) ;
} ;
Pattern . prototype . _update = function ( ) { } ;
module . exports . Pattern = Pattern ;
/***/ } ) ,
/* 13 */
/***/ ( function ( module ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
function Directives ( start _block _pattern , end _block _pattern ) {
start _block _pattern = typeof start _block _pattern === 'string' ? start _block _pattern : start _block _pattern . source ;
end _block _pattern = typeof end _block _pattern === 'string' ? end _block _pattern : end _block _pattern . source ;
this . _ _directives _block _pattern = new RegExp ( start _block _pattern + / beautify( \w+[:]\w+)+ / . source + end _block _pattern , 'g' ) ;
this . _ _directive _pattern = / (\w+)[:](\w+)/g ;
this . _ _directives _end _ignore _pattern = new RegExp ( start _block _pattern + /\sbeautify\signore:end\s/ . source + end _block _pattern , 'g' ) ;
}
Directives . prototype . get _directives = function ( text ) {
if ( ! text . match ( this . _ _directives _block _pattern ) ) {
return null ;
}
var directives = { } ;
this . _ _directive _pattern . lastIndex = 0 ;
var directive _match = this . _ _directive _pattern . exec ( text ) ;
while ( directive _match ) {
directives [ directive _match [ 1 ] ] = directive _match [ 2 ] ;
directive _match = this . _ _directive _pattern . exec ( text ) ;
}
return directives ;
} ;
Directives . prototype . readIgnored = function ( input ) {
return input . readUntilAfter ( this . _ _directives _end _ignore _pattern ) ;
} ;
module . exports . Directives = Directives ;
/***/ } ) ,
/* 14 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Pattern = ( _ _webpack _require _ _ ( 12 ) . Pattern ) ;
2022-01-21 08:28:41 +00:00
var template _names = {
django : false ,
erb : false ,
handlebars : false ,
php : false ,
smarty : false
} ;
// This lets templates appear anywhere we would do a readUntil
// The cost is higher but it is pay to play.
function TemplatablePattern ( input _scanner , parent ) {
Pattern . call ( this , input _scanner , parent ) ;
this . _ _template _pattern = null ;
this . _disabled = Object . assign ( { } , template _names ) ;
this . _excluded = Object . assign ( { } , template _names ) ;
if ( parent ) {
this . _ _template _pattern = this . _input . get _regexp ( parent . _ _template _pattern ) ;
this . _excluded = Object . assign ( this . _excluded , parent . _excluded ) ;
this . _disabled = Object . assign ( this . _disabled , parent . _disabled ) ;
}
var pattern = new Pattern ( input _scanner ) ;
this . _ _patterns = {
handlebars _comment : pattern . starting _with ( /{{!--/ ) . until _after ( /--}}/ ) ,
handlebars _unescaped : pattern . starting _with ( /{{{/ ) . until _after ( /}}}/ ) ,
handlebars : pattern . starting _with ( /{{/ ) . until _after ( /}}/ ) ,
php : pattern . starting _with ( /<\?(?:[= ]|php)/ ) . until _after ( /\?>/ ) ,
erb : pattern . starting _with ( /<%[^%]/ ) . until _after ( /[^%]%>/ ) ,
// django coflicts with handlebars a bit.
django : pattern . starting _with ( /{%/ ) . until _after ( /%}/ ) ,
django _value : pattern . starting _with ( /{{/ ) . until _after ( /}}/ ) ,
django _comment : pattern . starting _with ( /{#/ ) . until _after ( /#}/ ) ,
smarty : pattern . starting _with ( /{(?=[^}{\s\n])/ ) . until _after ( /[^\s\n]}/ ) ,
smarty _comment : pattern . starting _with ( /{\*/ ) . until _after ( /\*}/ ) ,
smarty _literal : pattern . starting _with ( /{literal}/ ) . until _after ( /{\/literal}/ )
} ;
}
TemplatablePattern . prototype = new Pattern ( ) ;
TemplatablePattern . prototype . _create = function ( ) {
return new TemplatablePattern ( this . _input , this ) ;
} ;
TemplatablePattern . prototype . _update = function ( ) {
this . _ _set _templated _pattern ( ) ;
} ;
TemplatablePattern . prototype . disable = function ( language ) {
var result = this . _create ( ) ;
result . _disabled [ language ] = true ;
result . _update ( ) ;
return result ;
} ;
TemplatablePattern . prototype . read _options = function ( options ) {
var result = this . _create ( ) ;
for ( var language in template _names ) {
result . _disabled [ language ] = options . templating . indexOf ( language ) === - 1 ;
}
result . _update ( ) ;
return result ;
} ;
TemplatablePattern . prototype . exclude = function ( language ) {
var result = this . _create ( ) ;
result . _excluded [ language ] = true ;
result . _update ( ) ;
return result ;
} ;
TemplatablePattern . prototype . read = function ( ) {
var result = '' ;
if ( this . _match _pattern ) {
result = this . _input . read ( this . _starting _pattern ) ;
} else {
result = this . _input . read ( this . _starting _pattern , this . _ _template _pattern ) ;
}
var next = this . _read _template ( ) ;
while ( next ) {
if ( this . _match _pattern ) {
next += this . _input . read ( this . _match _pattern ) ;
} else {
next += this . _input . readUntil ( this . _ _template _pattern ) ;
}
result += next ;
next = this . _read _template ( ) ;
}
if ( this . _until _after ) {
result += this . _input . readUntilAfter ( this . _until _pattern ) ;
}
return result ;
} ;
TemplatablePattern . prototype . _ _set _templated _pattern = function ( ) {
var items = [ ] ;
if ( ! this . _disabled . php ) {
items . push ( this . _ _patterns . php . _starting _pattern . source ) ;
}
if ( ! this . _disabled . handlebars ) {
items . push ( this . _ _patterns . handlebars . _starting _pattern . source ) ;
}
if ( ! this . _disabled . erb ) {
items . push ( this . _ _patterns . erb . _starting _pattern . source ) ;
}
if ( ! this . _disabled . django ) {
items . push ( this . _ _patterns . django . _starting _pattern . source ) ;
// The starting pattern for django is more complex because it has different
// patterns for value, comment, and other sections
items . push ( this . _ _patterns . django _value . _starting _pattern . source ) ;
items . push ( this . _ _patterns . django _comment . _starting _pattern . source ) ;
}
if ( ! this . _disabled . smarty ) {
items . push ( this . _ _patterns . smarty . _starting _pattern . source ) ;
}
if ( this . _until _pattern ) {
items . push ( this . _until _pattern . source ) ;
}
this . _ _template _pattern = this . _input . get _regexp ( '(?:' + items . join ( '|' ) + ')' ) ;
} ;
TemplatablePattern . prototype . _read _template = function ( ) {
var resulting _string = '' ;
var c = this . _input . peek ( ) ;
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 ( ! this . _disabled . php && ! this . _excluded . php && peek1 === '?' ) {
resulting _string = resulting _string ||
this . _ _patterns . php . read ( ) ;
}
if ( ! this . _disabled . erb && ! this . _excluded . erb && peek1 === '%' ) {
resulting _string = resulting _string ||
this . _ _patterns . erb . read ( ) ;
}
} else if ( c === '{' ) {
if ( ! this . _disabled . handlebars && ! this . _excluded . handlebars ) {
resulting _string = resulting _string ||
this . _ _patterns . handlebars _comment . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . handlebars _unescaped . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . handlebars . read ( ) ;
}
if ( ! this . _disabled . django ) {
// django coflicts with handlebars a bit.
if ( ! this . _excluded . django && ! this . _excluded . handlebars ) {
resulting _string = resulting _string ||
this . _ _patterns . django _value . read ( ) ;
}
if ( ! this . _excluded . django ) {
resulting _string = resulting _string ||
this . _ _patterns . django _comment . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . django . read ( ) ;
}
}
if ( ! this . _disabled . smarty ) {
// smarty cannot be enabled with django or handlebars enabled
if ( this . _disabled . django && this . _disabled . handlebars ) {
resulting _string = resulting _string ||
this . _ _patterns . smarty _comment . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . smarty _literal . read ( ) ;
resulting _string = resulting _string ||
this . _ _patterns . smarty . read ( ) ;
}
}
}
return resulting _string ;
} ;
module . exports . TemplatablePattern = TemplatablePattern ;
/***/ } ) ,
/* 15 */ ,
/* 16 */ ,
/* 17 */ ,
/* 18 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Beautifier = ( _ _webpack _require _ _ ( 19 ) . Beautifier ) ,
Options = ( _ _webpack _require _ _ ( 20 ) . Options ) ;
2022-01-21 08:28:41 +00:00
function style _html ( html _source , options , js _beautify , css _beautify ) {
var beautifier = new Beautifier ( html _source , options , js _beautify , css _beautify ) ;
return beautifier . beautify ( ) ;
}
module . exports = style _html ;
module . exports . defaultOptions = function ( ) {
return new Options ( ) ;
} ;
/***/ } ) ,
/* 19 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var Options = ( _ _webpack _require _ _ ( 20 ) . Options ) ;
var Output = ( _ _webpack _require _ _ ( 2 ) . Output ) ;
var Tokenizer = ( _ _webpack _require _ _ ( 21 ) . Tokenizer ) ;
var TOKEN = ( _ _webpack _require _ _ ( 21 ) . TOKEN ) ;
2022-01-21 08:28:41 +00:00
var lineBreak = /\r\n|[\r\n]/ ;
var allLineBreaks = /\r\n|[\r\n]/g ;
var Printer = function ( options , base _indent _string ) { //handles input/output and some other printing functions
this . indent _level = 0 ;
this . alignment _size = 0 ;
this . max _preserve _newlines = options . max _preserve _newlines ;
this . preserve _newlines = options . preserve _newlines ;
this . _output = new Output ( options , base _indent _string ) ;
} ;
Printer . prototype . current _line _has _match = function ( pattern ) {
return this . _output . current _line . has _match ( pattern ) ;
} ;
Printer . prototype . set _space _before _token = function ( value , non _breaking ) {
this . _output . space _before _token = value ;
this . _output . non _breaking _space = non _breaking ;
} ;
Printer . prototype . set _wrap _point = function ( ) {
this . _output . set _indent ( this . indent _level , this . alignment _size ) ;
this . _output . set _wrap _point ( ) ;
} ;
Printer . prototype . add _raw _token = function ( token ) {
this . _output . add _raw _token ( token ) ;
} ;
Printer . prototype . print _preserved _newlines = function ( raw _token ) {
var newlines = 0 ;
if ( raw _token . type !== TOKEN . TEXT && raw _token . previous . type !== TOKEN . TEXT ) {
newlines = raw _token . newlines ? 1 : 0 ;
}
if ( this . preserve _newlines ) {
newlines = raw _token . newlines < this . max _preserve _newlines + 1 ? raw _token . newlines : this . max _preserve _newlines + 1 ;
}
for ( var n = 0 ; n < newlines ; n ++ ) {
this . print _newline ( n > 0 ) ;
}
return newlines !== 0 ;
} ;
Printer . prototype . traverse _whitespace = function ( raw _token ) {
if ( raw _token . whitespace _before || raw _token . newlines ) {
if ( ! this . print _preserved _newlines ( raw _token ) ) {
this . _output . space _before _token = true ;
}
return true ;
}
return false ;
} ;
Printer . prototype . previous _token _wrapped = function ( ) {
return this . _output . previous _token _wrapped ;
} ;
Printer . prototype . print _newline = function ( force ) {
this . _output . add _new _line ( force ) ;
} ;
Printer . prototype . print _token = function ( token ) {
if ( token . text ) {
this . _output . set _indent ( this . indent _level , this . alignment _size ) ;
this . _output . add _token ( token . text ) ;
}
} ;
Printer . prototype . indent = function ( ) {
this . indent _level ++ ;
} ;
Printer . prototype . get _full _indent = function ( level ) {
level = this . indent _level + ( level || 0 ) ;
if ( level < 1 ) {
return '' ;
}
return this . _output . get _indent _string ( level ) ;
} ;
var get _type _attribute = function ( start _token ) {
var result = null ;
var raw _token = start _token . next ;
// Search attributes for a type attribute
while ( raw _token . type !== TOKEN . EOF && start _token . closed !== raw _token ) {
if ( raw _token . type === TOKEN . ATTRIBUTE && raw _token . text === 'type' ) {
if ( raw _token . next && raw _token . next . type === TOKEN . EQUALS &&
raw _token . next . next && raw _token . next . next . type === TOKEN . VALUE ) {
result = raw _token . next . next . text ;
}
break ;
}
raw _token = raw _token . next ;
}
return result ;
} ;
var get _custom _beautifier _name = function ( tag _check , raw _token ) {
var typeAttribute = null ;
var result = null ;
if ( ! raw _token . closed ) {
return null ;
}
if ( tag _check === 'script' ) {
typeAttribute = 'text/javascript' ;
} else if ( tag _check === 'style' ) {
typeAttribute = 'text/css' ;
}
typeAttribute = get _type _attribute ( raw _token ) || typeAttribute ;
// For script and style tags that have a type attribute, only enable custom beautifiers for matching values
// For those without a type attribute use default;
if ( typeAttribute . search ( 'text/css' ) > - 1 ) {
result = 'css' ;
} else if ( typeAttribute . search ( /module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/ ) > - 1 ) {
result = 'javascript' ;
} else if ( typeAttribute . search ( /(text|application|dojo)\/(x-)?(html)/ ) > - 1 ) {
result = 'html' ;
} else if ( typeAttribute . search ( /test\/null/ ) > - 1 ) {
// Test only mime-type for testing the beautifier when null is passed as beautifing function
result = 'null' ;
}
return result ;
} ;
function in _array ( what , arr ) {
return arr . indexOf ( what ) !== - 1 ;
}
function TagFrame ( parent , parser _token , indent _level ) {
this . parent = parent || null ;
this . tag = parser _token ? parser _token . tag _name : '' ;
this . indent _level = indent _level || 0 ;
this . parser _token = parser _token || null ;
}
function TagStack ( printer ) {
this . _printer = printer ;
this . _current _frame = null ;
}
TagStack . prototype . get _parser _token = function ( ) {
return this . _current _frame ? this . _current _frame . parser _token : null ;
} ;
TagStack . prototype . record _tag = function ( parser _token ) { //function to record a tag and its parent in this.tags Object
var new _frame = new TagFrame ( this . _current _frame , parser _token , this . _printer . indent _level ) ;
this . _current _frame = new _frame ;
} ;
TagStack . prototype . _try _pop _frame = function ( frame ) { //function to retrieve the opening tag to the corresponding closer
var parser _token = null ;
if ( frame ) {
parser _token = frame . parser _token ;
this . _printer . indent _level = frame . indent _level ;
this . _current _frame = frame . parent ;
}
return parser _token ;
} ;
TagStack . prototype . _get _frame = function ( tag _list , stop _list ) { //function to retrieve the opening tag to the corresponding closer
var frame = this . _current _frame ;
while ( frame ) { //till we reach '' (the initial value);
if ( tag _list . indexOf ( frame . tag ) !== - 1 ) { //if this is it use it
break ;
} else if ( stop _list && stop _list . indexOf ( frame . tag ) !== - 1 ) {
frame = null ;
break ;
}
frame = frame . parent ;
}
return frame ;
} ;
TagStack . prototype . try _pop = function ( tag , stop _list ) { //function to retrieve the opening tag to the corresponding closer
var frame = this . _get _frame ( [ tag ] , stop _list ) ;
return this . _try _pop _frame ( frame ) ;
} ;
TagStack . prototype . indent _to _tag = function ( tag _list ) {
var frame = this . _get _frame ( tag _list ) ;
if ( frame ) {
this . _printer . indent _level = frame . indent _level ;
}
} ;
function Beautifier ( source _text , options , js _beautify , css _beautify ) {
//Wrapper function to invoke all the necessary constructors and deal with the output.
this . _source _text = source _text || '' ;
options = options || { } ;
this . _js _beautify = js _beautify ;
this . _css _beautify = css _beautify ;
this . _tag _stack = null ;
// Allow the setting of language/file-type specific options
// with inheritance of overall settings
var optionHtml = new Options ( options , 'html' ) ;
this . _options = optionHtml ;
this . _is _wrap _attributes _force = this . _options . wrap _attributes . substr ( 0 , 'force' . length ) === 'force' ;
this . _is _wrap _attributes _force _expand _multiline = ( this . _options . wrap _attributes === 'force-expand-multiline' ) ;
this . _is _wrap _attributes _force _aligned = ( this . _options . wrap _attributes === 'force-aligned' ) ;
this . _is _wrap _attributes _aligned _multiple = ( this . _options . wrap _attributes === 'aligned-multiple' ) ;
this . _is _wrap _attributes _preserve = this . _options . wrap _attributes . substr ( 0 , 'preserve' . length ) === 'preserve' ;
this . _is _wrap _attributes _preserve _aligned = ( this . _options . wrap _attributes === 'preserve-aligned' ) ;
}
Beautifier . prototype . beautify = function ( ) {
// if disabled, return the input unchanged.
if ( this . _options . disabled ) {
return this . _source _text ;
}
var source _text = this . _source _text ;
var eol = this . _options . eol ;
if ( this . _options . eol === 'auto' ) {
eol = '\n' ;
if ( source _text && lineBreak . test ( source _text ) ) {
eol = source _text . match ( lineBreak ) [ 0 ] ;
}
}
// HACK: newline parsing inconsistent. This brute force normalizes the input.
source _text = source _text . replace ( allLineBreaks , '\n' ) ;
var baseIndentString = source _text . match ( /^[\t ]*/ ) [ 0 ] ;
var last _token = {
text : '' ,
type : ''
} ;
var last _tag _token = new TagOpenParserToken ( ) ;
var printer = new Printer ( this . _options , baseIndentString ) ;
var tokens = new Tokenizer ( source _text , this . _options ) . tokenize ( ) ;
this . _tag _stack = new TagStack ( printer ) ;
var parser _token = null ;
var raw _token = tokens . next ( ) ;
while ( raw _token . type !== TOKEN . EOF ) {
if ( raw _token . type === TOKEN . TAG _OPEN || raw _token . type === TOKEN . COMMENT ) {
2023-08-17 09:47:40 +00:00
parser _token = this . _handle _tag _open ( printer , raw _token , last _tag _token , last _token , tokens ) ;
2022-01-21 08:28:41 +00:00
last _tag _token = parser _token ;
} else if ( ( raw _token . type === TOKEN . ATTRIBUTE || raw _token . type === TOKEN . EQUALS || raw _token . type === TOKEN . VALUE ) ||
( raw _token . type === TOKEN . TEXT && ! last _tag _token . tag _complete ) ) {
2023-08-17 09:47:40 +00:00
parser _token = this . _handle _inside _tag ( printer , raw _token , last _tag _token , last _token ) ;
2022-01-21 08:28:41 +00:00
} else if ( raw _token . type === TOKEN . TAG _CLOSE ) {
parser _token = this . _handle _tag _close ( printer , raw _token , last _tag _token ) ;
} else if ( raw _token . type === TOKEN . TEXT ) {
parser _token = this . _handle _text ( printer , raw _token , last _tag _token ) ;
} else {
// This should never happen, but if it does. Print the raw token
printer . add _raw _token ( raw _token ) ;
}
last _token = parser _token ;
raw _token = tokens . next ( ) ;
}
var sweet _code = printer . _output . get _code ( eol ) ;
return sweet _code ;
} ;
Beautifier . prototype . _handle _tag _close = function ( printer , raw _token , last _tag _token ) {
var parser _token = {
text : raw _token . text ,
type : raw _token . type
} ;
printer . alignment _size = 0 ;
last _tag _token . tag _complete = true ;
printer . set _space _before _token ( raw _token . newlines || raw _token . whitespace _before !== '' , true ) ;
if ( last _tag _token . is _unformatted ) {
printer . add _raw _token ( raw _token ) ;
} else {
if ( last _tag _token . tag _start _char === '<' ) {
printer . set _space _before _token ( raw _token . text [ 0 ] === '/' , true ) ; // space before />, no space before >
if ( this . _is _wrap _attributes _force _expand _multiline && last _tag _token . has _wrapped _attrs ) {
printer . print _newline ( false ) ;
}
}
printer . print _token ( raw _token ) ;
}
if ( last _tag _token . indent _content &&
! ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) ) {
printer . indent ( ) ;
// only indent once per opened tag
last _tag _token . indent _content = false ;
}
if ( ! last _tag _token . is _inline _element &&
! ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) ) {
printer . set _wrap _point ( ) ;
}
return parser _token ;
} ;
2023-08-17 09:47:40 +00:00
Beautifier . prototype . _handle _inside _tag = function ( printer , raw _token , last _tag _token , last _token ) {
2022-01-21 08:28:41 +00:00
var wrapped = last _tag _token . has _wrapped _attrs ;
var parser _token = {
text : raw _token . text ,
type : raw _token . type
} ;
printer . set _space _before _token ( raw _token . newlines || raw _token . whitespace _before !== '' , true ) ;
if ( last _tag _token . is _unformatted ) {
printer . add _raw _token ( raw _token ) ;
} else if ( last _tag _token . tag _start _char === '{' && raw _token . type === TOKEN . TEXT ) {
// For the insides of handlebars allow newlines or a single space between open and contents
if ( printer . print _preserved _newlines ( raw _token ) ) {
raw _token . newlines = 0 ;
printer . add _raw _token ( raw _token ) ;
} else {
printer . print _token ( raw _token ) ;
}
} else {
if ( raw _token . type === TOKEN . ATTRIBUTE ) {
printer . set _space _before _token ( true ) ;
} else if ( raw _token . type === TOKEN . EQUALS ) { //no space before =
printer . set _space _before _token ( false ) ;
} else if ( raw _token . type === TOKEN . VALUE && raw _token . previous . type === TOKEN . EQUALS ) { //no space before value
printer . set _space _before _token ( false ) ;
}
if ( raw _token . type === TOKEN . ATTRIBUTE && last _tag _token . tag _start _char === '<' ) {
if ( this . _is _wrap _attributes _preserve || this . _is _wrap _attributes _preserve _aligned ) {
printer . traverse _whitespace ( raw _token ) ;
wrapped = wrapped || raw _token . newlines !== 0 ;
}
2023-08-17 09:47:40 +00:00
// Wrap for 'force' options, and if the number of attributes is at least that specified in 'wrap_attributes_min_attrs':
// 1. always wrap the second and beyond attributes
// 2. wrap the first attribute only if 'force-expand-multiline' is specified
if ( this . _is _wrap _attributes _force &&
last _tag _token . attr _count >= this . _options . wrap _attributes _min _attrs &&
( last _token . type !== TOKEN . TAG _OPEN || // ie. second attribute and beyond
this . _is _wrap _attributes _force _expand _multiline ) ) {
printer . print _newline ( false ) ;
wrapped = true ;
2022-01-21 08:28:41 +00:00
}
}
printer . print _token ( raw _token ) ;
wrapped = wrapped || printer . previous _token _wrapped ( ) ;
last _tag _token . has _wrapped _attrs = wrapped ;
}
return parser _token ;
} ;
Beautifier . prototype . _handle _text = function ( printer , raw _token , last _tag _token ) {
var parser _token = {
text : raw _token . text ,
type : 'TK_CONTENT'
} ;
if ( last _tag _token . custom _beautifier _name ) { //check if we need to format javascript
this . _print _custom _beatifier _text ( printer , raw _token , last _tag _token ) ;
} else if ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) {
printer . add _raw _token ( raw _token ) ;
} else {
printer . traverse _whitespace ( raw _token ) ;
printer . print _token ( raw _token ) ;
}
return parser _token ;
} ;
Beautifier . prototype . _print _custom _beatifier _text = function ( printer , raw _token , last _tag _token ) {
var local = this ;
if ( raw _token . text !== '' ) {
var text = raw _token . text ,
_beautifier ,
script _indent _level = 1 ,
pre = '' ,
post = '' ;
if ( last _tag _token . custom _beautifier _name === 'javascript' && typeof this . _js _beautify === 'function' ) {
_beautifier = this . _js _beautify ;
} else if ( last _tag _token . custom _beautifier _name === 'css' && typeof this . _css _beautify === 'function' ) {
_beautifier = this . _css _beautify ;
} else if ( last _tag _token . custom _beautifier _name === 'html' ) {
_beautifier = function ( html _source , options ) {
var beautifier = new Beautifier ( html _source , options , local . _js _beautify , local . _css _beautify ) ;
return beautifier . beautify ( ) ;
} ;
}
if ( this . _options . indent _scripts === "keep" ) {
script _indent _level = 0 ;
} else if ( this . _options . indent _scripts === "separate" ) {
script _indent _level = - printer . indent _level ;
}
var indentation = printer . get _full _indent ( script _indent _level ) ;
// if there is at least one empty line at the end of this text, strip it
// we'll be adding one back after the text but before the containing tag.
text = text . replace ( /\n[ \t]*$/ , '' ) ;
// Handle the case where content is wrapped in a comment or cdata.
if ( last _tag _token . custom _beautifier _name !== 'html' &&
text [ 0 ] === '<' && text . match ( /^(<!--|<!\[CDATA\[)/ ) ) {
var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/ . exec ( text ) ;
// if we start to wrap but don't finish, print raw
if ( ! matched ) {
printer . add _raw _token ( raw _token ) ;
return ;
}
pre = indentation + matched [ 1 ] + '\n' ;
text = matched [ 4 ] ;
if ( matched [ 5 ] ) {
post = indentation + matched [ 5 ] ;
}
// if there is at least one empty line at the end of this text, strip it
// we'll be adding one back after the text but before the containing tag.
text = text . replace ( /\n[ \t]*$/ , '' ) ;
if ( matched [ 2 ] || matched [ 3 ] . indexOf ( '\n' ) !== - 1 ) {
// if the first line of the non-comment text has spaces
// use that as the basis for indenting in null case.
matched = matched [ 3 ] . match ( /[ \t]+$/ ) ;
if ( matched ) {
raw _token . whitespace _before = matched [ 0 ] ;
}
}
}
if ( text ) {
if ( _beautifier ) {
// call the Beautifier if avaliable
var Child _options = function ( ) {
this . eol = '\n' ;
} ;
Child _options . prototype = this . _options . raw _options ;
var child _options = new Child _options ( ) ;
text = _beautifier ( indentation + text , child _options ) ;
} else {
// simply indent the string otherwise
var white = raw _token . whitespace _before ;
if ( white ) {
text = text . replace ( new RegExp ( '\n(' + white + ')?' , 'g' ) , '\n' ) ;
}
text = indentation + text . replace ( /\n/g , '\n' + indentation ) ;
}
}
if ( pre ) {
if ( ! text ) {
text = pre + post ;
} else {
text = pre + text + '\n' + post ;
}
}
printer . print _newline ( false ) ;
if ( text ) {
raw _token . text = text ;
raw _token . whitespace _before = '' ;
raw _token . newlines = 0 ;
printer . add _raw _token ( raw _token ) ;
printer . print _newline ( true ) ;
}
}
} ;
2023-08-17 09:47:40 +00:00
Beautifier . prototype . _handle _tag _open = function ( printer , raw _token , last _tag _token , last _token , tokens ) {
2022-01-21 08:28:41 +00:00
var parser _token = this . _get _tag _open _token ( raw _token ) ;
if ( ( last _tag _token . is _unformatted || last _tag _token . is _content _unformatted ) &&
! last _tag _token . is _empty _element &&
2023-08-17 09:47:40 +00:00
raw _token . type === TOKEN . TAG _OPEN && ! parser _token . is _start _tag ) {
2022-01-21 08:28:41 +00:00
// End element tags for unformatted or content_unformatted elements
// are printed raw to keep any newlines inside them exactly the same.
printer . add _raw _token ( raw _token ) ;
parser _token . start _tag _token = this . _tag _stack . try _pop ( parser _token . tag _name ) ;
} else {
printer . traverse _whitespace ( raw _token ) ;
this . _set _tag _position ( printer , raw _token , parser _token , last _tag _token , last _token ) ;
if ( ! parser _token . is _inline _element ) {
printer . set _wrap _point ( ) ;
}
printer . print _token ( raw _token ) ;
}
2023-08-17 09:47:40 +00:00
// count the number of attributes
if ( parser _token . is _start _tag && this . _is _wrap _attributes _force ) {
var peek _index = 0 ;
var peek _token ;
do {
peek _token = tokens . peek ( peek _index ) ;
if ( peek _token . type === TOKEN . ATTRIBUTE ) {
parser _token . attr _count += 1 ;
}
peek _index += 1 ;
} while ( peek _token . type !== TOKEN . EOF && peek _token . type !== TOKEN . TAG _CLOSE ) ;
}
2022-01-21 08:28:41 +00:00
//indent attributes an auto, forced, aligned or forced-align line-wrap
if ( this . _is _wrap _attributes _force _aligned || this . _is _wrap _attributes _aligned _multiple || this . _is _wrap _attributes _preserve _aligned ) {
parser _token . alignment _size = raw _token . text . length + 1 ;
}
if ( ! parser _token . tag _complete && ! parser _token . is _unformatted ) {
printer . alignment _size = parser _token . alignment _size ;
}
return parser _token ;
} ;
var TagOpenParserToken = function ( parent , raw _token ) {
this . parent = parent || null ;
this . text = '' ;
this . type = 'TK_TAG_OPEN' ;
this . tag _name = '' ;
this . is _inline _element = false ;
this . is _unformatted = false ;
this . is _content _unformatted = false ;
this . is _empty _element = false ;
this . is _start _tag = false ;
this . is _end _tag = false ;
this . indent _content = false ;
this . multiline _content = false ;
this . custom _beautifier _name = null ;
this . start _tag _token = null ;
this . attr _count = 0 ;
this . has _wrapped _attrs = false ;
this . alignment _size = 0 ;
this . tag _complete = false ;
this . tag _start _char = '' ;
this . tag _check = '' ;
if ( ! raw _token ) {
this . tag _complete = true ;
} else {
var tag _check _match ;
this . tag _start _char = raw _token . text [ 0 ] ;
this . text = raw _token . text ;
if ( this . tag _start _char === '<' ) {
tag _check _match = raw _token . text . match ( /^<([^\s>]*)/ ) ;
this . tag _check = tag _check _match ? tag _check _match [ 1 ] : '' ;
} else {
2022-07-11 11:25:19 +00:00
tag _check _match = raw _token . text . match ( /^{{~?(?:[\^]|#\*?)?([^\s}]+)/ ) ;
2022-01-21 08:28:41 +00:00
this . tag _check = tag _check _match ? tag _check _match [ 1 ] : '' ;
2022-07-11 11:25:19 +00:00
// handle "{{#> myPartial}}" or "{{~#> myPartial}}"
if ( ( raw _token . text . startsWith ( '{{#>' ) || raw _token . text . startsWith ( '{{~#>' ) ) && this . tag _check [ 0 ] === '>' ) {
if ( this . tag _check === '>' && raw _token . next !== null ) {
this . tag _check = raw _token . next . text . split ( ' ' ) [ 0 ] ;
} else {
this . tag _check = raw _token . text . split ( '>' ) [ 1 ] ;
}
2022-01-21 08:28:41 +00:00
}
}
2022-07-11 11:25:19 +00:00
2022-01-21 08:28:41 +00:00
this . tag _check = this . tag _check . toLowerCase ( ) ;
if ( raw _token . type === TOKEN . COMMENT ) {
this . tag _complete = true ;
}
this . is _start _tag = this . tag _check . charAt ( 0 ) !== '/' ;
this . tag _name = ! this . is _start _tag ? this . tag _check . substr ( 1 ) : this . tag _check ;
this . is _end _tag = ! this . is _start _tag ||
( raw _token . closed && raw _token . closed . text === '/>' ) ;
2022-07-11 11:25:19 +00:00
// if whitespace handler ~ included (i.e. {{~#if true}}), handlebars tags start at pos 3 not pos 2
var handlebar _starts = 2 ;
if ( this . tag _start _char === '{' && this . text . length >= 3 ) {
if ( this . text . charAt ( 2 ) === '~' ) {
handlebar _starts = 3 ;
}
}
2022-01-21 08:28:41 +00:00
// handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
this . is _end _tag = this . is _end _tag ||
2022-07-11 11:25:19 +00:00
( this . tag _start _char === '{' && ( this . text . length < 3 || ( /[^#\^]/ . test ( this . text . charAt ( handlebar _starts ) ) ) ) ) ;
2022-01-21 08:28:41 +00:00
}
} ;
Beautifier . prototype . _get _tag _open _token = function ( raw _token ) { //function to get a full tag and parse its type
var parser _token = new TagOpenParserToken ( this . _tag _stack . get _parser _token ( ) , raw _token ) ;
parser _token . alignment _size = this . _options . wrap _attributes _indent _size ;
parser _token . is _end _tag = parser _token . is _end _tag ||
in _array ( parser _token . tag _check , this . _options . void _elements ) ;
parser _token . is _empty _element = parser _token . tag _complete ||
( parser _token . is _start _tag && parser _token . is _end _tag ) ;
parser _token . is _unformatted = ! parser _token . tag _complete && in _array ( parser _token . tag _check , this . _options . unformatted ) ;
parser _token . is _content _unformatted = ! parser _token . is _empty _element && in _array ( parser _token . tag _check , this . _options . content _unformatted ) ;
2023-08-17 09:47:40 +00:00
parser _token . is _inline _element = in _array ( parser _token . tag _name , this . _options . inline ) || ( this . _options . inline _custom _elements && parser _token . tag _name . includes ( "-" ) ) || parser _token . tag _start _char === '{' ;
2022-01-21 08:28:41 +00:00
return parser _token ;
} ;
Beautifier . prototype . _set _tag _position = function ( printer , raw _token , parser _token , last _tag _token , last _token ) {
if ( ! parser _token . is _empty _element ) {
if ( parser _token . is _end _tag ) { //this tag is a double tag so check for tag-ending
parser _token . start _tag _token = this . _tag _stack . try _pop ( parser _token . tag _name ) ; //remove it and all ancestors
} else { // it's a start-tag
// check if this tag is starting an element that has optional end element
// and do an ending needed
if ( this . _do _optional _end _element ( parser _token ) ) {
if ( ! parser _token . is _inline _element ) {
printer . print _newline ( false ) ;
}
}
this . _tag _stack . record _tag ( parser _token ) ; //push it on the tag stack
if ( ( parser _token . tag _name === 'script' || parser _token . tag _name === 'style' ) &&
! ( parser _token . is _unformatted || parser _token . is _content _unformatted ) ) {
parser _token . custom _beautifier _name = get _custom _beautifier _name ( parser _token . tag _check , raw _token ) ;
}
}
}
if ( in _array ( parser _token . tag _check , this . _options . extra _liners ) ) { //check if this double needs an extra line
printer . print _newline ( false ) ;
if ( ! printer . _output . just _added _blankline ( ) ) {
printer . print _newline ( true ) ;
}
}
if ( parser _token . is _empty _element ) { //if this tag name is a single tag type (either in the list or has a closing /)
// if you hit an else case, reset the indent level if you are inside an:
// 'if', 'unless', or 'each' block.
if ( parser _token . tag _start _char === '{' && parser _token . tag _check === 'else' ) {
this . _tag _stack . indent _to _tag ( [ 'if' , 'unless' , 'each' ] ) ;
parser _token . indent _content = true ;
// Don't add a newline if opening {{#if}} tag is on the current line
var foundIfOnCurrentLine = printer . current _line _has _match ( /{{#if/ ) ;
if ( ! foundIfOnCurrentLine ) {
printer . print _newline ( false ) ;
}
}
// Don't add a newline before elements that should remain where they are.
if ( parser _token . tag _name === '!--' && last _token . type === TOKEN . TAG _CLOSE &&
last _tag _token . is _end _tag && parser _token . text . indexOf ( '\n' ) === - 1 ) {
//Do nothing. Leave comments on same line.
} else {
if ( ! ( parser _token . is _inline _element || parser _token . is _unformatted ) ) {
printer . print _newline ( false ) ;
}
this . _calcluate _parent _multiline ( printer , parser _token ) ;
}
} else if ( parser _token . is _end _tag ) { //this tag is a double tag so check for tag-ending
var do _end _expand = false ;
// deciding whether a block is multiline should not be this hard
do _end _expand = parser _token . start _tag _token && parser _token . start _tag _token . multiline _content ;
do _end _expand = do _end _expand || ( ! parser _token . is _inline _element &&
! ( last _tag _token . is _inline _element || last _tag _token . is _unformatted ) &&
! ( last _token . type === TOKEN . TAG _CLOSE && parser _token . start _tag _token === last _tag _token ) &&
last _token . type !== 'TK_CONTENT'
) ;
if ( parser _token . is _content _unformatted || parser _token . is _unformatted ) {
do _end _expand = false ;
}
if ( do _end _expand ) {
printer . print _newline ( false ) ;
}
} else { // it's a start-tag
parser _token . indent _content = ! parser _token . custom _beautifier _name ;
if ( parser _token . tag _start _char === '<' ) {
if ( parser _token . tag _name === 'html' ) {
parser _token . indent _content = this . _options . indent _inner _html ;
} else if ( parser _token . tag _name === 'head' ) {
parser _token . indent _content = this . _options . indent _head _inner _html ;
} else if ( parser _token . tag _name === 'body' ) {
parser _token . indent _content = this . _options . indent _body _inner _html ;
}
}
if ( ! ( parser _token . is _inline _element || parser _token . is _unformatted ) &&
( last _token . type !== 'TK_CONTENT' || parser _token . is _content _unformatted ) ) {
printer . print _newline ( false ) ;
}
this . _calcluate _parent _multiline ( printer , parser _token ) ;
}
} ;
Beautifier . prototype . _calcluate _parent _multiline = function ( printer , parser _token ) {
if ( parser _token . parent && printer . _output . just _added _newline ( ) &&
! ( ( parser _token . is _inline _element || parser _token . is _unformatted ) && parser _token . parent . is _inline _element ) ) {
parser _token . parent . multiline _content = true ;
}
} ;
//To be used for <p> tag special case:
2023-08-17 09:47:40 +00:00
var p _closers = [ 'address' , 'article' , 'aside' , 'blockquote' , 'details' , 'div' , 'dl' , 'fieldset' , 'figcaption' , 'figure' , 'footer' , 'form' , 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' , 'header' , 'hr' , 'main' , 'menu' , 'nav' , 'ol' , 'p' , 'pre' , 'section' , 'table' , 'ul' ] ;
2022-01-21 08:28:41 +00:00
var p _parent _excludes = [ 'a' , 'audio' , 'del' , 'ins' , 'map' , 'noscript' , 'video' ] ;
Beautifier . prototype . _do _optional _end _element = function ( parser _token ) {
var result = null ;
// NOTE: cases of "if there is no more content in the parent element"
// are handled automatically by the beautifier.
// It assumes parent or ancestor close tag closes all children.
// https://www.w3.org/TR/html5/syntax.html#optional-tags
if ( parser _token . is _empty _element || ! parser _token . is _start _tag || ! parser _token . parent ) {
return ;
}
if ( parser _token . tag _name === 'body' ) {
// A head element’ s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
result = result || this . _tag _stack . try _pop ( 'head' ) ;
//} else if (parser_token.tag_name === 'body') {
// DONE: A body element’ s end tag may be omitted if the body element is not immediately followed by a comment.
} else if ( parser _token . tag _name === 'li' ) {
// An li element’ s end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
2023-08-17 09:47:40 +00:00
result = result || this . _tag _stack . try _pop ( 'li' , [ 'ol' , 'ul' , 'menu' ] ) ;
2022-01-21 08:28:41 +00:00
} else if ( parser _token . tag _name === 'dd' || parser _token . tag _name === 'dt' ) {
// A dd element’ s end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
// A dt element’ s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
result = result || this . _tag _stack . try _pop ( 'dt' , [ 'dl' ] ) ;
result = result || this . _tag _stack . try _pop ( 'dd' , [ 'dl' ] ) ;
} else if ( parser _token . parent . tag _name === 'p' && p _closers . indexOf ( parser _token . tag _name ) !== - 1 ) {
// IMPORTANT: this else-if works because p_closers has no overlap with any other element we look for in this method
// check for the parent element is an HTML element that is not an <a>, <audio>, <del>, <ins>, <map>, <noscript>, or <video> element, or an autonomous custom element.
// To do this right, this needs to be coded as an inclusion of the inverse of the exclusion above.
// But to start with (if we ignore "autonomous custom elements") the exclusion would be fine.
var p _parent = parser _token . parent . parent ;
if ( ! p _parent || p _parent _excludes . indexOf ( p _parent . tag _name ) === - 1 ) {
result = result || this . _tag _stack . try _pop ( 'p' ) ;
}
} else if ( parser _token . tag _name === 'rp' || parser _token . tag _name === 'rt' ) {
// An rt element’ s end tag may be omitted if the rt element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
// An rp element’ s end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'rt' , [ 'ruby' , 'rtc' ] ) ;
result = result || this . _tag _stack . try _pop ( 'rp' , [ 'ruby' , 'rtc' ] ) ;
} else if ( parser _token . tag _name === 'optgroup' ) {
// An optgroup element’ s end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
// An option element’ s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'optgroup' , [ 'select' ] ) ;
//result = result || this._tag_stack.try_pop('option', ['select']);
} else if ( parser _token . tag _name === 'option' ) {
// An option element’ s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'option' , [ 'select' , 'datalist' , 'optgroup' ] ) ;
} else if ( parser _token . tag _name === 'colgroup' ) {
// DONE: A colgroup element’ s end tag may be omitted if the colgroup element is not immediately followed by a space character or a comment.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
} else if ( parser _token . tag _name === 'thead' ) {
// A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'colgroup' , [ 'table' ] ) ;
//} else if (parser_token.tag_name === 'caption') {
// DONE: A caption element’ s end tag may be omitted if the caption element is not immediately followed by a space character or a comment.
} else if ( parser _token . tag _name === 'tbody' || parser _token . tag _name === 'tfoot' ) {
// A thead element’ s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
// A tbody element’ s end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
// A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'colgroup' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'thead' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'tbody' , [ 'table' ] ) ;
//} else if (parser_token.tag_name === 'tfoot') {
// DONE: A tfoot element’ s end tag may be omitted if there is no more content in the parent element.
} else if ( parser _token . tag _name === 'tr' ) {
// A tr element’ s end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
// A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
// A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
result = result || this . _tag _stack . try _pop ( 'caption' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'colgroup' , [ 'table' ] ) ;
result = result || this . _tag _stack . try _pop ( 'tr' , [ 'table' , 'thead' , 'tbody' , 'tfoot' ] ) ;
} else if ( parser _token . tag _name === 'th' || parser _token . tag _name === 'td' ) {
// A td element’ s end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
// A th element’ s end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
result = result || this . _tag _stack . try _pop ( 'td' , [ 'table' , 'thead' , 'tbody' , 'tfoot' , 'tr' ] ) ;
result = result || this . _tag _stack . try _pop ( 'th' , [ 'table' , 'thead' , 'tbody' , 'tfoot' , 'tr' ] ) ;
}
// Start element omission not handled currently
// A head element’ s start tag may be omitted if the element is empty, or if the first thing inside the head element is an element.
// A tbody element’ s start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can’ t be omitted if the element is empty.)
// A colgroup element’ s start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can’ t be omitted if the element is empty.)
// Fix up the parent of the parser token
parser _token . parent = this . _tag _stack . get _parser _token ( ) ;
return result ;
} ;
module . exports . Beautifier = Beautifier ;
/***/ } ) ,
/* 20 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var BaseOptions = ( _ _webpack _require _ _ ( 6 ) . Options ) ;
2022-01-21 08:28:41 +00:00
function Options ( options ) {
BaseOptions . call ( this , options , 'html' ) ;
if ( this . templating . length === 1 && this . templating [ 0 ] === 'auto' ) {
this . templating = [ 'django' , 'erb' , 'handlebars' , 'php' ] ;
}
this . indent _inner _html = this . _get _boolean ( 'indent_inner_html' ) ;
this . indent _body _inner _html = this . _get _boolean ( 'indent_body_inner_html' , true ) ;
this . indent _head _inner _html = this . _get _boolean ( 'indent_head_inner_html' , true ) ;
this . indent _handlebars = this . _get _boolean ( 'indent_handlebars' , true ) ;
this . wrap _attributes = this . _get _selection ( 'wrap_attributes' ,
[ 'auto' , 'force' , 'force-aligned' , 'force-expand-multiline' , 'aligned-multiple' , 'preserve' , 'preserve-aligned' ] ) ;
2023-08-17 09:47:40 +00:00
this . wrap _attributes _min _attrs = this . _get _number ( 'wrap_attributes_min_attrs' , 2 ) ;
2022-01-21 08:28:41 +00:00
this . wrap _attributes _indent _size = this . _get _number ( 'wrap_attributes_indent_size' , this . indent _size ) ;
this . extra _liners = this . _get _array ( 'extra_liners' , [ 'head' , 'body' , '/html' ] ) ;
// Block vs inline elements
// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
// https://www.w3.org/TR/html5/dom.html#phrasing-content
this . inline = this . _get _array ( 'inline' , [
'a' , 'abbr' , 'area' , 'audio' , 'b' , 'bdi' , 'bdo' , 'br' , 'button' , 'canvas' , 'cite' ,
'code' , 'data' , 'datalist' , 'del' , 'dfn' , 'em' , 'embed' , 'i' , 'iframe' , 'img' ,
'input' , 'ins' , 'kbd' , 'keygen' , 'label' , 'map' , 'mark' , 'math' , 'meter' , 'noscript' ,
'object' , 'output' , 'progress' , 'q' , 'ruby' , 's' , 'samp' , /* 'script', */ 'select' , 'small' ,
'span' , 'strong' , 'sub' , 'sup' , 'svg' , 'template' , 'textarea' , 'time' , 'u' , 'var' ,
'video' , 'wbr' , 'text' ,
// obsolete inline tags
'acronym' , 'big' , 'strike' , 'tt'
] ) ;
2023-08-17 09:47:40 +00:00
this . inline _custom _elements = this . _get _boolean ( 'inline_custom_elements' , true ) ;
2022-01-21 08:28:41 +00:00
this . void _elements = this . _get _array ( 'void_elements' , [
// HTLM void elements - aka self-closing tags - aka singletons
// https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
'area' , 'base' , 'br' , 'col' , 'embed' , 'hr' , 'img' , 'input' , 'keygen' ,
'link' , 'menuitem' , 'meta' , 'param' , 'source' , 'track' , 'wbr' ,
// NOTE: Optional tags are too complex for a simple list
// they are hard coded in _do_optional_end_element
// Doctype and xml elements
'!doctype' , '?xml' ,
// obsolete tags
// basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
// isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
'basefont' , 'isindex'
] ) ;
this . unformatted = this . _get _array ( 'unformatted' , [ ] ) ;
this . content _unformatted = this . _get _array ( 'content_unformatted' , [
'pre' , 'textarea'
] ) ;
this . unformatted _content _delimiter = this . _get _characters ( 'unformatted_content_delimiter' ) ;
this . indent _scripts = this . _get _selection ( 'indent_scripts' , [ 'normal' , 'keep' , 'separate' ] ) ;
}
Options . prototype = new BaseOptions ( ) ;
module . exports . Options = Options ;
/***/ } ) ,
/* 21 */
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/*jshint node:true */
/ *
The MIT License ( MIT )
Copyright ( c ) 2007 - 2018 Einar Lielmanis , Liam Newman , and contributors .
Permission is hereby granted , free of charge , to any person
obtaining a copy of this software and associated documentation files
( the "Software" ) , to deal in the Software without restriction ,
including without limitation the rights to use , copy , modify , merge ,
publish , distribute , sublicense , and / or sell copies of the Software ,
and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND ,
EXPRESS OR IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY , FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER IN AN
ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE .
* /
2022-04-07 13:41:52 +00:00
var BaseTokenizer = ( _ _webpack _require _ _ ( 9 ) . Tokenizer ) ;
var BASETOKEN = ( _ _webpack _require _ _ ( 9 ) . TOKEN ) ;
var Directives = ( _ _webpack _require _ _ ( 13 ) . Directives ) ;
var TemplatablePattern = ( _ _webpack _require _ _ ( 14 ) . TemplatablePattern ) ;
var Pattern = ( _ _webpack _require _ _ ( 12 ) . Pattern ) ;
2022-01-21 08:28:41 +00:00
var TOKEN = {
TAG _OPEN : 'TK_TAG_OPEN' ,
TAG _CLOSE : 'TK_TAG_CLOSE' ,
ATTRIBUTE : 'TK_ATTRIBUTE' ,
EQUALS : 'TK_EQUALS' ,
VALUE : 'TK_VALUE' ,
COMMENT : 'TK_COMMENT' ,
TEXT : 'TK_TEXT' ,
UNKNOWN : 'TK_UNKNOWN' ,
START : BASETOKEN . START ,
RAW : BASETOKEN . RAW ,
EOF : BASETOKEN . EOF
} ;
var directives _core = new Directives ( /<\!--/ , /-->/ ) ;
var Tokenizer = function ( input _string , options ) {
BaseTokenizer . call ( this , input _string , options ) ;
this . _current _tag _name = '' ;
// Words end at whitespace or when a tag starts
// if we are indenting handlebars, they are considered tags
var templatable _reader = new TemplatablePattern ( this . _input ) . read _options ( this . _options ) ;
var pattern _reader = new Pattern ( this . _input ) ;
this . _ _patterns = {
word : templatable _reader . until ( /[\n\r\t <]/ ) ,
single _quote : templatable _reader . until _after ( /'/ ) ,
double _quote : templatable _reader . until _after ( /"/ ) ,
attribute : templatable _reader . until ( /[\n\r\t =>]|\/>/ ) ,
element _name : templatable _reader . until ( /[\n\r\t >\/]/ ) ,
handlebars _comment : pattern _reader . starting _with ( /{{!--/ ) . until _after ( /--}}/ ) ,
handlebars : pattern _reader . starting _with ( /{{/ ) . until _after ( /}}/ ) ,
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 ( /]]>/ ) ,
// https://en.wikipedia.org/wiki/Conditional_comment
conditional _comment : pattern _reader . starting _with ( /<!\[/ ) . until _after ( /]>/ ) ,
processing : pattern _reader . starting _with ( /<\?/ ) . until _after ( /\?>/ )
} ;
if ( this . _options . indent _handlebars ) {
this . _ _patterns . word = this . _ _patterns . word . exclude ( 'handlebars' ) ;
}
this . _unformatted _content _delimiter = null ;
if ( this . _options . unformatted _content _delimiter ) {
var literal _regexp = this . _input . get _literal _regexp ( this . _options . unformatted _content _delimiter ) ;
this . _ _patterns . unformatted _content _delimiter =
pattern _reader . matching ( literal _regexp )
. until _after ( literal _regexp ) ;
}
} ;
Tokenizer . prototype = new BaseTokenizer ( ) ;
Tokenizer . prototype . _is _comment = function ( current _token ) { // jshint unused:false
return false ; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
} ;
Tokenizer . prototype . _is _opening = function ( current _token ) {
return current _token . type === TOKEN . TAG _OPEN ;
} ;
Tokenizer . prototype . _is _closing = function ( current _token , open _token ) {
return current _token . type === TOKEN . TAG _CLOSE &&
( open _token && (
( ( current _token . text === '>' || current _token . text === '/>' ) && open _token . text [ 0 ] === '<' ) ||
( current _token . text === '}}' && open _token . text [ 0 ] === '{' && open _token . text [ 1 ] === '{' ) ) ) ;
} ;
Tokenizer . prototype . _reset = function ( ) {
this . _current _tag _name = '' ;
} ;
Tokenizer . prototype . _get _next _token = function ( previous _token , open _token ) { // jshint unused:false
var token = null ;
this . _readWhitespace ( ) ;
var c = this . _input . peek ( ) ;
if ( c === null ) {
return this . _create _token ( TOKEN . EOF , '' ) ;
}
token = token || this . _read _open _handlebars ( c , open _token ) ;
token = token || this . _read _attribute ( c , previous _token , open _token ) ;
token = token || this . _read _close ( c , open _token ) ;
token = token || this . _read _raw _content ( c , previous _token , open _token ) ;
token = token || this . _read _content _word ( 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 _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 ) ;
// We treat all comments as literals, even more than preformatted tags
// we only look for the appropriate closing marker
if ( peek1 === '!' ) {
resulting _string = this . _ _patterns . comment . read ( ) ;
// only process directive on html comments
if ( resulting _string ) {
directives = directives _core . get _directives ( resulting _string ) ;
if ( directives && directives . ignore === 'start' ) {
resulting _string += directives _core . readIgnored ( this . _input ) ;
}
} else {
resulting _string = this . _ _patterns . cdata . read ( ) ;
}
}
if ( resulting _string ) {
token = this . _create _token ( TOKEN . COMMENT , resulting _string ) ;
token . directives = directives ;
}
}
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 ;
if ( ! open _token ) {
if ( c === '<' ) {
resulting _string = this . _input . next ( ) ;
if ( this . _input . peek ( ) === '/' ) {
resulting _string += this . _input . next ( ) ;
}
resulting _string += this . _ _patterns . element _name . read ( ) ;
token = this . _create _token ( TOKEN . TAG _OPEN , resulting _string ) ;
}
}
return token ;
} ;
Tokenizer . prototype . _read _open _handlebars = function ( c , open _token ) {
var resulting _string = null ;
var token = null ;
if ( ! open _token ) {
if ( this . _options . indent _handlebars && c === '{' && this . _input . peek ( 1 ) === '{' ) {
if ( this . _input . peek ( 2 ) === '!' ) {
resulting _string = this . _ _patterns . handlebars _comment . read ( ) ;
resulting _string = resulting _string || this . _ _patterns . handlebars . read ( ) ;
token = this . _create _token ( TOKEN . COMMENT , resulting _string ) ;
} else {
resulting _string = this . _ _patterns . handlebars _open . read ( ) ;
token = this . _create _token ( TOKEN . TAG _OPEN , resulting _string ) ;
}
}
}
return token ;
} ;
Tokenizer . prototype . _read _close = function ( c , open _token ) {
var resulting _string = null ;
var token = null ;
if ( open _token ) {
if ( open _token . text [ 0 ] === '<' && ( c === '>' || ( c === '/' && this . _input . peek ( 1 ) === '>' ) ) ) {
resulting _string = this . _input . next ( ) ;
if ( c === '/' ) { // for close tag "/>"
resulting _string += this . _input . next ( ) ;
}
token = this . _create _token ( TOKEN . TAG _CLOSE , resulting _string ) ;
} else if ( open _token . text [ 0 ] === '{' && c === '}' && this . _input . peek ( 1 ) === '}' ) {
this . _input . next ( ) ;
this . _input . next ( ) ;
token = this . _create _token ( TOKEN . TAG _CLOSE , '}}' ) ;
}
}
return token ;
} ;
Tokenizer . prototype . _read _attribute = function ( c , previous _token , open _token ) {
var token = null ;
var resulting _string = '' ;
if ( open _token && open _token . text [ 0 ] === '<' ) {
if ( c === '=' ) {
token = this . _create _token ( TOKEN . EQUALS , this . _input . next ( ) ) ;
} else if ( c === '"' || c === "'" ) {
var content = this . _input . next ( ) ;
if ( c === '"' ) {
content += this . _ _patterns . double _quote . read ( ) ;
} else {
content += this . _ _patterns . single _quote . read ( ) ;
}
token = this . _create _token ( TOKEN . VALUE , content ) ;
} else {
resulting _string = this . _ _patterns . attribute . read ( ) ;
if ( resulting _string ) {
if ( previous _token . type === TOKEN . EQUALS ) {
token = this . _create _token ( TOKEN . VALUE , resulting _string ) ;
} else {
token = this . _create _token ( TOKEN . ATTRIBUTE , resulting _string ) ;
}
}
}
}
return token ;
} ;
Tokenizer . prototype . _is _content _unformatted = function ( tag _name ) {
// void_elements have no content and so cannot have unformatted content
// script and style tags should always be read as unformatted content
// finally content_unformatted and unformatted element contents are unformatted
return this . _options . void _elements . indexOf ( tag _name ) === - 1 &&
( this . _options . content _unformatted . indexOf ( tag _name ) !== - 1 ||
this . _options . unformatted . indexOf ( tag _name ) !== - 1 ) ;
} ;
Tokenizer . prototype . _read _raw _content = function ( c , previous _token , open _token ) { // jshint unused:false
var resulting _string = '' ;
if ( open _token && open _token . text [ 0 ] === '{' ) {
resulting _string = this . _ _patterns . handlebars _raw _close . read ( ) ;
} else if ( previous _token . type === TOKEN . TAG _CLOSE &&
previous _token . opened . text [ 0 ] === '<' && previous _token . text [ 0 ] !== '/' ) {
// ^^ empty tag has no content
var tag _name = previous _token . opened . text . substr ( 1 ) . toLowerCase ( ) ;
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 _or _cdata ( c ) ;
if ( token ) {
token . type = TOKEN . TEXT ;
return token ;
}
resulting _string = this . _input . readUntil ( new RegExp ( '</' + tag _name + '[\\n\\r\\t ]*?>' , 'ig' ) ) ;
} else if ( this . _is _content _unformatted ( tag _name ) ) {
resulting _string = this . _input . readUntil ( new RegExp ( '</' + tag _name + '[\\n\\r\\t ]*?>' , 'ig' ) ) ;
}
}
if ( resulting _string ) {
return this . _create _token ( TOKEN . TEXT , resulting _string ) ;
}
return null ;
} ;
Tokenizer . prototype . _read _content _word = function ( c ) {
var resulting _string = '' ;
if ( this . _options . unformatted _content _delimiter ) {
if ( c === this . _options . unformatted _content _delimiter [ 0 ] ) {
resulting _string = this . _ _patterns . unformatted _content _delimiter . read ( ) ;
}
}
if ( ! resulting _string ) {
resulting _string = this . _ _patterns . word . read ( ) ;
}
if ( resulting _string ) {
return this . _create _token ( TOKEN . TEXT , resulting _string ) ;
}
} ;
module . exports . Tokenizer = Tokenizer ;
module . exports . TOKEN = TOKEN ;
/***/ } )
/******/ ] ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/ // Check if module is in cache
/******/ var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ if ( cachedModule !== undefined ) {
/******/ return cachedModule . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ _ _webpack _modules _ _ [ moduleId ] ( module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var _ _webpack _exports _ _ = _ _webpack _require _ _ ( 18 ) ;
/******/ legacy _beautify _html = _ _webpack _exports _ _ ;
/******/
/******/ } ) ( )
;
var style _html = legacy _beautify _html ;
/* Footer */
if ( typeof define === "function" && define . amd ) {
// Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
define ( [ "require" , "./beautify" , "./beautify-css" ] , function ( requireamd ) {
var js _beautify = requireamd ( "./beautify" ) ;
var css _beautify = requireamd ( "./beautify-css" ) ;
return {
html _beautify : function ( html _source , options ) {
return style _html ( html _source , options , js _beautify . js _beautify , css _beautify . css _beautify ) ;
}
} ;
} ) ;
} else if ( typeof exports !== "undefined" ) {
// Add support for CommonJS. Just put this file somewhere on your require.paths
// and you will be able to `var html_beautify = require("beautify").html_beautify`.
var js _beautify = require ( './beautify.js' ) ;
var css _beautify = require ( './beautify-css.js' ) ;
exports . html _beautify = function ( html _source , options ) {
return style _html ( html _source , options , js _beautify . js _beautify , css _beautify . css _beautify ) ;
} ;
} else if ( typeof window !== "undefined" ) {
// If we're running a web page and don't have either of the above, add our one global
window . html _beautify = function ( html _source , options ) {
return style _html ( html _source , options , window . js _beautify , window . css _beautify ) ;
} ;
} else if ( typeof global !== "undefined" ) {
// If we don't even have window, try global.
global . html _beautify = function ( html _source , options ) {
return style _html ( html _source , options , global . js _beautify , global . css _beautify ) ;
} ;
}
} ( ) ) ;