Skip to content

Commit 9b13375

Browse files
authored
Add example inserting images
1 parent 28bd5c2 commit 9b13375

File tree

9 files changed

+1360
-146
lines changed

9 files changed

+1360
-146
lines changed

.github/workflows/pythonpublish.yml

+4-13
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,16 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18-
- name: Set up Python
19-
uses: actions/setup-python@v5
20-
with:
21-
python-version: '3.x'
22-
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install setuptools wheel twine
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v5
2720

2821
- name: Make sure unit tests succeed
2922
run: |
30-
pip install ".[dev]"
31-
pytest
23+
uv run pytest
3224
3325
- name: Build
3426
run: |
35-
pip install build setuptools
36-
python -m build
27+
uv build
3728
3829
# See https://docs.pypi.org/trusted-publishers/using-a-publisher/
3930
- name: Publish package distributions to PyPI

.github/workflows/workflow.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@master
1212

13-
- name: Setup Python
14-
uses: actions/setup-python@master
13+
- name: Install uv and set the python version
14+
uses: astral-sh/setup-uv@v5
1515
with:
1616
python-version: ${{ matrix.python-version }}
1717

1818
- name: Run unit tests
1919
run: |
20-
pip install ".[dev]"
21-
pytest --cov=mkdocs_table_reader_plugin --cov-report=xml
20+
uv run pytest --cov=mkdocs_table_reader_plugin --cov-report=xml
2221
2322
- name: Upload coverage to Codecov
2423
if: contains(env.USING_COVERAGE, matrix.python-version) && github.ref == 'refs/heads/master'

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ipython_config.py
2121
.AppleDouble
2222
.LSOverride
2323
# Icon must end with two \r
24-
Icon
24+
Icon
2525
# Thumbnails
2626
._*
2727
# Files that might appear in the root of a volume
@@ -128,6 +128,7 @@ share/python-wheels/
128128
.installed.cfg
129129
*.egg
130130
MANIFEST
131+
.venv/
131132
# PyInstaller
132133
# Usually these files are written by a python script from a template
133134
# before PyInstaller builds the exe, so as to inject date/other infos into it.

docs/assets/tables/html_table.csv

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"a";"b"
2+
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/ayY04sAAAAASUVORK5CYII=;73
3+
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/ayY04sAAAAASUVORK5CYII=;52
4+
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/ayY04sAAAAASUVORK5CYII=;123,80

docs/howto/customize_tables.md

+25
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,28 @@ You can use [tabulate](https://pypi.org/project/tabulate/)'s [number formatting]
9191

9292
{{ read_fwf('tables/fixedwidth_table.txt', floatfmt=".2f") | add_indentation(spaces=4) }}
9393

94+
95+
## Further customization
96+
97+
If you use enable [`mkdocs-macros-plugin`](https://mkdocs-macros-plugin.readthedocs.io/en/latest/) (see [ Compatibility with mkdocs-macros-plugin to enable further automation](use_jinja2.md)), you can do much more.
98+
99+
For example:
100+
101+
{% raw %}
102+
```jinja
103+
{% for base64_image in pd_read_csv('tables/html_table.csv', sep=";")['a'] %}
104+
105+
<img src="data:image/png;base64,{{ base64_image }}" alt="Small Red Dot">
106+
107+
{% endfor %}
108+
```
109+
{% endraw %}
110+
111+
Should render 3 red dots:
112+
113+
{% for base64_image in pd_read_csv('tables/html_table.csv', sep=";")['a'] %}
114+
115+
<img src="data:image/png;base64,{{ base64_image }}" alt="Small Red Dot">
116+
117+
{% endfor %}
118+

pyproject.toml

+19-7
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ classifiers=[
2929
"License :: OSI Approved :: MIT License",
3030
]
3131

32-
dynamic = ["version","dependencies","optional-dependencies"]
32+
dynamic = ["version"]
33+
dependencies = [
34+
"mkdocs>=1.0",
35+
"pandas>=1.1",
36+
"pyyaml>=5.4.1",
37+
"tabulate>=0.8.7",
38+
]
3339

3440
[project.urls]
3541
"Homepage" = "https://github.com/timvink/mkdocs-table-reader-plugin"
3642

3743
[tool.setuptools.dynamic]
3844
version = {attr = "mkdocs_table_reader_plugin.__version__"}
3945

40-
dependencies={file = ["requirements.txt"]}
41-
42-
optional-dependencies.dev={file = ["requirements_dev.txt"]}
43-
optional-dependencies.base={file = ["requirements.txt"]}
44-
optional-dependencies.all={file = ["requirements.txt", "requirements_dev.txt"]}
45-
4646
[tool.pytest.ini_options]
4747
markers = [
4848
"integration: marks tests as integration, meaning they use databases (deselect with '-m \"not integration\"')",
@@ -113,5 +113,17 @@ fix = true
113113

114114
[tool.uv]
115115
dev-dependencies = [
116+
"click>=8.1.8",
117+
"codecov>=2.1.13",
118+
"mkdocs-git-authors-plugin>=0.9.4",
119+
"mkdocs-git-revision-date-localized-plugin>=1.4.5",
120+
"mkdocs-macros-plugin>=1.3.7",
121+
"mkdocs-markdownextradata-plugin>=0.2.6",
122+
"mkdocs-material>=9.6.9",
123+
"openpyxl>=3.1.5",
124+
"pyarrow>=17.0.0",
125+
"pytest>=8.3.5",
126+
"pytest-cov>=5.0.0",
116127
"ruff",
128+
"xlrd>=1.0.0",
117129
]

requirements.txt

-4
This file was deleted.

requirements_dev.txt

-16
This file was deleted.

0 commit comments

Comments
 (0)