Skip to content

Commit

Permalink
Fix the mermaid graph on PyPI (GH-19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan authored Apr 28, 2023
2 parents e7f6c69 + fde181a commit 2083943
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ jobs:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python prepublish.py
python setup.py sdist bdist_wheel
twine upload dist/*
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master, tests ]
branches: [ master ]

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion fuzzymap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

__all__ = ('FuzzyMap',)
__version__ = '1.1.0'
__version__ = '1.1.1'
16 changes: 16 additions & 0 deletions prepublish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import re

if __name__ == "__main__":
mermaid_snippet_pattern = r"^```mermaid[\s\S]+?```"
mermaid_snippet_svg_url = (
# Initially was uploaded to GitHub
"https://user-images.githubusercontent.com/44609997/"
"205437148-4fb3d7bd-1fe9-4ce8-8321-d7aef9488e37.svg"
)
html_replacement = "<p align=\"center\"><img src=\"%s\" height=\"400\" /></p>" % mermaid_snippet_svg_url
with open("README.md", "r") as fp:
readme = fp.read()
readme = re.sub(mermaid_snippet_pattern, html_replacement, readme, flags=re.M)

with open("README.md", "w") as fp:
fp.write(readme)

0 comments on commit 2083943

Please sign in to comment.