You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This plugin is built to be able to quickly insert table files anywhere in a markdown file.
4
+
5
+
You could also consider alternative approaches that might fit your use-case better.
6
+
7
+
## Write tables to markdown files
8
+
9
+
You could write a script (maybe triggered by a [mkdocs hook](https://www.mkdocs.org/user-guide/configuration/#hooks)) that writes the tables you need into markdown files. It could look something like this:
10
+
11
+
```python
12
+
# write markdown tables
13
+
import pandas as pd
14
+
15
+
md = pd.read_csv("your_file.csv").to_markdown()
16
+
withopen("docs/assets/tables/my_file.md", "w") as f:
17
+
f.write(md)
18
+
```
19
+
20
+
You can then use the [snippets extension](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/) to insert the tables into your markdown pages:
21
+
22
+
```md
23
+
# some_page.md
24
+
25
+
My table:
26
+
27
+
;--8<-- "assets/tables/my_file.md"
28
+
```
29
+
30
+
Upsides:
31
+
32
+
- Easy, fast, low on dependencies
33
+
- You can see changes of your tables in version control
34
+
35
+
Downsides:
36
+
37
+
- You need to generate/update the markdown files on every build
38
+
- if you move the page you have to update the path (if you used a relative path for the snippet)
39
+
40
+
## Execute python during build
41
+
42
+
You could also choose to insert the markdown for tables dynamically, using packages like [markdown-exec]() or [mkdocs-macros-plugin](https://mkdocs-macros-plugin.readthedocs.io/).
Copy file name to clipboardExpand all lines: docs/options.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,6 @@ plugins:
16
16
allow_missing_files: False
17
17
```
18
18
19
-
## Options
20
-
21
19
## `base_path`
22
20
23
21
The base path where `mkdocs-table-reader-plugin` will search for input files. The path to your table files should be relative to the `base_path`. Allowed values:
0 commit comments