Skip to content

Commit

Permalink
Rewrite relative links
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Sep 19, 2024
1 parent 17ff470 commit dfd1110
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling<2"]
requires = ["hatchling<2", "hatch-fancy-pypi-readme"]

[project]
name = "pymc-marketing"
description = "Marketing Statistical Models in PyMC"
requires-python = ">=3.10"
readme = "README.md"
license = { file = "LICENSE" }
dynamic = ["version"]
dynamic = ["version", "readme"]
maintainers = [{ name = "PyMC Labs", email = "[email protected]" }]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down Expand Up @@ -97,8 +96,29 @@ packages = [
[tool.hatch.version]
path = "pymc_marketing/version.py"

[tool.setuptools.dynamic]
version = { file = "pymc_marketing/version.txt" }
# <https://github.com/hynek/hatch-fancy-pypi-readme>
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "README.md"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# Image links should go to the raw content on GitHub
# <https://stackoverflow.com/a/46875147>
pattern = '\[(.*?)\]\(((?!https?://)\S+\.(png|jpe?g|svg|gif))\)'
replacement = '[\1](https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/\g<2>)'

[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# Handle also HTML image tags
pattern = '''(<img\b[^>]*\bsrc=)(['"])((?!https?://)[^'"]+)(['"][^>]*>)'''
replacement = '<img src="https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/\g<3>\g<4>'

[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# Remaining non-image relative links map to the normal absolute GitHub URL
# <https://stackoverflow.com/a/46875147>
pattern = '\[(.*?)\]\(((?!https?://)\S+)\)'
replacement = '[\1](https://github.com/pymc-labs/pymc-marketing/tree/main/\g<2>)'

[project.urls]
repository = "https://github.com/pymc-labs/pymc-marketing"
Expand Down

0 comments on commit dfd1110

Please sign in to comment.