Skip to content

Commit

Permalink
Fixed #32
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesloibl committed Feb 5, 2025
1 parent 29d19ac commit 743e822
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Release History
calls to ``pharaoh.assetlib.api.get_current_component`` resulted in an error.
- Tracebacks occurring during asset generation in Jupyter notebooks are now
printed to console with filtered ANSI control characters to improve readability.
- Fixed :issue:`32`: Image assets with whitespace in path are not rendered correctly

0.8.1
-----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. image:: {{ asset_rel_path_from_project(asset) }}
.. image:: {{ asset_rel_path_from_project(asset)|rsub('(\\s)', '\\\\\\1') }}
{% for key, value in image_opts.items() %}
:{{ key }}: {{ value }}
{% endfor %}
7 changes: 7 additions & 0 deletions src/pharaoh/templating/second_level/env_filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import re
from pathlib import Path

import omegaconf
Expand Down Expand Up @@ -104,6 +105,11 @@ def md2html(text):
return mistletoe.markdown(text)


def rsub(s, find: str, replace: str):
"""A non-optimal implementation of a regex filter"""
return re.sub(find, replace, s)


env_filters = {
"hasattr": hasattr_,
"req": required,
Expand All @@ -116,6 +122,7 @@ def md2html(text):
"exists": exists,
"to_path": to_path,
"md2html": md2html,
"rsub": rsub,
}

# Only document the functions defined in here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

with metadata_context(label="MPL"):
fig.savefig(
"coherence1.png",
"co he-rence 1.png", # try with whitespace in path, see https://github.com/Infineon/pharaoh-dev/issues/32
)
fig.savefig("coherence2.svg")
plt.show()

0 comments on commit 743e822

Please sign in to comment.