Skip to content

Commit 9244d0e

Browse files
authored
Merge branch 'main' into fix/css-media-query-range-operator-spacing
2 parents dea7915 + 6121692 commit 9244d0e

30 files changed

Lines changed: 800 additions & 576 deletions

.github/workflows/main.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: [ ubuntu, windows, macos ]
20-
python-version: ['3.10', 3.11]
20+
python-version: [3.11, 3.12, 3.14]
2121
include:
22-
- python-version: '3.10'
23-
node-version: 16
24-
- python-version: 3.11
25-
node-version: 18
26-
- python-version: 3.11
27-
node-version: 20
22+
- python-version: 3.11
23+
node-version: 22
24+
- python-version: 3.12
25+
node-version: 24
26+
- python-version: 3.14
27+
node-version: 26
2828
steps:
2929
- uses: actions/checkout@v6
3030
- name: Set up Node ${{ matrix.node-version }}

.github/workflows/milestone-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ jobs:
1818
- name: Set up Node
1919
uses: actions/setup-node@v6
2020
with:
21-
node-version: 18
21+
node-version: 26
2222
registry-url: https://registry.npmjs.org/
2323
- name: Set up Python
2424
uses: actions/setup-python@v6
2525
with:
26-
python-version: 3.11
26+
python-version: 3.14
2727
- name: Set git user
2828
run: |
2929
git config --global user.email "github-action@users.noreply.github.com"

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PROJECT_ROOT=$(subst \,/,$(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
22
BUILD_DIR=$(PROJECT_ROOT)build
33
SCRIPT_DIR=$(PROJECT_ROOT)tools
44
SHELL=/bin/bash
5-
PYTHON=$(SCRIPT_DIR)/python
5+
PYTHON=$(SCRIPT_DIR)/python-dev python
66
NODE=$(SCRIPT_DIR)/node
77
NPM=$(SCRIPT_DIR)/npm
88

@@ -146,7 +146,8 @@ $(BUILD_DIR)/virtualenv: | $(BUILD_DIR)
146146
virtualenv build/python-rel
147147
$(SCRIPT_DIR)/python-dev python -m pip install --upgrade pip || exit 0
148148
$(SCRIPT_DIR)/python-rel python -m pip install --upgrade pip || exit 0
149-
$(SCRIPT_DIR)/python-dev3 pip install black
149+
$(SCRIPT_DIR)/python-dev pip install setuptools black
150+
$(SCRIPT_DIR)/python-rel pip install setuptools
150151
@touch $(BUILD_DIR)/virtualenv
151152

152153

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Unlike the JavaScript version, the Python version can only reformat JavaScript.
9797
```bash
9898
$ pip install cssbeautifier
9999
```
100+
Note: This project no longer supports Python 2.
100101

101102
# Usage
102103
You can beautify JavaScript using JS Beautifier in your web browser, or on the command-line using Node.js or Python.

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,19 @@ <h2>Options</h2>
148148
</div>
149149
</div>
150150

151+
<div>
152+
<p style="margin:6px 0 0 0">HTML attribute wrapping:</p>
153+
<select id="wrap-attributes">
154+
<option value="auto">Wrap when line is too long</option>
155+
<option value="force">Wrap each attribute</option>
156+
<option value="force-aligned">Wrap and align attributes</option>
157+
<option value="force-expand-multiline">Always wrap multiline</option>
158+
<option value="aligned-multiple">Align multiple attributes</option>
159+
<option value="preserve">Preserve wrapping</option>
160+
<option value="preserve-aligned">Preserve and align</option>
161+
</select>
162+
</div>
163+
151164
<div class="options-checkboxes">
152165
<input class="checkbox" type="checkbox" id="end-with-newline">
153166
<label for="end-with-newline">End script and style with newline?</label>

js/src/html/beautifier.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ var get_custom_beautifier_name = function(tag_check, raw_token) {
166166
// For those without a type attribute use default;
167167
if (typeAttribute.search('text/css') > -1) {
168168
result = 'css';
169-
} else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
169+
} else if (typeAttribute.search(/module|importmap|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
170170
result = 'javascript';
171171
} else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
172172
result = 'html';

js/src/javascript/beautifier.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,16 @@ function split_linebreaks(s) {
104104
//return s.split(/\x0d\x0a|\x0a/);
105105

106106
s = s.replace(acorn.allLineBreaks, '\n');
107-
var out = [],
108-
idx = s.indexOf("\n");
107+
var out = [];
108+
var start = 0;
109+
var idx = s.indexOf("\n", start);
109110
while (idx !== -1) {
110-
out.push(s.substring(0, idx));
111-
s = s.substring(idx + 1);
112-
idx = s.indexOf("\n");
111+
out.push(s.substring(start, idx));
112+
start = idx + 1;
113+
idx = s.indexOf("\n", start);
113114
}
114-
if (s.length) {
115-
out.push(s);
115+
if (start < s.length) {
116+
out.push(s.substring(start));
116117
}
117118
return out;
118119
}

0 commit comments

Comments
 (0)