Lightbox generates a <div> tag for every image, but div tags cannot be inside p tags (in HTML-spec-speak, the content model for <p> is phrasing content, which does not include <div>). This causes browsers to make these divs close and escape the p tags. Any following content are also out of the p tag, causing issues in some environments. For example,
[details="details" open]

Some text *emphasized* or **bold** or @panic mention
[/details]
should render as
Some text emphasized or bold or @panic mention
instead of the current
The current behaviour is a result of <details> treating every direct child a block.