Skip to content

Commit

Permalink
Add html-tidy formatter (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohkale authored Apr 22, 2023
1 parent 568862d commit 2686e7b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ The format is based on [Keep a Changelog].
for [Bazel Build](https://bazel.build/) ([#171]).
* [`cmake-format`](https://github.com/cheshirekow/cmake_format)
for [CMake](https://cmake.org/) ([#172]).
* [`html-tidy`](https://www.html-tidy.org/) for HTML/XML ([#173]).

[#168]: https://github.com/radian-software/apheleia/pull/168
[#169]: https://github.com/radian-software/apheleia/pull/169
[#170]: https://github.com/radian-software/apheleia/pull/170
[#171]: https://github.com/radian-software/apheleia/pull/171
[#172]: https://github.com/radian-software/apheleia/pull/172
[#173]: https://github.com/radian-software/apheleia/pull/173
[#174]: https://github.com/radian-software/apheleia/pull/174
[#182]: https://github.com/radian-software/apheleia/pull/182
[#187]: https://github.com/radian-software/apheleia/pull/187
Expand Down
16 changes: 16 additions & 0 deletions apheleia.el
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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" "-"))
(jq "jq" "."
(apheleia-formatters-js-indent "--tab" "--indent"))
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>

0 comments on commit 2686e7b

Please sign in to comment.