Fix plot links for astro static files
This commit is contained in:
parent
e90b423ebc
commit
4306a7d246
2 changed files with 28 additions and 0 deletions
26
tools/fix-astro-img.py
Normal file
26
tools/fix-astro-img.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
# Replaces all img tags with markdown 
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
if not os.getenv("QUARTO_PROJECT_RENDER_ALL"):
|
||||
sys.exit(0)
|
||||
|
||||
q_output_dir = os.getenv("QUARTO_PROJECT_OUTPUT_DIR")
|
||||
q_output_files = os.getenv("QUARTO_PROJECT_OUTPUT_FILES")
|
||||
if not q_output_files:
|
||||
sys.exit(1)
|
||||
|
||||
for fname in q_output_files.splitlines():
|
||||
if not fname.endswith(".md"):
|
||||
continue
|
||||
|
||||
with open(fname, "r") as f:
|
||||
content = f.read()
|
||||
|
||||
modified = re.sub(r'<img src="(.+?)".*/>', r"", content)
|
||||
|
||||
with open(fname, "w") as f:
|
||||
f.write(modified)
|
||||
Loading…
Add table
Add a link
Reference in a new issue