Improve shortcode indentation handling

* Record the leading whitespace (tabs, spaces) before the shortcode when parsing the page.
* Apply that indentation to the rendered result of shortcodes without inner content (where the user will apply indentation).

Fixes #9946
This commit is contained in:
Bjørn Erik Pedersen 2022-05-28 13:18:50 +02:00
parent 322d19a81f
commit d2cfaede5b
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
9 changed files with 208 additions and 4 deletions

View file

@ -61,3 +61,17 @@ func Puts(s string) string {
}
return s + "\n"
}
// VisitLinesAfter calls the given function for each line, including newlines, in the given string.
func VisitLinesAfter(s string, fn func(line string)) {
high := strings.Index(s, "\n")
for high != -1 {
fn(s[:high+1])
s = s[high+1:]
high = strings.Index(s, "\n")
}
if s != "" {
fn(s)
}
}