├── .codecov.yml ├── .github ├── FUNDING.yml └── workflows │ ├── pythonpublish.yml │ ├── unittests.yml │ └── unittests_codecov.yml ├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── MANIFEST.in ├── README.md ├── docs ├── contributing.md ├── demo_content.md ├── how-to │ ├── banner.md │ ├── cover_page.md │ ├── do_not_print.md │ ├── export-HTML.md │ ├── export-PDF.md │ ├── pdf_button.md │ └── print_button.md ├── index.md ├── javascripts │ └── config.js ├── options.md └── overrides │ └── main.html ├── mkdocs.yml ├── pyproject.toml ├── src └── mkdocs_print_site_plugin │ ├── __init__.py │ ├── css │ ├── print-site-material.css │ ├── print-site-mkdocs.css │ ├── print-site-readthedocs.css │ └── print-site.css │ ├── exclude.py │ ├── js │ └── print-site.js │ ├── plugin.py │ ├── renderer.py │ ├── templates │ ├── cover_page.tpl │ └── print_site_banner.tpl │ ├── urls.py │ └── utils.py ├── tests ├── __init__.py ├── fixtures │ └── projects │ │ ├── bad_headings │ │ ├── docs │ │ │ ├── a.md │ │ │ ├── empty.md │ │ │ ├── index.md │ │ │ ├── section.md │ │ │ ├── subsection1.md │ │ │ ├── subsection2.md │ │ │ └── z.md │ │ └── mkdocs.yml │ │ ├── basic │ │ ├── docs │ │ │ ├── a.md │ │ │ ├── empty.md │ │ │ ├── ignore_content.md │ │ │ ├── index.md │ │ │ ├── section.md │ │ │ ├── subfolder │ │ │ │ └── anotherpage.md │ │ │ ├── subsection1.md │ │ │ ├── subsection2.md │ │ │ └── z.md │ │ ├── mkdocs.yml │ │ ├── mkdocs_addtonav_false.yml │ │ ├── mkdocs_do_not_print.yml │ │ ├── mkdocs_material_disabled.yml │ │ ├── mkdocs_material_instant_loading.yml │ │ ├── mkdocs_material_with_enum_plugin.yml │ │ ├── mkdocs_material_with_git_plugin.yml │ │ ├── mkdocs_no_directory_urls.yml │ │ ├── mkdocs_no_toc.yml │ │ ├── mkdocs_readthedocs.yml │ │ ├── mkdocs_toc_depth.yml │ │ ├── mkdocs_toc_permalink.yml │ │ ├── mkdocs_weird_nav.yml │ │ ├── mkdocs_windmill.yml │ │ ├── mkdocs_with_enum.yml │ │ ├── mkdocs_with_nav.yml │ │ ├── mkdocs_with_nav_addtonav_false.yml │ │ └── mkdocs_with_nav_and_theme.yml │ │ ├── mkdocs_material_tags │ │ ├── docs │ │ │ └── index.md │ │ └── mkdocs.yml │ │ ├── nested_sections │ │ ├── docs │ │ │ ├── index.md │ │ │ ├── info.md │ │ │ ├── page1.md │ │ │ ├── page2.md │ │ │ ├── page3.md │ │ │ ├── page4.md │ │ │ ├── page5.md │ │ │ ├── page6.md │ │ │ ├── page7.md │ │ │ └── page8.md │ │ ├── mkdocs.yml │ │ └── mkdocs_basetheme.yml │ │ ├── relative_images │ │ ├── docs │ │ │ ├── About.md │ │ │ ├── Chapter1 │ │ │ │ ├── Section1.md │ │ │ │ ├── Section2.md │ │ │ │ └── img │ │ │ │ │ ├── Picture1-1.png │ │ │ │ │ └── Picture1-2.png │ │ │ ├── Chapter2 │ │ │ │ ├── Section1.md │ │ │ │ ├── Section2.md │ │ │ │ ├── files │ │ │ │ │ └── dummy.txt │ │ │ │ └── img │ │ │ │ │ └── Picture2-2.png │ │ │ ├── github-octocat.png │ │ │ ├── img │ │ │ │ └── Picture0.png │ │ │ └── index.md │ │ ├── mkdocs.yml │ │ ├── mkdocs_img2fig.yml │ │ └── mkdocs_no_dir_urls.yml │ │ ├── snippets │ │ ├── docs │ │ │ └── index.md │ │ ├── includes │ │ │ ├── bla.md │ │ │ └── content.html │ │ └── mkdocs.yml │ │ ├── tables │ │ ├── docs │ │ │ ├── index.md │ │ │ ├── long.md │ │ │ └── wide.md │ │ └── mkdocs.yml │ │ └── with_markdown_ext │ │ ├── docs │ │ ├── appendix.md │ │ ├── extensions │ │ │ ├── admonition.md │ │ │ ├── codehilite.md │ │ │ ├── footnotes.md │ │ │ ├── metadata.md │ │ │ ├── permalinks.md │ │ │ └── pymdown.md │ │ ├── folder │ │ │ ├── img │ │ │ │ └── github-octocat.png │ │ │ ├── subfolder │ │ │ │ └── nested_file.md │ │ │ └── subpage.md │ │ ├── images.md │ │ ├── index.md │ │ ├── overrides │ │ │ └── main.html │ │ └── two.md │ │ ├── mkdocs.yml │ │ ├── mkdocs_diff_cover_page.yml │ │ ├── mkdocs_img2fig.yml │ │ ├── mkdocs_with_toc.yml │ │ └── other_cover_page.tpl ├── test_building.py ├── test_exclude.py └── test_urls.py └── uv.lock /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | # Commits pushed to master should not make the overall 8 | # project coverage decrease by more than x%: 9 | target: auto 10 | threshold: 20% 11 | patch: 12 | default: 13 | # Be tolerant on slight code coverage diff on PRs to limit 14 | # noisy red coverage status on github PRs. 15 | # Note: The coverage stats are still uploaded 16 | # to codecov so that PR reviewers can see uncovered lines 17 | target: auto 18 | threshold: 20% 19 | 20 | codecov: 21 | notify: 22 | # Prevent coverage status to upload multiple times for parallel and long 23 | # running CI pipelines. This configuration is particularly useful on PRs 24 | # to avoid confusion. Note that this value is set to the number of Azure 25 | # Pipeline jobs uploading coverage reports. 26 | after_n_builds: 6 -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [timvink] 4 | -------------------------------------------------------------------------------- /.github/workflows/pythonpublish.yml: -------------------------------------------------------------------------------- 1 | name: Upload Python Package 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [created] 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | environment: release 12 | permissions: 13 | # IMPORTANT: this permission is mandatory for trusted publishing 14 | id-token: write 15 | contents: write 16 | steps: 17 | - uses: actions/checkout@v4 18 | with: 19 | fetch-depth: '0' 20 | - name: Set up Python 21 | uses: actions/setup-python@v5 22 | with: 23 | python-version: '3.x' 24 | - name: Install uv 25 | uses: astral-sh/setup-uv@v5 26 | 27 | - name: Make sure unit tests succeed 28 | run: | 29 | git config --global user.name "Github Action" 30 | git config --global user.email "githubaction@gmail.com" 31 | uv run pytest 32 | 33 | - name: Build 34 | run: | 35 | uv build 36 | 37 | # See https://docs.pypi.org/trusted-publishers/using-a-publisher/ 38 | - name: Publish package distributions to PyPI 39 | uses: pypa/gh-action-pypi-publish@release/v1 40 | -------------------------------------------------------------------------------- /.github/workflows/unittests.yml: -------------------------------------------------------------------------------- 1 | name: Unit tests 2 | on: [pull_request] 3 | jobs: 4 | run: 5 | name: Run unit tests 6 | runs-on: ${{ matrix.os }} 7 | env: 8 | USING_COVERAGE: '3.10' 9 | strategy: 10 | matrix: 11 | os: [ubuntu-latest, macos-latest, windows-latest] 12 | python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] 13 | steps: 14 | - uses: actions/checkout@master 15 | 16 | - name: Install uv and set the python version 17 | uses: astral-sh/setup-uv@v5 18 | with: 19 | python-version: ${{ matrix.python-version }} 20 | 21 | - name: Run unit tests 22 | run: | 23 | git config --global user.name "Github Action" 24 | git config --global user.email "githubaction@gmail.com" 25 | uv run pytest --cov=mkdocs_print_site_plugin --cov-report=xml 26 | -------------------------------------------------------------------------------- /.github/workflows/unittests_codecov.yml: -------------------------------------------------------------------------------- 1 | name: pytest 2 | on: 3 | # Trigger the workflow on push or pull request, 4 | # but only for the master branch 5 | push: 6 | branches: 7 | - master 8 | pull_request: 9 | branches: 10 | - master 11 | jobs: 12 | run: 13 | name: Run unit tests with codecov upload 14 | runs-on: ${{ matrix.os }} 15 | env: 16 | USING_COVERAGE: '3.10' 17 | strategy: 18 | matrix: 19 | os: [ubuntu-latest, macos-latest, windows-latest] 20 | python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"] 21 | steps: 22 | - uses: actions/checkout@master 23 | 24 | - name: Install uv and set the python version 25 | uses: astral-sh/setup-uv@v5 26 | with: 27 | python-version: ${{ matrix.python-version }} 28 | 29 | - name: Generate coverage report 30 | run: | 31 | git config --global user.name "Github Action" 32 | git config --global user.email "githubaction@gmail.com" 33 | uv run pytest --cov=mkdocs_print_site_plugin --cov-report=xml 34 | 35 | - name: Upload coverage to Codecov 36 | if: "contains(env.USING_COVERAGE, matrix.python-version)" 37 | uses: codecov/codecov-action@v4 38 | with: 39 | files: ./coverage.xml 40 | flags: unittests 41 | fail_ci_if_error: false 42 | env: 43 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 44 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: local 3 | hooks: 4 | - id: mypy 5 | name: mypy 6 | entry: mypy 7 | language: system 8 | types: [python] 9 | args: [--ignore-missing-imports, --namespace-packages, --show-error-codes, --pretty] 10 | 11 | # D100 requires all Python files (modules) to have a "public" docstring even if all functions within have a docstring. 12 | # D104 requires __init__ files to have a docstring 13 | # D212 14 | # D200 15 | # D412 No blank lines allowed between a section header and its content 16 | # E203 17 | # W293 blank line contains whitespace 18 | # W503 line break before binary operator (for compatibility with black) 19 | # W605 invalid escape sequence '\/' 20 | # E722 do not use bare 'except' -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Tim Vink 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include mkdocs_print_site_plugin/css/*.css 2 | include mkdocs_print_site_plugin/js/*.js 3 | include mkdocs_print_site_plugin/templates/*.tpl -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Actions Status](https://github.com/timvink/mkdocs-print-site-plugin/workflows/pytest/badge.svg)](https://github.com/timvink/mkdocs-print-site-plugin/actions) 2 | ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mkdocs-print-site-plugin) 3 | ![PyPI](https://img.shields.io/pypi/v/mkdocs-print-site-plugin) 4 | ![PyPI - Downloads](https://img.shields.io/pypi/dm/mkdocs-print-site-plugin) 5 | [![codecov](https://codecov.io/gh/timvink/mkdocs-print-site-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/timvink/mkdocs-print-site-plugin) 6 | ![GitHub contributors](https://img.shields.io/github/contributors/timvink/mkdocs-print-site-plugin) 7 | ![PyPI - License](https://img.shields.io/pypi/l/mkdocs-print-site-plugin) 8 | 9 | # mkdocs-print-site-plugin 10 | 11 | [MkDocs](https://www.mkdocs.org/) plugin that adds a print page to your site that combines the entire site, allowing for easy export to PDF and standalone HTML. See [demo](https://timvink.github.io/mkdocs-print-site-plugin/print_page.html). 12 | 13 | ## Features :star2: 14 | 15 | - Support for [mkdocs-material](https://github.com/squidfunk/mkdocs-material) theme, including features like instant loading, dark color themes and certain plugins (f.e. the [tags](https://squidfunk.github.io/mkdocs-material/plugins/tags/) plugin) 16 | - Support for [readthedocs](https://www.mkdocs.org/user-guide/choosing-your-theme/#readthedocs) theme 17 | - Support for pagination in PDFs. 18 | - Many options to customize appearance 19 | - Option to add a cover page 20 | - Lightweight, no dependencies. 21 | 22 | ## Setup 23 | 24 | Install the plugin using `pip3`: 25 | 26 | ```bash 27 | pip3 install mkdocs-print-site-plugin 28 | ``` 29 | 30 | Next, add the following lines to your `mkdocs.yml`: 31 | 32 | ```yml 33 | plugins: 34 | - search 35 | - print-site 36 | ``` 37 | 38 | > ⚠️ Make sure to put `print-site` to the **bottom** of the plugin list. This is because other plugins might alter your site (like the navigation), and you want these changes included in the print page. 39 | 40 | > If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set. 41 | 42 | ## Usage 43 | 44 | - Navigate to `/print_page/` or `print_page.html` 45 | - Export to standalone HTML (see [export to HTML](https://timvink.github.io/mkdocs-print-site-plugin/how-to/export-HTML.html)) 46 | - Export to PDF using your browser using *File > Print > Save as PDF* (see [export to PDF](https://timvink.github.io/mkdocs-print-site-plugin/how-to/export-PDF.html)) 47 | 48 | ## Documentation 49 | 50 | Available at [timvink.github.io/mkdocs-print-site-plugin](https://timvink.github.io/mkdocs-print-site-plugin/). 51 | 52 | ## Contributing 53 | 54 | Contributions are very welcome! Start by reading the [contribution guidelines](https://timvink.github.io/mkdocs-print-site-plugin/contributing.html). 55 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Thanks for considering to contribute to this project! Some guidelines: 4 | 5 | - Go through the issue list and if needed create a relevant issue to discuss the change design. On disagreements, maintainer(s) will have the final word. 6 | - You can expect a response from a maintainer within 7 days. If you haven’t heard anything by then, feel free to ping the thread. 7 | - This package tries to be as simple as possible for the user (hide any complexity from the user). Options are only added when there is clear value to the majority of users. 8 | - When issues or pull requests are not going to be resolved or merged, they should be closed as soon as possible. This is kinder than deciding this after a long period. Our issue tracker should reflect work to be done. 9 | 10 | ## Unit Tests 11 | 12 | We use [uv](https://docs.astral.sh/uv/getting-started/installation/) to manage python: 13 | 14 | ```bash 15 | uv run pytest --cov=mkdocs_print_site_plugin --cov-report term-missing tests/ 16 | ``` 17 | 18 | If it makes sense, writing tests for your PRs is always appreciated and will help get them merged. 19 | 20 | You can also apply formatting using: 21 | 22 | ```bash 23 | uv run --with ruff ruff format src/ 24 | ``` 25 | 26 | ## Manual testing 27 | 28 | To quickly serve a website with your latest changes to the plugin use the sites in our tests suite. For example: 29 | 30 | ```bash 31 | uv run mkdocs serve -f tests/fixutures/basic/mkdocs.yml 32 | ``` 33 | 34 | Tip: If you use google chrome, you can also view the print version of a page inside the browser [by setting the renderer](https://www.smashingmagazine.com/2018/05/print-stylesheets-in-2018/). 35 | 36 | ## Code Style 37 | 38 | Make sure your code *roughly* follows [PEP-8](https://www.python.org/dev/peps/pep-0008/) and keeps things consistent with the rest of the code. I recommended using [Ruff](https://github.com/astral-sh/ruff) to automatically format your code. 39 | 40 | We use google-style docstrings. 41 | 42 | ## Documentation 43 | 44 | Is in `docs/`. To [deploy the docs](https://www.mkdocs.org/user-guide/deploying-your-docs/), run: 45 | 46 | ```bash 47 | uv run mkdocs gh-deploy 48 | ``` 49 | 50 | Note: there is no automated github action for this currently. -------------------------------------------------------------------------------- /docs/demo_content.md: -------------------------------------------------------------------------------- 1 | # Demo Content 2 | 3 | This content is here to demonstrate what it looks like while printing. 4 | 5 | :point_right: Go ahead and visit the [print page](print_page.html) and check it out! 6 | 7 | ## Links to other pages 8 | 9 | `mkdocs-print-site-plugin` will fix internal links when combining all the pages into one. Try navigating to other site pages using these internal links: 10 | 11 | - [Home](index.md) 12 | - [Options](options.md) 13 | - [Contributing](contributing.md) 14 | 15 | ## Links to other sections 16 | 17 | When combining all pages into one, `mkdocs-print-site-plugin` will also ensure anchor links keep working (also to anchor links on other pages). Try them out: 18 | 19 | - [Dummy section](#dummy-section) lower down this demo page 20 | - The [Manual Testing](contributing.md#manual-testing) in the contributing guide 21 | 22 | ## Charts 23 | 24 | From the [mkdocs-charts-plugin](https://timvink.github.io/mkdocs-charts-plugin/): 25 | 26 | ```vegalite 27 | { 28 | "description": "A simple bar chart with embedded data.", 29 | "data": { 30 | "values": [ 31 | {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43}, 32 | {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53}, 33 | {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52} 34 | ] 35 | }, 36 | "mark": {"type": "bar", "tooltip": true}, 37 | "encoding": { 38 | "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}}, 39 | "y": {"field": "b", "type": "quantitative"} 40 | } 41 | } 42 | ``` 43 | 44 | ## Magic links 45 | 46 | **Magic links and emails:** turned to links as recognized 47 | 48 | | Output | Code | 49 | | --------------------- | ----------------------- | 50 | | http://www.google.com | `http://www.google.com` | 51 | | johndoe@gmail.com | `johndoe@gmail.com` | 52 | | www.google.com | `www.google.com` | 53 | 54 | 55 | ## Markdown extensions 56 | 57 | MkDocs has support for many markdown extensions (see [mkdocs-material reference](https://squidfunk.github.io/mkdocs-material/reference/admonitions/)). Below is a quick showcase so you can see how they print. 58 | 59 | !!! note "Phasellus posuere in sem ut cursus" 60 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod 61 | nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor 62 | massa, nec semper lorem quam in massa. 63 | 64 | !!! note "" 65 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod 66 | nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor 67 | massa, nec semper lorem quam in massa. 68 | 69 | !!! note 70 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod 71 | nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor 72 | massa, nec semper lorem quam in massa. 73 | 74 | ``` python 75 | def bubble_sort(items): 76 | for i in range(len(items)): 77 | for j in range(len(items) - 1 - i): 78 | if items[j] > items[j + 1]: 79 | items[j], items[j + 1] = items[j + 1], items[j] 80 | ``` 81 | 82 | Nunc eu odio eleifend, blandit leo a, volutpat sapien. Phasellus posuere in 83 | sem ut cursus. Nullam sit amet tincidunt ipsum, sit amet elementum turpis. 84 | Etiam ipsum quam, mattis in purus vitae, lacinia fermentum enim. 85 | 86 | ??? note 87 | This is a collapsible block, that is collapsed by default. 88 | 89 | [Example of a button](#){: .md-button } 90 | 91 | [Primary button](#){: .md-button .md-button--primary } 92 | 93 | [With icon :fontawesome-solid-paper-plane:](#){: .md-button .md-button--primary } 94 | 95 | ``` python 96 | import tensorflow as tf 97 | ``` 98 | 99 | ``` python linenums="1" 100 | def bubble_sort(items): 101 | for i in range(len(items)): 102 | for j in range(len(items) - 1 - i): 103 | if items[j] > items[j + 1]: 104 | items[j], items[j + 1] = items[j + 1], items[j] 105 | ``` 106 | 107 | ``` python hl_lines="2 3" 108 | def bubble_sort(items): 109 | for i in range(len(items)): 110 | for j in range(len(items) - 1 - i): 111 | if items[j] > items[j + 1]: 112 | items[j], items[j + 1] = items[j + 1], items[j] 113 | ``` 114 | 115 | The `#!python range()` function is used to generate a sequence of numbers. 116 | 117 | ++ctrl+alt+del++ 118 | 119 | === "C" 120 | 121 | ``` c 122 | #include 123 | 124 | int main(void) { 125 | printf("Hello world!\n"); 126 | return 0; 127 | } 128 | ``` 129 | 130 | === "C++" 131 | 132 | ``` c++ 133 | #include 134 | 135 | int main(void) { 136 | std::cout << "Hello world!" << std::endl; 137 | return 0; 138 | } 139 | ``` 140 | 141 | Another tabbed content 142 | 143 | === "Unordered list" 144 | 145 | * Sed sagittis eleifend rutrum 146 | * Donec vitae suscipit est 147 | * Nulla tempor lobortis orci 148 | 149 | === "Ordered list" 150 | 151 | 1. Sed sagittis eleifend rutrum 152 | 2. Donec vitae suscipit est 153 | 3. Nulla tempor lobortis orci 154 | 155 | Embedding content: 156 | 157 | !!! example 158 | 159 | === "Unordered List" 160 | 161 | _Example_: 162 | 163 | ``` markdown 164 | * Sed sagittis eleifend rutrum 165 | * Donec vitae suscipit est 166 | * Nulla tempor lobortis orci 167 | ``` 168 | 169 | _Result_: 170 | 171 | * Sed sagittis eleifend rutrum 172 | * Donec vitae suscipit est 173 | * Nulla tempor lobortis orci 174 | 175 | === "Ordered List" 176 | 177 | _Example_: 178 | 179 | ``` markdown 180 | 1. Sed sagittis eleifend rutrum 181 | 2. Donec vitae suscipit est 182 | 3. Nulla tempor lobortis orci 183 | ``` 184 | 185 | _Result_: 186 | 187 | 1. Sed sagittis eleifend rutrum 188 | 2. Donec vitae suscipit est 189 | 3. Nulla tempor lobortis orci 190 | 191 | | Method | Description | 192 | | ----------- | ------------------------------------ | 193 | | `GET` | :material-check: Fetch resource | 194 | | `PUT` | :material-check-all: Update resource | 195 | | `DELETE` | :material-close: Delete resource | 196 | 197 | Footnotes in a text: Lorem ipsum[^1] dolor sit amet, consectetur adipiscing elit.[^2] 198 | 199 | [^1]: Lorem ipsum dolor sit amet, consectetur adipiscing elit. 200 | [^2]: 201 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod 202 | nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor 203 | massa, nec semper lorem quam in massa. 204 | 205 | * :material-account-circle: – `.icons/material/account-circle.svg` 206 | * :fontawesome-regular-laugh-wink: – `.icons/fontawesome/regular/laugh-wink.svg` 207 | * :octicons-octoface-16: – `.icons/octicons/octoface-16.svg` 208 | * :fontawesome-brands-medium:{: .medium } – Medium 209 | * :fontawesome-brands-twitter:{: .twitter } – Twitter 210 | * :fontawesome-brands-facebook:{: .facebook } – Facebook 211 | 212 | :smile: 213 | 214 | ### Images 215 | 216 | `mkdocs-print-site-plugin` supports enumerating figure captions (which can be added easily using the [img2fig](https://github.com/stuebersystems/mkdocs-img2fig-plugin) plugin): 217 | 218 |
219 | 220 |
Image caption
221 |
222 | 223 |
224 | 225 |
Another image caption
226 |
227 | 228 | ![](https://play-lh.googleusercontent.com/JHDqEqU0QNC8vsa5_UsPAws5X1OvTVPcfDVLnV1WXhoYrEX81sE6fL7cmamStPrK_A=w1440-h620-rw "A cat playing") 229 | 230 | ![](https://play-lh.googleusercontent.com/tKuOgQBwDTjhZg3DjCdZVTSVa9X9iMrtrM_1JDH6Ky_YyQeKw_bnFDy0tj1aZ39TDnI=w1440-h620-r "Another cat playing") 231 | 232 | ![](https://play-lh.googleusercontent.com/4CPahw1_E0b61tZKq4QI1bw_dqR6bYy0aDiNWrn-MCoz9Wq5bNyhKywfVlK01nNKR-A=w1440-h620-r "More cats that play") 233 | 234 | ![](https://play-lh.googleusercontent.com/5DeXBFITrh81XB68XxvJGvat5bwVj2ELVdSXNb6mGdvohZtnUoUl5kkPLPSrgtN9XHk=w1440-h620-r "The internet loves cats") 235 | 236 | 237 | ### Lists 238 | 239 | 1. Vivamus id mi enim. Integer id turpis sapien. Ut condimentum lobortis 240 | sagittis. Aliquam purus tellus, faucibus eget urna at, iaculis venenatis 241 | nulla. Vivamus a pharetra leo. 242 | 243 | 1. Vivamus venenatis porttitor tortor sit amet rutrum. Pellentesque aliquet 244 | quam enim, eu volutpat urna rutrum a. Nam vehicula nunc mauris, a 245 | ultricies libero efficitur sed. 246 | 247 | 2. Morbi eget dapibus felis. Vivamus venenatis porttitor tortor sit amet 248 | rutrum. Pellentesque aliquet quam enim, eu volutpat urna rutrum a. 249 | 250 | 1. Mauris dictum mi lacus 251 | 2. Ut sit amet placerat ante 252 | 3. Suspendisse ac eros arcu 253 | 254 | `Lorem ipsum dolor sit amet` 255 | : Sed sagittis eleifend rutrum. Donec vitae suscipit est. Nullam tempus 256 | tellus non sem sollicitudin, quis rutrum leo facilisis. 257 | 258 | `Cras arcu libero` 259 | : Aliquam metus eros, pretium sed nulla venenatis, faucibus auctor ex. Proin 260 | ut eros sed sapien ullamcorper consequat. Nunc ligula ante. 261 | 262 | Duis mollis est eget nibh volutpat, fermentum aliquet dui mollis. 263 | Nam vulputate tincidunt fringilla. 264 | Nullam dignissim ultrices urna non auctor. 265 | 266 | * [x] Lorem ipsum dolor sit amet, consectetur adipiscing elit 267 | * [ ] Vestibulum convallis sit amet nisi a tincidunt 268 | * [x] In hac habitasse platea dictumst 269 | * [x] In scelerisque nibh non dolor mollis congue sed et metus 270 | * [ ] Praesent sed risus massa 271 | * [ ] Aenean pretium efficitur erat, donec pharetra, ligula non scelerisque 272 | 273 | $$ 274 | \operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} 275 | $$ 276 | 277 | The homomorphism $f$ is injective if and only if its kernel is only the 278 | singleton set $e_G$, because otherwise $\exists a,b\in G$ with $a\neq b$ such 279 | that $f(a)=f(b)$00. 280 | 281 | ## Dummy section 282 | 283 | This section has an incoming anchor link, at the top of this page 284 | 285 | ## Some [lorem ipsum](https://www.lipsum.com/) 286 | 287 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut eget mi lacinia arcu ultrices rutrum eget a lacus. Etiam erat mi, sodales at nisl vel, bibendum tempor nunc. Cras in ultrices augue. Cras aliquam in mauris et semper. In hac habitasse platea dictumst. Proin dignissim scelerisque risus, consectetur ornare justo ultrices eu. Quisque tempus, elit eu ullamcorper interdum, metus augue pulvinar lectus, nec dictum mi dolor non turpis. Sed condimentum vulputate pretium. 288 | 289 | Nulla at nisl tortor. Praesent vitae turpis sit amet sem condimentum fermentum eget nec dolor. Maecenas et imperdiet ante, at ultrices orci. Nunc ornare sodales enim. Sed tempor vitae mi et faucibus. Nunc aliquam est sit amet mauris tempus varius. Aenean blandit vel nibh nec sagittis. Sed vehicula nunc a nunc vehicula viverra. Proin risus justo, ullamcorper ac sem a, vulputate ornare justo. Sed facilisis pharetra elit, vitae dignissim nibh iaculis eu. Suspendisse potenti. Curabitur quis arcu ac est faucibus suscipit vel non lacus. 290 | 291 | Ut tincidunt sapien sed sem auctor, et pellentesque erat tristique. Nunc porttitor lacus diam, eu malesuada nibh venenatis in. Donec sit amet enim eget enim facilisis placerat nec eget tortor. Etiam imperdiet, felis ac posuere dignissim, nulla sapien auctor mauris, ac aliquam orci leo nec dui. Donec efficitur turpis quis enim efficitur, eu ornare nisi consectetur. Sed ac arcu at orci pretium lobortis luctus non augue. Duis posuere purus at semper fringilla. Pellentesque facilisis libero vestibulum elit varius iaculis. Donec dapibus pretium scelerisque. 292 | 293 | Suspendisse non orci vitae lorem placerat pretium vitae a ex. Nunc facilisis aliquam risus in vehicula. Fusce sodales bibendum lectus id ultricies. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In cursus blandit quam ac bibendum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut commodo tellus vel interdum vulputate. Nulla in turpis tellus. Mauris at semper ex. Nulla varius leo eu libero placerat, quis euismod orci euismod. Phasellus pulvinar ut sapien nec elementum. Maecenas vel mi eros. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus volutpat massa vel purus interdum imperdiet. Curabitur congue turpis eget faucibus varius. Aenean eleifend placerat lorem vel vestibulum. 294 | 295 | Nullam in posuere urna. Sed cursus est porta maximus dignissim. Etiam id ante libero. Curabitur ac rhoncus turpis. Cras eu ipsum lacus. Aliquam ac rutrum elit. Donec pharetra in arcu feugiat interdum. Nam sed libero semper, sollicitudin urna vel, tincidunt nulla. Curabitur dapibus massa lectus, vulputate fermentum est finibus et. Ut efficitur velit nec justo varius tempor. Nullam aliquet commodo enim eget lobortis. Nullam sit amet nunc viverra, iaculis sem non, scelerisque mauris. Vivamus eu finibus lacus, dignissim luctus elit. -------------------------------------------------------------------------------- /docs/how-to/banner.md: -------------------------------------------------------------------------------- 1 | # Customize the print site banner 2 | 3 | When a user visits the print page, it might not be immediately obvious how to use it. You can set the `add_print_site_banner` option to `true` to add a banner to the top of the HTML print page that will be hidden when printing. 4 | 5 | You might want to customize this banner, for example by translating it to your language. You can do that by specifying the path to a custom banner template in the `mkdocs.yml` file. This file should be a standard [jinja2 template](https://jinja.palletsprojects.com/en/2.11.x/templates/) where you can combine HTML and jinja2 variables. The information specified in `mkdocs.yml` will already by available as jinja2 variables (see [mkdocs project information](https://www.mkdocs.org/user-guide/configuration/#project-information)). 6 | 7 | _Example_: 8 | 9 | === "mkdocs.yml" 10 | 11 | ```yaml 12 | plugins: 13 | - print-site: 14 | add_print_site_banner: true 15 | print_site_banner_template: "docs/assets/templates/custom_banner.tpl" 16 | ``` 17 | 18 | === "docs/assets/templates/custom_banner.tpl" 19 | 20 | ```jinja 21 |

22 | This box will disappear when printing 23 | mkdocs-print-site-plugin 24 |

25 |

This page has combined all site pages into one. You can export to PDF using File > Print > Save as PDF.

26 |

See also [export to PDF](https://timvink.github.io/mkdocs-print-site-plugin/how-to/export-PDF.html) and [export to standalone HTML](https://timvink.github.io/mkdocs-print-site-plugin/how-to/export-HTML.html).

27 | ``` 28 | 29 | As an example, have a look at the default [print_site_banner.tpl](https://github.com/timvink/mkdocs-print-site-plugin/tree/master/mkdocs_print_site_plugin/templates/print_site_banner.tpl). 30 | 31 | ## Adding configurable content 32 | 33 | You might want to add some content to your print banner that's not yet specified in your `mkdocs.yml` file. 34 | Of course you could just hard-code it in your custom template file, but you could also make use of MkDocs's [extra context](https://www.mkdocs.org/user-guide/custom-themes/#extra-context) feature, allowing you to use custom variables from your config file with `{{ config.extra. }}`. 35 | 36 | _Example_: 37 | 38 | === "mkdocs.yml" 39 | 40 | ```yaml 41 | plugins: 42 | - print-site: 43 | add_print_site_banner: true 44 | print_site_banner_template: "docs/assets/templates/custom_banner.tpl" 45 | 46 | extra: 47 | banner_message: "Save this page using File > Print > Save as PDF" 48 | ``` 49 | 50 | === "docs/assets/templates/custom_banner.tpl" 51 | 52 | ```jinja 53 |

54 | This box will disappear when printing 55 | mkdocs-print-site-plugin 56 |

57 |

{{ config.extra.banner_message }}

58 | ``` 59 | 60 | 61 | -------------------------------------------------------------------------------- /docs/how-to/cover_page.md: -------------------------------------------------------------------------------- 1 | # Customize the cover page 2 | 3 | By default the `add_cover_page` option is set to `true`, which will add a cover page to the print page. You might want to customize it more to your liking. 4 | 5 | You can do that by specifying the path to a custom cover page template in the `mkdocs.yml` file. This file should be a standard [jinja2 template](https://jinja.palletsprojects.com/en/2.11.x/templates/) where you can combine HTML and jinja2 variables. The information specified in `mkdocs.yml` will already by available as jinja2 variables (see [mkdocs project information](https://www.mkdocs.org/user-guide/configuration/#project-information)). 6 | 7 | _Example_: 8 | 9 | === "mkdocs.yml" 10 | 11 | ```yaml 12 | plugins: 13 | - print-site: 14 | add_cover_page: true 15 | cover_page_template: "docs/assets/templates/custom_cover_page.tpl" 16 | ``` 17 | 18 | === "docs/assets/templates/custom_cover_page.tpl" 19 | 20 | ```jinja 21 | {% if config.site_name %} 22 |

{{ config.site_name }}

23 | {% endif %} 24 |

This is my custom print cover page

25 | ``` 26 | 27 | To get you started have a look at the default [cover_page.tpl](https://github.com/timvink/mkdocs-print-site-plugin/tree/master/mkdocs_print_site_plugin/templates/cover_page.tpl). 28 | 29 | ## Adding images 30 | 31 | When adding images to your custom cover page template, make sure to define the image source as the hosted image path. The url for the image stored in `docs/assets/img/example.png` would be `/assets/img/example.png`. 32 | 33 | _Example_: 34 | 35 | === "docs/assets/templates/custom_cover_page.tpl" 36 | 37 | ```jinja 38 | {% if config.site_name %} 39 |

{{ config.site_name }}

40 | {% endif %} 41 | 42 | ``` 43 | 44 | For a full working example have a look at this [custom cover page with an image](https://github.com/timvink/mkdocs-print-site-plugin/blob/master/tests/fixtures/projects/with_markdown_ext/other_cover_page.tpl). 45 | 46 | ## Adding configurable content 47 | 48 | You might want to add some content to your cover page that's not yet specified in your `mkdocs.yml` file. Of course you could just hard-code it in your custom template file, but you could also make use of MkDocs's [extra context](https://www.mkdocs.org/user-guide/custom-themes/#extra-context) feature, allowing you to use custom variables from your config file with `{{ config.extra. }}`. 49 | 50 | _Example_: 51 | 52 | === "mkdocs.yml" 53 | 54 | ```yaml 55 | plugins: 56 | - print-site: 57 | add_cover_page: true 58 | cover_page_template: "docs/assets/templates/custom_cover_page.tpl" 59 | 60 | extra: 61 | abstract: This is a report about a topic 62 | ``` 63 | 64 | === "docs/assets/templates/custom_cover_page.tpl" 65 | 66 | ```jinja 67 | {% if config.site_name %} 68 |

{{ config.site_name }}

69 | {% endif %} 70 |

{{ config.extra.abstract }}

71 | ``` 72 | 73 | ## Change the styling 74 | 75 | You'll likely also want to change the styling of the cover page to your liking. You can add your own CSS file using the [extra_css](https://www.mkdocs.org/user-guide/configuration/#extra_css) option from MkDocs. `mkdocs-print-site-plugin` wraps the cover page in a `