Skip to content

Andrew/sanitize title#340

Merged
ayjayt merged 7 commits intomasterfrom
andrew/sanitize-title
Jun 3, 2025
Merged

Andrew/sanitize title#340
ayjayt merged 7 commits intomasterfrom
andrew/sanitize-title

Conversation

@ayjayt
Copy link
Collaborator

@ayjayt ayjayt commented Jun 3, 2025

Add regex to sanitize title

@ayjayt ayjayt requested a review from emilykl June 3, 2025 16:54
)
prefix = fig.get("layout", {}).get("title", {}).get("text", "fig")
prefix = re.sub(r"[ \-]", "_", prefix)
prefix = re.sub(r"[^a-zA-Z0-9_]", "", prefix)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe add a final step here that if the resulting prefix is an empty string, set it to "fig", e.g.:

prefix = prefix or "fig"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's fine, so in the case where they have a title like "####"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah exactly, in case the title is ONLY special characters

Copy link
Collaborator

@emilykl emilykl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @ayjayt 👍

@ayjayt ayjayt merged commit eb21c13 into master Jun 3, 2025
4 checks passed
@ayjayt ayjayt deleted the andrew/sanitize-title branch June 3, 2025 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants