- first_node = node[0]
- cap = None
- if isinstance(first_node, nodes.paragraph):
- cap = nodes.caption(first_node.rawsource, '', *first_node.children)
+ first_node = None
+ second_node = None
+ try:
+ first_node = node[0]
+ second_node = node[1]
+ except IndexError:
+ pass
+ is_first_para = isinstance(first_node, nodes.paragraph)
+ is_second_para = isinstance(second_node, nodes.paragraph)
+ capt = None
+ capd = None
+ if is_first_para and is_second_para:
+ capt = captitle(first_node.rawsource, '', *first_node.children)
+ capd = capdesc(second_node.rawsource, '', *second_node.children)
+ node = node[2:]
+ elif is_first_para:
+ capt = captitle(first_node.rawsource, '', *first_node.children)
+ capd = capdesc(first_node.rawsource, '', *first_node.children)
+ node = node[1:]
+ elif is_second_para:
+ capt = captitle(second_node.rawsource, '', *second_node.children)
+ capd = capdesc(second_node.rawsource, '', *second_node.children)