diff --git a/requirements.txt b/requirements.txt
index c704949..d85380e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,12 +4,15 @@ black==22.1.0; python_full_version >= "3.6.2"
click==8.0.3; python_version >= "3.6"
colorama==0.4.4; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
coverage==6.4.2; python_version >= "3.7"
+cssbeautifier==1.14.4
+editorconfig==0.12.3
execnet==1.9.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
html-tag-names==0.1.2; python_version >= "3.7" and python_version < "4.0"
html-void-elements==0.1.0; python_version >= "3.7" and python_version < "4.0"
importlib-metadata==4.11.0; python_version >= "3.7"
iniconfig==1.1.1; python_version >= "3.7"
isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0"
+jsbeautifier==1.14.4
mypy-extensions==0.4.3; python_full_version >= "3.6.2"
packaging==21.3; python_version >= "3.7"
pathspec==0.9.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
@@ -23,6 +26,7 @@ pytest-xdist==2.5.0; python_version >= "3.6"
pytest==7.1.2; python_version >= "3.7"
pyyaml==6.0; python_version >= "3.6"
regex==2022.1.18
+six==1.16.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0"
tomli==2.0.1; python_full_version <= "3.11.0a6" and python_version >= "3.7" and python_full_version >= "3.6.2" or python_version < "3.11"
tqdm==4.62.3; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
typed-ast==1.4.3; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.6.2"
diff --git a/src/djlint/formatter/css.py b/src/djlint/formatter/css.py
index 5c54502..8698eb3 100644
--- a/src/djlint/formatter/css.py
+++ b/src/djlint/formatter/css.py
@@ -13,9 +13,13 @@ def format_css(html: str, config: Config) -> str:
def launch_formatter(config: Config, match: re.Match) -> str:
"""Add break after if not in ignored block."""
+ if not match.group(3).strip():
+ return match.group()
+
indent = len(match.group(1)) * " "
inner_indent = indent + config.indent
opts = BeautifierOptions(config.css_config)
+
beautified = (
"\n"
+ inner_indent
@@ -30,7 +34,7 @@ def format_css(html: str, config: Config) -> str:
return re.sub(
re.compile(
- r"([ ]*?)()",
+ r"([ ]*?)(<(?:style)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}])*>)(.*?)(?=)",
re.IGNORECASE | re.DOTALL,
),
func,
diff --git a/src/djlint/formatter/js.py b/src/djlint/formatter/js.py
index ef410be..8f71108 100644
--- a/src/djlint/formatter/js.py
+++ b/src/djlint/formatter/js.py
@@ -13,6 +13,9 @@ def format_js(html: str, config: Config) -> str:
def launch_formatter(config: Config, match: re.Match) -> str:
"""Add break after if not in ignored block."""
+ if not match.group(3).strip():
+ return match.group()
+
indent = len(match.group(1)) * " "
inner_indent = indent + config.indent
opts = BeautifierOptions(config.js_config)
@@ -31,7 +34,7 @@ def format_js(html: str, config: Config) -> str:
return re.sub(
re.compile(
- r"([ ]*?)()",
+ r"([ ]*?)(<(?:script)\b(?:\"[^\"]*\"|'[^']*'|{[^}]*}|[^'\">{}])*>)(.*?)(?=)",
re.IGNORECASE | re.DOTALL,
),
func,
diff --git a/tests/test_config/test_scripts_styles/html.html b/tests/test_config/test_scripts_styles/html.html
index 12f6a71..a63d504 100644
--- a/tests/test_config/test_scripts_styles/html.html
+++ b/tests/test_config/test_scripts_styles/html.html
@@ -15,3 +15,7 @@
width: 12px
}
+
+
+
+