Remove XML PI and trailing newline from ditaa svg

This commit is contained in:
Tony Garnock-Jones 2022-02-15 16:21:31 +01:00
parent 125e1e1416
commit e06748dac0
1 changed files with 2 additions and 0 deletions

View File

@ -68,6 +68,8 @@ def expand_ditaa(m, context, directory):
else:
svg = subprocess.check_output(['ditaa', '-T', '--svg', '-'], input=ditaa_source.encode('utf-8'))
svg = svg.decode('utf-8')
svg = re.sub(r'<\?xml.*?\?>', '', svg)
svg = svg.strip()
cache.cursor().execute('INSERT INTO diagrams VALUES (?, ?)', (ditaa_source, svg))
cache.cursor().execute('COMMIT')