Skip to content

Commit

Permalink
Merge pull request #2167 from beautify-web/staging/release
Browse files Browse the repository at this point in the history
Pulling staging/release into release
  • Loading branch information
bitwiseman authored Jul 20, 2023
2 parents f2a11a3 + 3936d74 commit 11e21b0
Show file tree
Hide file tree
Showing 21 changed files with 148 additions and 55 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v1.14.9
* Bump semver and editorconfig ([#2161](https://github.com/beautify-web/js-beautify/pull/2161))
* Update editorconfig package ([#2160](https://github.com/beautify-web/js-beautify/issues/2160))
* Allow to configure the "custom elements as inline elements" behavior ([#2113](https://github.com/beautify-web/js-beautify/issues/2113))

## v1.14.8
* Require nodejs v12 or greater ([#2151](https://github.com/beautify-web/js-beautify/pull/2151))
* CSS insideNonNestedAtRule generic variable ([#2147](https://github.com/beautify-web/js-beautify/pull/2147))
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ JS Beautifier is hosted on two CDN services: [cdnjs](https://cdnjs.com/libraries

To pull the latest version from one of these services include one set of the script tags below in your document:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.8/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.8/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.8/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.9/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.9/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.9/beautify-html.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.8/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.8/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.8/beautify-html.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.9/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.9/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.9/beautify-html.min.js"></script>
```

Example usage of a JS tag in html:
Expand All @@ -76,7 +76,7 @@ Example usage of a JS tag in html:

. . .

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.8/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.9/beautify.min.js"></script>
<script src="script.js"></script>
</body>
</html>
Expand Down Expand Up @@ -371,6 +371,7 @@ HTML Beautifier Options:
-M, --wrap-attributes-min-attrs Minimum number of html tag attributes for force wrap attribute options [2]
-i, --wrap-attributes-indent-size Indent wrapped attributes to after N characters [indent-size] (ignored if wrap-attributes is "aligned")
-d, --inline List of tags to be considered inline tags
--inline_custom_elements Inline custom elements [true]
-U, --unformatted List of tags (defaults to inline) that should not be reformatted
-T, --content_unformatted List of tags (defaults to pre) whose content should not be reformatted
-E, --extra_liners List of tags (defaults to [head,body,/html] that should have an extra newline before them.
Expand Down Expand Up @@ -433,4 +434,4 @@ Thanks also to Jason Diamond, Patrick Hof, Nochum Sossonko, Andreas Schneider, D
Vasilevsky, Vital Batmanov, Ron Baldwin, Gabriel Harrison, Chris J. Shull,
Mathias Bynens, Vittorio Gambaletta and others.
(README.md: [email protected].8)
(README.md: [email protected].9)
3 changes: 2 additions & 1 deletion js/lib/beautifier.js

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

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion js/lib/beautify-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,7 @@ Beautifier.prototype._get_tag_open_token = function(raw_token) { //function to g

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);
parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || parser_token.tag_name.includes("-") || parser_token.tag_start_char === '{';
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 === '{';

return parser_token;
};
Expand Down Expand Up @@ -2691,6 +2691,7 @@ function Options(options) {
// obsolete inline tags
'acronym', 'big', 'strike', 'tt'
]);
this.inline_custom_elements = this._get_boolean('inline_custom_elements', true);
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
Expand Down
2 changes: 2 additions & 0 deletions js/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ var path = require('path'),
// HTML-only
"max_char": Number, // obsolete since 1.3.5
"inline": [String, Array],
"inline_custom_elements": [Boolean],
"unformatted": [String, Array],
"content_unformatted": [String, Array],
"indent_inner_html": [Boolean],
Expand Down Expand Up @@ -168,6 +169,7 @@ var path = require('path'),
"i": ["--wrap_attributes_indent_size"],
"W": ["--max_char"], // obsolete since 1.3.5
"d": ["--inline"],
// no shorthand for "inline_custom_elements"
"U": ["--unformatted"],
"T": ["--content_unformatted"],
"I": ["--indent_inner_html"],
Expand Down
2 changes: 2 additions & 0 deletions js/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ var path = require('path'),
// HTML-only
"max_char": Number, // obsolete since 1.3.5
"inline": [String, Array],
"inline_custom_elements": [Boolean],
"unformatted": [String, Array],
"content_unformatted": [String, Array],
"indent_inner_html": [Boolean],
Expand Down Expand Up @@ -168,6 +169,7 @@ var path = require('path'),
"i": ["--wrap_attributes_indent_size"],
"W": ["--max_char"], // obsolete since 1.3.5
"d": ["--inline"],
// no shorthand for "inline_custom_elements"
"U": ["--unformatted"],
"T": ["--content_unformatted"],
"I": ["--indent_inner_html"],
Expand Down
2 changes: 1 addition & 1 deletion js/src/html/beautifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ Beautifier.prototype._get_tag_open_token = function(raw_token) { //function to g

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);
parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || parser_token.tag_name.includes("-") || parser_token.tag_start_char === '{';
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 === '{';

return parser_token;
};
Expand Down
1 change: 1 addition & 0 deletions js/src/html/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function Options(options) {
// obsolete inline tags
'acronym', 'big', 'strike', 'tt'
]);
this.inline_custom_elements = this._get_boolean('inline_custom_elements', true);
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
Expand Down
23 changes: 23 additions & 0 deletions js/test/generated/beautify-html-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9269,6 +9269,29 @@ function run_html_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_be
'</span>');


//============================================================
// Disables custom elements inlining with inline_custom_elements=false
reset_options();
set_name('Disables custom elements inlining with inline_custom_elements=false');
opts.inline_custom_elements = false;
bth(
'<span>\n' +
' <span>\n' +
' <span>The time for this result is 1:02</span\n' +
' ><time-dot>.</time-dot\n' +
' ><time-decimals>27</time-decimals>\n' +
' </span>\n' +
'</span>',
// -- output --
'<span>\n' +
' <span>\n' +
' <span>The time for this result is 1:02</span>\n' +
' <time-dot>.</time-dot>\n' +
' <time-decimals>27</time-decimals>\n' +
' </span>\n' +
'</span>');


//============================================================
// New Test Suite
reset_options();
Expand Down
95 changes: 62 additions & 33 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-beautify",
"version": "1.14.8",
"version": "1.14.9",
"description": "beautifier.io for node",
"main": "js/index.js",
"bin": {
Expand Down Expand Up @@ -50,7 +50,7 @@
"browserslist": "ie 11",
"dependencies": {
"config-chain": "^1.1.13",
"editorconfig": "^0.15.3",
"editorconfig": "^1.0.3",
"glob": "^8.1.0",
"nopt": "^6.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion python/cssbeautifier/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.14.8"
__version__ = "1.14.9"
1 change: 1 addition & 0 deletions python/cssbeautifier/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty file :)
2 changes: 1 addition & 1 deletion python/jsbeautifier/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.14.8"
__version__ = "1.14.9"
1 change: 1 addition & 0 deletions python/jsbeautifier/tests/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty file :)
4 changes: 2 additions & 2 deletions python/jsbeautifier/tests/generated/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10075,7 +10075,7 @@ def test_beautifier_unconverted(self):
test_fragment('foo {', 'foo {')
test_fragment('return {', 'return {') # return needs the brace.
test_fragment('return /* inline */ {', 'return /* inline */ {')
test_fragment('return;\n{', 'return; {')
test_fragment('return;\n{', 'return;\n{')
bt("throw {}")
bt("throw {\n foo;\n}")
bt('var foo = {}')
Expand Down Expand Up @@ -10166,7 +10166,7 @@ def test_beautifier_unconverted(self):
test_fragment('foo {', 'foo {')
test_fragment('return {', 'return {') # return needs the brace.
test_fragment('return /* inline */ {', 'return /* inline */ {')
test_fragment('return;\n{', 'return; {')
test_fragment('return;\n{', 'return;\n{')
bt("throw {}")
bt("throw {\n foo;\n}")
bt('var foo = {}')
Expand Down
Loading

0 comments on commit 11e21b0

Please sign in to comment.