mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 12:41:20 -08:00
72 lines
3.2 KiB
Plaintext
72 lines
3.2 KiB
Plaintext
/*
|
|
|
|
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 {{/foo}}
|
|
end_with_newline (false) - end with a newline
|
|
extra_liners (default [head,body,/html]) -List of tags that should have an extra newline before them.
|
|
|
|
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']
|
|
});
|
|
*/ |