From ae61446a21bb4983308e5e20af2d21409e6a64cc Mon Sep 17 00:00:00 2001 From: spekary Date: Wed, 16 Mar 2022 19:35:54 -0700 Subject: [PATCH 1/2] Fixing some documentation --- README.md | 5 +++++ class.go | 2 +- style.go | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 94e03e5..023660d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,11 @@ html5tag does some checks to make sure tags are well-formed. For example, when adding data-* attributes, it will make sure the key used for the attribute does not violate html syntax rules. +html5tag has options to pretty-print tags and the content of tags so they appear formatted +in a document. However, in certain contexts, like in inline text, or in a textarea tag, adding +extra returns and spaces changes the look of the output. In these situations, use the functions +that do not add spaces to the inner HTML of a tag. + Some examples: ```go diff --git a/class.go b/class.go index 023b902..920f993 100644 --- a/class.go +++ b/class.go @@ -79,7 +79,7 @@ func RemoveWords(originalValues string, removeValues string) string { // Bootstrap uses 'col-lg-6' to represent a table that is 6 units wide on large screens and Foundation // uses 'large-6' to do the same thing. This utility removes classes that start with a particular prefix // to remove whatever sizing class was specified. -// Returns the resulting class list, and true if the list actually changed. +// Returns the resulting class list. func RemoveClassesWithPrefix(class string, prefix string) string { classes := strings.Fields(class) ret := "" diff --git a/style.go b/style.go index 0c3dce8..45605f9 100644 --- a/style.go +++ b/style.go @@ -142,8 +142,6 @@ func (s Style) SetChanged(property string, value string) (changed bool, err erro } // Set is like SetChanged, but returns the Style for chaining. -// -// It will also allocate a style if passed a nil style, and return it. func (s Style) Set(property string, value string) Style { _, err := s.SetChanged(property, value) if err != nil { From 0c5c691a6a8654f4ffb1156063ed78a0e2d90e10 Mon Sep 17 00:00:00 2001 From: spekary Date: Wed, 16 Mar 2022 19:55:02 -0700 Subject: [PATCH 2/2] Fixing lint errors --- attributes.go | 3 +-- tag_test.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/attributes.go b/attributes.go index 89a6c58..ac31bf1 100644 --- a/attributes.go +++ b/attributes.go @@ -743,9 +743,8 @@ func ValueString(i interface{}) string { case bool: if v { return "" // boolean true - } else { - return FalseValue // Our special value to indicate to NOT print the attribute at all } + return FalseValue // Our special value to indicate to NOT print the attribute at all case string: return v case int: diff --git a/tag_test.go b/tag_test.go index 47b0c55..48e1386 100644 --- a/tag_test.go +++ b/tag_test.go @@ -18,9 +18,8 @@ func (b *errBuffer) Write(p []byte) (n int, err error) { l := b.cap - b.buf.Len() n, _ = b.Write(p[:l]) return n, fmt.Errorf("out of memory") - } else { - return b.buf.Write(p) } + return b.buf.Write(p) } func newErrBuf(cap int) *errBuffer {