Skip to content

Commit d4c2257

Browse files
committed
docs: add strict mode section to CLI documentation
1 parent fd60b6e commit d4c2257

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/cli.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ Use `--fragment` to parse the input as an HTML fragment (instead of a full docum
4242
echo '<li>Hi</li>' | justhtml - --fragment
4343
```
4444

45+
## Strict Mode
46+
47+
Use `--strict` to fail immediately and print an error to `stderr` if the input HTML contains parsing errors or is otherwise malformed according to the WHATWG specification.
48+
49+
```bash
50+
echo '</b>' | justhtml - --strict --fragment
51+
# Exits with code 2 and prints:
52+
# StrictModeError: Element 'b' has no matching start tag
53+
```
54+
4555
## Output formats
4656

4757
`--format` controls what is printed:
@@ -105,7 +115,7 @@ justhtml page.html --selector "main" --format text --separator "" --no-strip
105115

106116
- `0`: success
107117
- `1`: missing input path or no matches for the selector
108-
- `2`: invalid selector
118+
- `2`: invalid selector, or a parse error when `--strict` is enabled
109119

110120
## Real-world example
111121

0 commit comments

Comments
 (0)