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:
Kaushal Modi
2018-02-05 14:06:29 -05:00
committed by Bjørn Erik Pedersen
parent 76d38d5e53
commit 2e95ec6844
6 changed files with 63 additions and 17 deletions

View File

@@ -123,22 +123,22 @@ func TestShortcodeFigure(t *testing.T) {
}{
{
`{{< figure src="/img/hugo-logo.png" >}}`,
"(?s)\n<figure >.*?<img src=\"/img/hugo-logo.png\" />.*?</figure>\n",
"(?s)\n<figure>.*?<img src=\"/img/hugo-logo.png\" />.*?</figure>\n",
},
{
// set alt
`{{< figure src="/img/hugo-logo.png" alt="Hugo logo" >}}`,
"(?s)\n<figure >.*?<img src=\"/img/hugo-logo.png\" alt=\"Hugo logo\" />.*?</figure>\n",
"(?s)\n<figure>.*?<img src=\"/img/hugo-logo.png\" alt=\"Hugo logo\" />.*?</figure>\n",
},
// set title
{
`{{< figure src="/img/hugo-logo.png" title="Hugo logo" >}}`,
"(?s)\n<figure >.*?<img src=\"/img/hugo-logo.png\" />.*?<figcaption>.*?<h4>Hugo logo</h4>.*?</figcaption>.*?</figure>\n",
"(?s)\n<figure>.*?<img src=\"/img/hugo-logo.png\" />.*?<figcaption>.*?<h4>Hugo logo</h4>.*?</figcaption>.*?</figure>\n",
},
// set attr and attrlink
{
`{{< figure src="/img/hugo-logo.png" attr="Hugo logo" attrlink="/img/hugo-logo.png" >}}`,
"(?s)\n<figure >.*?<img src=\"/img/hugo-logo.png\" />.*?<figcaption>.*?<p>.*?<a href=\"/img/hugo-logo.png\">.*?Hugo logo.*?</a>.*?</p>.*?</figcaption>.*?</figure>\n",
"(?s)\n<figure>.*?<img src=\"/img/hugo-logo.png\" />.*?<figcaption>.*?<p>.*?<a href=\"/img/hugo-logo.png\">.*?Hugo logo.*?</a>.*?</p>.*?</figcaption>.*?</figure>\n",
},
} {