Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add html-tidy formatter #173

Merged
merged 9 commits into from
Apr 22, 2023
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ The format is based on [Keep a Changelog].
by suppressing all logs from `ktlint`.

### Formatters

* [purs-tidy](https://github.com/natefaubion/purescript-tidy) for PureScript ([#182]).
* [`html-tidy`](https://www.html-tidy.org/) for HTML/XML ([#173]).

[#173]: https://github.com/radian-software/apheleia/pull/173
[#182]: https://github.com/radian-software/apheleia/pull/182

## 3.2 (released 2023-02-25)
Expand Down
16 changes: 16 additions & 0 deletions apheleia.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@
(gofumpt . ("gofumpt"))
(goimports . ("goimports"))
(google-java-format . ("google-java-format" "-"))
(html-tidy "tidy"
"--quiet" "yes"
"--tidy-mark" "no"
"--vertical-space" "yes"
"-indent"
(when (derived-mode-p 'nxml-mode)
"-xml")
(apheleia-formatters-indent
"--indent-with-tabs"
"--indent-spaces"
(cond
((derived-mode-p 'nxml-mode)
'nxml-child-indent)
((derived-mode-p 'web-mode)
'web-mode-indent-style)))
(apheleia-formatters-fill-column "-wrap"))
(isort . ("isort" "-"))
(lisp-indent . apheleia-indent-lisp-buffer)
(ktlint . ("ktlint" "--log-level=none" "--stdin" "-F" "-"))
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/html-tidy.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt-get install -y tidy
1 change: 1 addition & 0 deletions test/formatters/samplecode/html-tidy/in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><title>Hello world</title></head><body><ul><li>1</li><li>2</li><li><ul><li>3</li></ul></li></ul></body></html>
19 changes: 19 additions & 0 deletions test/formatters/samplecode/html-tidy/out.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello world</title>
</head>
<body>
<ul>
<li>1</li>

<li>2</li>

<li>
<ul>
<li>3</li>
</ul>
</li>
</ul>
</body>
</html>