diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-05-28 13:18:50 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-05-30 11:32:55 +0200 |
commit | d2cfaede5be420c7d8b701d97b98bc61b87e46d5 (patch) | |
tree | db0926a42c3b53df10b87671d1733391b831b517 /parser/pageparser/pageparser_shortcode_test.go | |
parent | 322d19a81fedbf423a047bdf286499d2e25d14be (diff) | |
download | hugo-d2cfaede5be420c7d8b701d97b98bc61b87e46d5.tar.gz hugo-d2cfaede5be420c7d8b701d97b98bc61b87e46d5.zip |
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
Diffstat (limited to 'parser/pageparser/pageparser_shortcode_test.go')
-rw-r--r-- | parser/pageparser/pageparser_shortcode_test.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/parser/pageparser/pageparser_shortcode_test.go b/parser/pageparser/pageparser_shortcode_test.go index 54580217c..ce1297573 100644 --- a/parser/pageparser/pageparser_shortcode_test.go +++ b/parser/pageparser/pageparser_shortcode_test.go @@ -51,6 +51,9 @@ var shortCodeLexerTests = []lexerTest{ {"simple with markup", `{{% sc1 %}}`, []Item{tstLeftMD, tstSC1, tstRightMD, tstEOF}}, {"with spaces", `{{< sc1 >}}`, []Item{tstLeftNoMD, tstSC1, tstRightNoMD, tstEOF}}, + {"indented on new line", "Hello\n {{% sc1 %}}", []Item{nti(tText, "Hello\n"), nti(tIndentation, " "), tstLeftMD, tstSC1, tstRightMD, tstEOF}}, + {"indented on new line tab", "Hello\n\t{{% sc1 %}}", []Item{nti(tText, "Hello\n"), nti(tIndentation, "\t"), tstLeftMD, tstSC1, tstRightMD, tstEOF}}, + {"indented on first line", " {{% sc1 %}}", []Item{nti(tIndentation, " "), tstLeftMD, tstSC1, tstRightMD, tstEOF}}, {"mismatched rightDelim", `{{< sc1 %}}`, []Item{ tstLeftNoMD, tstSC1, nti(tError, "unrecognized character in shortcode action: U+0025 '%'. Note: Parameters with non-alphanumeric args must be quoted"), |