htmlformat

package module
v0.0.0-...-c3d4a33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 5 Imported by: 3

README

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 github.com/a-h/htmlformat/cmd/htmlformat@latest

Usage

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Document

func Document(w io.Writer, r io.Reader) (err error)

Document formats a HTML document.

func Fragment

func Fragment(w io.Writer, r io.Reader) (err error)

Fragment formats a fragment of a HTML document.

func Nodes

func Nodes(w io.Writer, nodes []*html.Node) (err error)

Nodes formats a slice of HTML nodes.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL