yamlfmt

https://github.com/google/yamlfmt

Google 製 yaml フォーマッター「yamlfmt」を試してみる 2022

$ pkg search yamlfmt
yamlfmt-0.9.0                  Simple command line tool for formatting yaml files
$ sudo pkg install yamlfmt

https://github.com/google/yamlfmt/blob/main/docs/config-file.md#basic-formatter

ansible用

~/.config/yamlfmt/.yamlfmt

formatter:
  type: basic
  include_document_start: true
  retain_line_breaks: true 
  scan_folded_as_literal: true

I added scan_folded_as_literal: true because I noticed that it was reformatting my > string literal blocks to a single line, which I didn't like. Here's what it was doing:

   expected: >
-    Here comes a table <table>
-    <thead><tr><th>One</th><th>Two</th></tr></thead>
-    <tbody> <tr><td>1</td><td>2</td></tr> </tbody>
-    </table> Done
+    Here comes a table <table> <thead><tr><th>One</th><th>Two</th></tr></thead> <tbody> <tr><td>1</td><td>2</td></tr> </tbody> </table> Done

https://til.simonwillison.net/yaml/yamlfmt