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
|
@ -3,6 +3,8 @@ project:
|
||||||
output-dir: /home/marty/projects/hosting/webpage/src/content/blog/2024-07-02-nuclear-explosions-analysis
|
output-dir: /home/marty/projects/hosting/webpage/src/content/blog/2024-07-02-nuclear-explosions-analysis
|
||||||
render:
|
render:
|
||||||
- index.qmd
|
- index.qmd
|
||||||
|
post-render:
|
||||||
|
- tools/fix-astro-img.py
|
||||||
|
|
||||||
format:
|
format:
|
||||||
hugo-md:
|
hugo-md:
|
||||||
|
|
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 ![image-tags](./aiming/at/output/dir)
|
||||||
|
|
||||||
|
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"![fig](./\1)", content)
|
||||||
|
|
||||||
|
with open(fname, "w") as f:
|
||||||
|
f.write(modified)
|
Loading…
Reference in a new issue