Skip to content

Commit

Permalink
Bump version to 0.4.5 and improve bullet point formatting in alt text…
Browse files Browse the repository at this point in the history
… generator
  • Loading branch information
JakeWags committed Dec 2, 2024
1 parent b6678df commit 27bbadf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ no_implicit_reexport = true

[project]
name = "upset-alttxt"
version = "0.4.4"
version = "0.4.5"
description = "Generates alt text for UpSet plots"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
15 changes: 9 additions & 6 deletions src/alttxt/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,22 @@ def text(self) -> str:
trend_analysis = self.descriptions["level_3"]["trend_analysis"]
text_desc += trend_analysis
text_desc += " "


if self.structured:
# Helper function to replace periods with newlines and bullet points
def add_bullet_points(text: str) -> str:
# Add a bullet point to the first sentence
text = text.strip()
text = "* " + text
# add bullet point to the first sentence
text = "* " + text.strip()

parts = text.split('. ')

if len(parts) > 1:
return '.\n* '.join(parts[:-1]) + '. ' + parts[-1]
return text
# add \n* to each part except the last one, and only add * to the first one
p = parts[0] + ".\n* " + ("\n* ".join(parts[1:]))
print(p)
return p
else:
return text

# Construct the dictionary for markdown content
data_to_write_as_md = {
Expand Down

0 comments on commit 27bbadf

Please sign in to comment.