From: facelessuser <faceless.shop@gmail.com>
Date: Sun, 16 Mar 2025 12:45:06 -0600
Subject: Account for empty content in caption

This is mainly to preserve test integrity

(cherry picked from commit ff7f6dab949f43c9c76de04a2bc6821b82486033)
---
 pymdownx/blocks/caption.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pymdownx/blocks/caption.py b/pymdownx/blocks/caption.py
index c0023a6..d242fae 100644
--- a/pymdownx/blocks/caption.py
+++ b/pymdownx/blocks/caption.py
@@ -59,7 +59,8 @@ def update_tag(el, fig_type, fig_num, template, prepend):
                     p = children[0]
                     span = etree.Element('span', {'class': 'caption-prefix'})
                     span.text = value
-                    span.tail = (' ' + p.text) if p.text is not None else p.text
+                    empty = not bool(p.text)
+                    span.tail = (' ' + p.text) if not empty else p.text
                     p.text = None
                     p.insert(0, span)
 
