mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-25 00:36:55 +02:00
bugfix: #1547 Before calling serializeToString in mmdc_playwright.py, make sure the SVG element exists.
This commit is contained in:
parent
b5bb4d7e63
commit
04438651b6
1 changed files with 7 additions and 4 deletions
|
|
@ -81,10 +81,13 @@ async def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048,
|
|||
if "svg" in suffixes:
|
||||
svg_xml = await page.evaluate(
|
||||
"""() => {
|
||||
const svg = document.querySelector('svg');
|
||||
const xmlSerializer = new XMLSerializer();
|
||||
return xmlSerializer.serializeToString(svg);
|
||||
}"""
|
||||
const svg = document.querySelector('svg');
|
||||
if (!svg) {
|
||||
throw new Error('SVG element not found');
|
||||
}
|
||||
const xmlSerializer = new XMLSerializer();
|
||||
return xmlSerializer.serializeToString(svg);
|
||||
}"""
|
||||
)
|
||||
logger.info(f"Generating {output_file_without_suffix}.svg..")
|
||||
with open(f"{output_file_without_suffix}.svg", "wb") as f:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue