# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: OpenMDW-1.1 """Render titles explicitly declared by native chart metadata as table captions.""" import re from html import escape def transform(text): changed=0 def chart(m): nonlocal changed body=m[2] if ''+''.join(''+escape(c)+'' for c in cells[0])+'' result+=''.join(''+''.join(''+escape(c)+'' for c in row)+'' for row in cells[2:])+'\n' return result new=pattern.sub(table,body) if not count:return m[0] # The title is rendered in its associated captions, retaining text and roles. new=re.sub(r'(?m)^title:[ \t]*[^\n]*\n?', '',new,count=1) changed+=count;return m[1]+new+m[3] out=re.sub(r'(]*>)(.*?)()',chart,text,flags=re.S) return out,changed