How can I specify a line break in a shortcode expansion?
-
I have a shortcode to help create a table with each cell containing a <figure> with a <figcaption>. It is invoked with:
[mycode photo=’photo URL’ cap=’my caption text here’]
Sometimes, my caption text is too long to fit on one line in the cell. I would like to specify where the linebreak should be within the caption text, rather than letting the browser choose where to break.
But I can’t do this: [mycode photo=’photo URL’ cap=’my caption<br />text here’]
That causes the caption to display as “my caption<br />text here”.
Nor can I do this: [mycode photo=’photo URL’ cap=’my caption
text here’]That gets converted to this HTML:
<figcaption>
<p></p>
my caption
<p>text here</p>
</figcaption>I might attempt to parse my ‘cap’ parameter in my shortcode PHP code, but I don’t think I yet understand when various other editors and parsers tinker with the parameters.
I might add a third parameter to my shortcode so that the caption’s second line is passed separately, but that seems like a kludge.
I would appreciate other suggestions.
- The topic ‘How can I specify a line break in a shortcode expansion?’ is closed to new replies.