Skip to content

Commit ae2d49a

Browse files
committed
Further sanitize title-filename
1 parent b83b6b8 commit ae2d49a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/py/kaleido/_fig_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ def build_fig_spec(fig, path, opts): # noqa: C901
142142
)
143143
if not full_path:
144144
_logger.debug("Looking for title")
145-
prefix = (
146-
fig.get("layout", {}).get("title", {}).get("text", "fig").replace(" ", "_")
147-
)
145+
prefix = fig.get("layout", {}).get("title", {}).get("text", "fig")
146+
prefix = re.sub(r"[ \-]", "_", prefix)
147+
prefix = re.sub(r"[^a-zA-Z0-9_]", "", prefix)
148148
_logger.debug(f"Found: {prefix}")
149149
name = _next_filename(directory, prefix, ext)
150150
full_path = directory / name

0 commit comments

Comments
 (0)