mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Add "target" and "rel" parameters to figure shortcode
Also: - Remove unnecessary space from `figure` tag if no class is specified. - Update related tests. - Add test cases for the changes made to the figure shortcode. - Document the newly added target and rel parameters - Add more detail to the documentation of all figure shortcode parameters.
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
76d38d5e53
commit
2e95ec6844
@@ -293,6 +293,11 @@ func TestParentShortcode(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestFigureOnlySrc(t *testing.T) {
|
||||
t.Parallel()
|
||||
CheckShortCodeMatch(t, `{{< figure src="/found/here" >}}`, "\n<figure>\n \n <img src=\"/found/here\" />\n \n \n</figure>\n", nil)
|
||||
}
|
||||
|
||||
func TestFigureImgWidth(t *testing.T) {
|
||||
t.Parallel()
|
||||
CheckShortCodeMatch(t, `{{% figure src="/found/here" class="bananas orange" alt="apple" width="100px" %}}`, "\n<figure class=\"bananas orange\">\n \n <img src=\"/found/here\" alt=\"apple\" width=\"100px\" />\n \n \n</figure>\n", nil)
|
||||
@@ -308,6 +313,21 @@ func TestFigureImgWidthAndHeight(t *testing.T) {
|
||||
CheckShortCodeMatch(t, `{{% figure src="/found/here" class="bananas orange" alt="apple" width="50" height="100" %}}`, "\n<figure class=\"bananas orange\">\n \n <img src=\"/found/here\" alt=\"apple\" width=\"50\" height=\"100\" />\n \n \n</figure>\n", nil)
|
||||
}
|
||||
|
||||
func TestFigureLinkNoTarget(t *testing.T) {
|
||||
t.Parallel()
|
||||
CheckShortCodeMatch(t, `{{< figure src="/found/here" link="/jump/here/on/clicking" >}}`, "\n<figure>\n <a href=\"/jump/here/on/clicking\">\n <img src=\"/found/here\" />\n </a>\n \n</figure>\n", nil)
|
||||
}
|
||||
|
||||
func TestFigureLinkWithTarget(t *testing.T) {
|
||||
t.Parallel()
|
||||
CheckShortCodeMatch(t, `{{< figure src="/found/here" link="/jump/here/on/clicking" target="_self" >}}`, "\n<figure>\n <a href=\"/jump/here/on/clicking\" target=\"_self\">\n <img src=\"/found/here\" />\n </a>\n \n</figure>\n", nil)
|
||||
}
|
||||
|
||||
func TestFigureLinkWithTargetAndRel(t *testing.T) {
|
||||
t.Parallel()
|
||||
CheckShortCodeMatch(t, `{{< figure src="/found/here" link="/jump/here/on/clicking" target="_blank" rel="noopener" >}}`, "\n<figure>\n <a href=\"/jump/here/on/clicking\" target=\"_blank\" rel=\"noopener\">\n <img src=\"/found/here\" />\n </a>\n \n</figure>\n", nil)
|
||||
}
|
||||
|
||||
const testScPlaceholderRegexp = "HAHAHUGOSHORTCODE-\\d+HBHB"
|
||||
|
||||
func TestExtractShortcodes(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user