fix indentation of script/style tags
2 files changed, 3 insertions(+), 7 deletions(-)
changed files
M format.go → format.go
@@ -177,7 +177,7 @@ return } } if !isVoidElement(n) { - if err = printChildren(w, n, isPreFormatted(n.Data), level+1); err != nil { + if err = printChildren(w, n, n.Data == "pre", level+1); err != nil { return } if isSpecialContentElement(n) || !hasSingleTextChild(n) {@@ -212,10 +212,6 @@ return } } return -} - -func isPreFormatted(s string) bool { - return s == "pre" || s == "script" || s == "style" } func printChildren(w io.Writer, n *html.Node, pre bool, level int) (err error) {
M format_test.go → format_test.go
@@ -53,12 +53,12 @@ input: `test 123`, expected: `test 123` + "\n", }, { - name: "script tags are not formatted", + name: "script tags are only indented", input: `<script> var x = 1; </script>`, expected: `<script> - var x = 1; + var x = 1; </script>` + "\n", }, {