Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/staging/main' into staging/release
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Action committed Oct 21, 2022
2 parents 55af767 + fded96d commit 90b32ec
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## v1.14.7
* Doc: Updates web browser implementation examples ([#2107](https://github.com/beautify-web/js-beautify/pull/2107))
* HTML formatter breaks layout by introducing newlines ([#1989](https://github.com/beautify-web/js-beautify/issues/1989))

## v1.14.6
* Globs no longer work on Windows in 1.14.5 ([#2093](https://github.com/beautify-web/js-beautify/issues/2093))

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -7,7 +7,7 @@ If you find a bug, please report it, including environment and examples of curre
## How to Make Changes (Implement Fixes and New Features)
Fixes and enhancements are totally welcome. We prefer you to file an issue before filing a PR, as this gives us chance to discuss design details, but feel free to dive right in.

### 0. Prereqisites for development
### 0. Prerequisites for development

* bash
* make
Expand Down Expand Up @@ -85,7 +85,7 @@ This project has been around for a while. While some parts have improved signif
into disrepair and were mothballed. All branches named `attic-*` are significantly out of date and kept for reference purposes only.

### PHP
`attic-php` contains a PHP implmenetation of the beautifier.
`attic-php` contains a PHP implementation of the beautifier.
If you're interested in using it feel free.
If you plan to enhance it, please consider joining this project, and updating this version to match current functionality.

Expand Down
51 changes: 43 additions & 8 deletions README.md
Expand Up @@ -58,15 +58,29 @@ 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.6/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.6/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.6/beautify-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.7/beautify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.7/beautify-css.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.7/beautify-html.js"></script>

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

Example usage of a JS tag in html:

```html
<!DOCTYPE html>
<html lang="en">
<body>

. . .

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.14.7/beautify.min.js"></script>
<script src="script.js"></script>
</body>
</html>
```
Older versions are available by changing the version number.

Disclaimer: These are free services, so there are [no uptime or support guarantees](https://github.com/rgrove/rawgit/wiki/Frequently-Asked-Questions#i-need-guaranteed-100-uptime-should-i-use-cdnrawgitcom).
Expand All @@ -91,7 +105,28 @@ You can beautify JavaScript using JS Beautifier in your web browser, or on the c
Open [beautifier.io](https://beautifier.io/). Options are available via the UI.

## Web Library
The script tags above expose three functions: `js_beautify`, `css_beautify`, and `html_beautify`.
After you embed the `<script>` tags in your `html` file, they expose three functions: `js_beautify`, `css_beautify`, and `html_beautify`

Example usage of beautifying a json string:

```js
const options = { indent_size: 2, space_in_empty_paren: true }

const dataObj = {completed: false,id: 1,title: "delectus aut autem",userId: 1,}

const dataJson = JSON.stringify(dataObj)

js_beautify(dataJson, options)

/* OUTPUT
{
"completed": false,
"id": 1,
"title": "delectus aut autem",
"userId": 1,
}
*/
```

## Node.js JavaScript

Expand Down Expand Up @@ -397,4 +432,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: js-beautify@1.14.6)
(README.md: js-beautify@1.14.7)
2 changes: 1 addition & 1 deletion js/src/html/beautifier.js
Expand Up @@ -658,7 +658,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_start_char === '{';
parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || parser_token.tag_name.includes("-") || parser_token.tag_start_char === '{';

return parser_token;
};
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "js-beautify",
"version": "1.14.6",
"version": "1.14.7",
"description": "beautifier.io for node",
"main": "js/index.js",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion python/cssbeautifier/__version__.py
@@ -1 +1 @@
__version__ = "1.14.6"
__version__ = "1.14.7"
2 changes: 1 addition & 1 deletion python/jsbeautifier/__version__.py
@@ -1 +1 @@
__version__ = "1.14.6"
__version__ = "1.14.7"
40 changes: 40 additions & 0 deletions test/data/html/tests.js
Expand Up @@ -3642,6 +3642,46 @@ exports.test_data = {
'{{/row}}'
]
}]
}, {
name: "Does not add whitespace around custom elements ",
description: "Regression test for https://github.com/beautify-web/js-beautify/issues/1989",
tests: [{
input: [
'<span>',
' <span>',
' <span>The time for this result is 1:02</span',
' ><div>.</div',
' ><section>27</section>',
' </span>',
'</span>'
],
output: [
'<span>',
' <span>',
' <span>The time for this result is 1:02</span>',
' <div>.</div>',
' <section>27</section>',
' </span>',
'</span>'
]
}, {
input: [
'<span>',
' <span>',
' <span>The time for this result is 1:02</span',
' ><time-dot>.</time-dot',
' ><time-decimals>27</time-decimals>',
' </span>',
'</span>'
],
output: [
'<span>',
' <span>',
' <span>The time for this result is 1:02</span><time-dot>.</time-dot><time-decimals>27</time-decimals>',
' </span>',
'</span>'
]
}]
}, {
name: "New Test Suite"
}]
Expand Down

0 comments on commit 90b32ec

Please sign in to comment.