1
1
Fork
You've already forked htmlformat
0
Go package and CLI tool used to format HTML
  • Go 100%
2026年02月06日 21:24:17 +01:00
cmd/htmlformat make indent string configurable (default 2 spaces) 2025年10月11日 12:54:25 +02:00
.gitignore ignore build output 2025年10月10日 23:10:42 +02:00
format.go fix unescaping of html entities in <code> tags 2026年02月06日 21:24:17 +01:00
format_test.go fix unescaping of html entities in <code> tags 2026年02月06日 21:24:17 +01:00
go.mod update go version 2026年02月06日 16:59:09 +01:00
go.sum feat: skip formatting scripts ( #3 ) 2025年05月07日 18:38:18 +02:00
LICENSE feat: first commit 2023年04月17日 11:56:37 +01:00
README.md rename module 2025年10月10日 23:30:08 +02:00

htmlformat

htmlformat is a Go package and CLI tool used to format HTML.

It is forked and simplified from the https://github.com/ericchiang/pup package.

It does not aim to:

  • Colorize output.
  • Modify the input HTML except for formatting (i.e. no HTML escaping will be applied).
  • Provide any facilities to query the content.

Installation

To use the CLI, you can install with Go > 1.20.

go install alin.ovh/htmlformat/cmd/htmlformat@latest

Usage

CLI

echo '<ol><li style="&"><em>A</em></li><li>B</li></ol>' | htmlformat
<ol>
 <li style="&">
 <em>A</em>
 </li>
 <li>B</li>
</ol>

Package

r:=strings.NewReader(`<ol><li style="&">A</li><li>B</li></ol>`)w:=os.Stdoutiferr:=Fragment(w,r);err!=nil{log.Fatalf("failed to format: %v",err)}