orzih / mkdocs-with-pdf Goto Github PK
View Code? Open in Web Editor NEWGenerate a single PDF file from MkDocs repository.
License: MIT License
Generate a single PDF file from MkDocs repository.
License: MIT License
PDF generation takes a while
$ time mkdocs build
...
INFO - Converting 14 articles to PDF took 28.5s
INFO - Documentation built in 30.59 seconds
real 0m32.552s
user 0m29.004s
sys 0m0.923s
so PDF generation takes about 90% of the total time for my particular build.
This is fine when running mkdocs build
, but when using mkdocs serve
this means that any edit to any file takes half a minute to show up.
Might it be possible to skip or background PDF generation during mkdocs serve
?
Links that include special characters like ä or & are not resolved in the pdf. On rendering the pdf the following error is thrown:
No anchor #broken_entry_&/ for internal URI reference
This also effects the links in the toc as mentioned in #15
I created a minimal example with the bug:
mkdocs_heading_example.zip
There still seems to be a problem with links and special characters like ä,& ect. When creating a local link inside a markdown document like this:
[local link](#some-heading)
everything works fine as long as there is no special character in the path. With special characters in the path the link is no longer working in the pdf. However if we use the path explicitly like this:
[local link](../../../path/to/here_ä/#some-heading)
the link works again.
I created a minimal example to show the three different cases I described.
mkdocs_heading_example.zip
enviroment: Windows10, Python3.9.5
cmd: mkdocs.exe build
error:
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\click\core.py", line 763, in invoke
return callback(*args, **kwargs)
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\mkdocs_main.py", line 183, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\mkdocs\commands\build.py", line 249, in build
config = config['plugins'].run_event('config', config)
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\mkdocs\plugins.py", line 94, in run_event
result = method(item, **kwargs)
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\mkdocs_pdf_export_plugin\plugin.py", line 42, in on_config
from .renderer import Renderer
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\mkdocs_pdf_export_plugin\renderer.py", line 6, in
from weasyprint import HTML
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\weasyprint_init.py", line 469, in
from .css import preprocess_stylesheet # noqa isort:skip
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\weasyprint\css_init_.py", line 27, in
from . import computed_values, counters, media_queries
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\weasyprint\css\computed_values.py", line 15, in
from .. import text
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\weasyprint\text.py", line 11, in
import cairocffi as cairo
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\cairocffi_init_.py", line 48, in
cairo = dlopen(
File "d:\hzh_sfq\projects\shenzhen\docs\venv\lib\site-packages\cairocffi_init_.py", line 45, in dlopen
raise OSError(error_message) # pragma: no cover
OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x7e
cannot load library 'libcairo-2.dll': error 0x7e
Commit ae13433 added _remove_empty_tags functionality, but I think this results in all
<img ...../>
tags being removed from the generated pdf files.p is in the includes array and a paragraph only containing an image tag has no text in it, so 'if x.name in includes and len(x.get_text(strip=True)) == 0:' at line 109 of generator.py returns true causing the tag to be removed
If I comment out the call to the _remove_empty_tags function the images appear in the generated pdf, if I leave the call in I get no images in the pdf
Right now the download link get's appended to md-footer-copyright in the material design and always has "... download PDF".
I might be alone with this issue, but it would be very helpful if the tag for the download link would be available via the config parameters.
Also, it would be great if the Link-Text would be something that can be adjusted easily.
Thank you for considering. If it doesn't fit your overall roadmap, please just close.
Hi and thank you for your really great work with this plugin.
Unfortunately I got an error when building my documentation and I do not know how to fix it. Maybe you can help me:
/usr/local/lib/python3.8/site-packages/weasyprint/fonts.py:227: UserWarning: FontConfig: No fonts configured. Expect ugly output. warnings.warn(
I have the following fonts set:
font: text: Barlow code: Roboto Mono
is the error I get, when I build my mkdocs-material on docker (alpine). Did I miss a dependency?
Thanks in advance!
Hi,
I'm trying to export mkdocs website as a PDF however I'm having issues scaling the images to the PDF's column width.
The images look just fine on the website, however, while rendering the PDF they are not scaled to column width as they scaled on the website.
Also, as you see, figure2 is missing on pdf while there is no visible issue regarding that figure. Both the figures are located in the same directory and both of them are called in the same way on markdown.
Hi @orzih,
we have an internal fork of this wonderful handy library. We - like it seems other too, judging from the other issue reports - were looking for ways to customize styles, layout etc.
We started to redactor some stuff to make our use case more easy - and moved away from python + beautiful soup for templating and replaced it with jinja. Is this direction something you like us to make merge requests here or should we fork?
First of all, thank you very much for the plugin, it's fantastic.
I'm not sure if I did it right, I was not able to exclude pages from the pdf as described in the documentation. Also in the sample pdf it seems that it did not work?
How to use "excludes_children:" correctly?
Hi, I have a problem with headers fonts but impossible for me to fix it... This screeshot is from the sample mkdocs.
Thanks.
I want to change the textcolor from grey to another color for the level1 heading (h1). I was able to do it for h2 to h6 with the help of styles.scss in the template directory introduced in version 0.8.0
$tmag: #0f0;
h1 { color: $tmag;}
article h1,h2,h3,h4,h5,h6 {color: $tmag;}
any hint ?
Seems related to handling of unicode in Python, except the same repo and configuration successfully builds and outputs to file on Linux
Windows 10 Version 10.0.19042 Build 19042
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
mkdocs build
# a bunch of HTML and stuff
INFO - Converting 34 articles to PDF took 8.6s
INFO - Documentation built in 9.49 seconds
mkdocs build > pdf.html
# a bunch of INFO and WARNING messages
Traceback (most recent call last):
File "c:\users\rpark\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\rpark\AppData\Local\Programs\Python\Python37\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\mkdocs\__main__.py", line 152, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\mkdocs\commands\build.py", line 295, in build
config['plugins'].run_event('post_build', config=config)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\mkdocs\plugins.py", line 96, in run_event
result = method(**kwargs)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\mkdocs_with_pdf\plugin.py", line 135, in on_post_build
self.generator.on_post_build(config, self.config['output_path'])
File "c:\users\rpark\appdata\local\programs\python\python37\lib\site-packages\mkdocs_with_pdf\generator.py", line 132, in on_post_build
print(html_string)
File "c:\users\rpark\appdata\local\programs\python\python37\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2190' in position 34939: character maps to <undefined>
For example, I wan the title to be,
This is document
for
Company A
And not
This is document for Company A
I try everything, using |, \n, \newline, \n\n, 2 break lines,
, and they are not working.
Internal links in PDF inactive when use_directory_urls
is false and filename does not begin with index
.
Example:
# TEST PAGE
- [Internal link to one](#one)
- [Internal link to two](#two)
## One
One
## Two
two
index.md
, indexnot.md
.notindex.md
, not.md
.use_directory_links: true
(the default) all links are correct.Hi, and thanks for this nice plugin!
I was hoping to be able to auto-detect markdown documents (not specified in the nav
) by using mkdocs-awesome-pages and have a PDF generated from such docs, e.g.:
site_name: my docs
theme:
name: material
plugins:
- search
- with-pdf:
enabled_if_env: ENABLE_PDF_EXPORT
- awesome-pages
nav:
- Home: index.md
- Changelog: changelog.md
- ...
But this just results in a completely empty PDF.
I have numerous folders with markdown documents inside, which I don't have to add to the nav
, as they are added automatically by the - ...
. Do you have any ideas on if there's any way to fix this or maybe you are aware of another plugin which does something similar?
I'm using material for mkdocs. There are two different behaviors. If I don't set a first level heading for a page, mkdocs automatically renders the one that is given by the nav
entry in the config file. In this case mkdocs-with-pdf throws the following error:
ERROR - Content discarded: target points to undefined anchor "('string', '#')"
The entry in the toc then points to #
.
If I set the heading on the page manually by adding
# exampleHeading
to my markdown file I get the following error instead:
ERROR - No anchor #example/path/:exampleheading for internal URI reference
The resulting toc entry is then no longer a link meaning it is not clickable.
Hi, first off - amazing project. Ive been struggling with creating PDFs with mkdocs for a few weeks now, and came across this by chance. Worked flawlessly (with material) on the first attempt.
I was trying to customize the location of the "Download PDF" button as we want to keep it in a different location,
and I dug through the code to find the theme_handler_path
config where I can define my own inject-html
function to do this
I found that the theme_handler_path
is being read from the configs twice - and it looked like a bug so, I thought I'd report it.
I created theme/pdf_handler/material.py
and copied contents from: https://github.com/orzih/mkdocs-with-pdf/blob/master/mkdocs_with_pdf/themes/pdf_handler.py
To test things out ...
https://github.com/orzih/mkdocs-with-pdf/blob/v0.7.5/mkdocs_with_pdf/options.py#L57
site_name: MyDocs
theme:
name: material
plugins:
- with-pdf:
cover_title: MyDocs-PDFVersion
theme_handler_path: theme/pdf_handler.py
This had no effect. I realized that this config is being over written by a global config by the same name
https://github.com/orzih/mkdocs-with-pdf/blob/v0.7.5/mkdocs_with_pdf/options.py#L96
site_name: MyDocs
theme:
name: material
plugins:
- with-pdf:
cover_title: MyDocs-PDFVersion
theme_handler_path: theme/pdf_handler.py
I could not use the --strict
when I tried this, because it gave the error - WARNING - Config value: 'theme_handler_path'. Warning: Unrecognised configuration name: theme_handler_path
This works find after removing --strict
Hi, I have read the documentation. And it seem the way to change is to add our file to extra_css
in config file.
extra_css:
- css/extra.css
I have done so. On build, the file extra.css wll be addded in site
but nothing seem to happen
I've managed to produce a nice-looking PDF matching our corp ident but can't see how to add an image (Logo) to the cover. Is it possible?
How can the font size be increased globally?
Especially the headings are pretty small when there are h5 or h6 headings.
It looks like the f"..." syntax is not supported in Python3.5.
Running mkdocs build gives:
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 11, in
sys.exit(cli())
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/mkdocs/main.py", line 152, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "/usr/local/lib/python3.5/dist-packages/mkdocs/config/base.py", line 197, in load_config
errors, warnings = cfg.validate()
File "/usr/local/lib/python3.5/dist-packages/mkdocs/config/base.py", line 107, in validate
run_failed, run_warnings = self._validate()
File "/usr/local/lib/python3.5/dist-packages/mkdocs/config/base.py", line 62, in _validate
self[key] = config_option.validate(value)
File "/usr/local/lib/python3.5/dist-packages/mkdocs/config/config_options.py", line 131, in validate
return self.run_validation(value)
File "/usr/local/lib/python3.5/dist-packages/mkdocs/config/config_options.py", line 609, in run_validation
plgins[item] = self.load_plugin(item, cfg)
File "/usr/local/lib/python3.5/dist-packages/mkdocs/config/config_options.py", line 617, in load_plugin
Plugin = self.installed_plugins[name].load()
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 2447, in load
return self.resolve()
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/init.py", line 2453, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/local/lib/python3.5/dist-packages/mkdocs_with_pdf/plugin.py", line 68
f'(set environment variable {env_name} to 1 to enable)'
^
SyntaxError: invalid syntax
This is a bug in "WeasyPrint v52".
Do not use v52.
If I add a markdown Link to a chapter like this
[My Chapter](../../my/chapter)
it is not resolved in the pdf and I get an error on build time that there is no anchor, however the following works:
[My Chapter](../../my/chapter/)
Both are resolved correctly in the web version.
the pdf generator was working nice until we decided to use the tabbed extension.
https://facelessuser.github.io/pymdown-extensions/extensions/tabbed/
The issue is simple
-the content from other tab then the first tab is not rendered,
would be nice to see the support for that.
I want to create a docker image based on alpine linux for sphinx and this awesome theme. Libsass package is too complicated, it must be compiled and it is too heavy (~60MB) also. Would it be possible to replace it with another written in pure python? For example https://github.com/Kronuz/pyScss?
If you have a table that is longer than a single page, the table is always starting on a separate page even if the content above the table consists only of a single sentence. I know it's not easy to define when a pagebreak makes sense and when it doesn't... Maybe you have an idea on how to improve this.
My markdown doc contains Chinese, Chinese is garbled after the generated PDF. What should I do? What are the possible problems? I'm a new guy, and I don't have any idea.
[root@centos7 ~]# python -V
Python 3.7.5
[root@centos7 ~]# pip list
Package Version
-------------------------- ---------
beautifulsoup4 4.9.3
cairocffi 1.2.0
CairoSVG 2.5.2
cffi 1.14.5
click 7.1.2
cssselect2 0.4.1
defusedxml 0.7.1
future 0.18.2
html5lib 1.1
importlib-metadata 3.7.3
Jinja2 2.11.3
joblib 1.0.1
libsass 0.20.1
livereload 2.6.3
lunr 0.5.8
Markdown 3.3.4
MarkupSafe 1.1.1
mkdocs 1.1.2
mkdocs-material 7.0.6
mkdocs-material-extensions 1.0.1
mkdocs-pdf-export-plugin 0.5.8
mkdocs-with-pdf 0.8.3
nltk 3.5
Pillow 8.1.2
pip 19.2.3
pycparser 2.20
Pygments 2.8.1
pymarkdown 0.1.4
pymdown-extensions 8.1.1
Pyphen 0.10.0
PyYAML 5.4.1
regex 2021.3.17
setuptools 41.2.0
six 1.15.0
soupsieve 2.2.1
tinycss2 1.1.0
toolz 0.11.1
tornado 6.1
tqdm 4.59.0
typing-extensions 3.7.4.3
WeasyPrint 52.4
webencodings 0.5.1
zipp 3.4.1
1. Create a new project.
[root@centos7 ~]# mkdocs new test
[root@centos7 ~]# cd test/
2. Using the plugin.
[root@centos7 test]# cat > mkdocs.yml <<EOF
site_name: 我的测试
dev_addr: 0.0.0.0:8000
plugins:
- with-pdf:
EOF
3. Rewrite index.md with Chinese
[root@centos7 test]# cat > docs/index.md <<"EOF"
完整文档请访问:[mkdocs.org](https://www.mkdocs.org).
* `mkdocs new [dir-name]` - 创建一个新项目
* `mkdocs serve` - 启动实时重新加载文档服务器
* `mkdocs build` - 建立文档站点
* `mkdocs -h` - 打印这个帮助信息
mkdocs.yml # 配置文件、
docs/
index.md # 文档根页面
... # 其他markdown页面, 镜像或其他问题
EOF
4. mkdocs build
[root@centos7 test]# mkdocs build
WARNING - Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready server instead.
INFO - Cleaning site directory
INFO - Building documentation to directory: /root/test/site
INFO - Number headings up to level 3.
INFO - Generate a table of contents up to heading level 2.
INFO - Generate a cover page with "default_cover.html.j2".
INFO - Converting <img> alignment(workaround).
INFO - Rendering for PDF.
INFO - Output a PDF to "/root/test/site/pdf/document.pdf".
INFO - Converting 1 articles to PDF took 2.2s
INFO - Documentation built in 2.47 seconds
5. Download and open the pdf
I have run into an issue which might be related to #46.
The problem is that I am unable to use exclude_pages
together with awesome-pages
. Basically, if I use the ...
in my mkdocs.yaml file, to have awesome-pages automatically add pages to nav
, the exclude_pages
functionality stops working.
I have created MWE in this repository: https://github.com/ErikThorsell/mkdocs_with_pdf-exclude_pages-bug. The key thing is Line 26 in the mkdocs.yaml (link), please see the inline comment.
Please let me know if there's anything I can do to assist you further in debugging the issue.
Is your feature request related to a problem? Please describe.
I can't render Mermaid diagrams using Headless Chrome JS renderer.
Everything renders correctly, except Mermaid Diagrams. Do you
have any working example to check this on your side?
Describe the solution you'd like
I would like to have Mermaid Diagrams rendered correctly into the output PDF.
Describe alternatives you've considered
I worked with the code a bit and noticed, that the produced output HTML is
working correctly and when open in the web browser e.g. firefox it
renders Mermaid diagrams fine. But after generating PDF diagrams disappear.
So... I noticed that https://github.com/RelaxedJS/ReLaXed is able to render
PDF correctly, so basically I am taking the output HTML and open a subprocess
with 'relaxed' to do a last step with the PDF processing and I managed to
get the diagrams working.
I am just wondering, why is this not working with Headless Chrome for me?
Maybe I am doing something wrong.
I see that another plugin is working with the diagrams fine:
https://github.com/smaxtec/mkdocs-pdf-with-js-plugin
Otherwise maybe you would consider a PR with additional option for used
the 'relaxed' tool as an alternative to the Headless Chrome?
Additional context
Versions:
mkdocs-with-pdf: 0.7.7
python: 3.7.9
chromedriver: 86.0.4240.22
Chrome: 86.0.4240.111
Material for mkdocs supports the permalink
markdown extension as described here:
https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#table-of-contents
It would be great to have support for that in the pdf, in the sense that when a link points to the anchor like this
[My subsection](#mysubsection)
it is correctly resolved.
An author name specified in the the mkdocs.yaml file containing an apostrophe will cause the pdf generation to crash.
E.g. O'Leary
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 176, in gh_deploy_command
build.build(cfg, dirty=not clean)
File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 295, in build
config['plugins'].run_event('post_build', config=config)
File "/usr/local/lib/python3.9/site-packages/mkdocs/plugins.py", line 96, in run_event
result = method(**kwargs)
File "/usr/local/lib/python3.9/site-packages/mkdocs_with_pdf/plugin.py", line 106, in on_post_build
self.generator.on_post_build(config, self.config['output_path'])
File "/usr/local/lib/python3.9/site-packages/mkdocs_with_pdf/generator.py", line 101, in on_post_build
add_stylesheet(style_for_print(self._options))
File "/usr/local/lib/python3.9/site-packages/mkdocs_with_pdf/styles/__init__.py", line 17, in style_for_print
root = sass.compile(string=scss)
File "/usr/local/lib/python3.9/site-packages/sass.py", line 738, in compile
raise CompileError(v)
sass.CompileError: Error: Invalid CSS after "...copyright 'None": expected expression (e.g. 1px, bold), was "';"
on line 4:36 of stdin
>> string-set: copyright 'None';
The apostrophe can be escaped O\'Leary, which no longer crashes, but the name appears in the pdf with the escaping backslash.
Mkdocs material supports image alignment: https://squidfunk.github.io/mkdocs-material/reference/images/#images
However, this has no effect on the pdf. I looked into the html debug output and the html attribute is set correctly. So I think there is either a problem with the css or with WeasyPrint.
If you give me a pointer on where to look I'll gladly help fixing the issue.
how to export B5 instead of A4
Hi guys, thx very much for this amazing plugin, by far one of the best I tried!
I run into some issues which I hope you can help with. I often put pictures inside tables to have a side by side view and to auto-size the pictures between mobile and desktop. I think what happens is that pictures get in the full resolution which ends up cutting the table and misses content.
On PDF output - Only part of the table
The markup
## **Install display on your handlebar**
| Measure handlebar | Tighten the screw | Allow slight rotation | Plug-in the connector |
|:-:|:-:|:-:|:-:|
| ![Handlebar measurement][HandlebarMeasurement] | ![EggRider hero][DisplayScrewThightening] | ![Allow slight rotation][DisplaySlightRotation] | ![Plug-in connector][PlugConnectors] |
The HTML
<h2 id="install-display-on-your-handlebar"><strong>Install display on your handlebar</strong><a class="headerlink" href="#install-display-on-your-handlebar" title="Permanent link">Link</a></h2>
<div class="md-typeset__scrollwrap"><div class="md-typeset__table"><table> <thead> <tr> <th align="center">Measure handlebar</th> <th align="center">Tighten the screw</th> <th align="center">Allow slight rotation</th> <th align="center">Plug-in the connector</th> </tr> </thead> <tbody> <tr> <td align="center"><img alt="Handlebar measurement" src="../assets/images/display_instructions/handlebar_measurement.jpg" title="Handlebar measurement"></td> <td align="center"><img alt="EggRider hero" src="../assets/images/display_instructions/eggrider_screw_tightening.jpg" title="EggRider screw thightening"></td> <td align="center"><img alt="Allow slight rotation" src="../assets/images/display_instructions/eggrider_allow_slight_rotation2.jpg" title="EggRider allow slight rotation"></td> <td align="center"><img alt="Plug-in connector" src="../assets/images/display_instructions/plug_connectors.jpg" title="Plug connectors"></td> </tr> </tbody> </table></div></div>
PS: I tried the suggestions in #23 but no success :(
I would really appreciate your help! Keep up with the good work!
Mkdocs provides a --strict
flag for the build with
mkdocs build --strict
This fails on all warnings. This is especially useful for pipelines, where you don't want to publish when there are warnings or errors. However when enabled it ignores all errors from mkdocs-with-pdf. It would be great to either directly integrate with the mkdocs flag or to provide a different way to configure mkdocs-with-pdf to fail on errors.
With a nav bar like below.
- Logs:
2020:
- Something:
- log/2020/something/somepage.md
Basically any title that is all numbers, it results in:
Traceback (most recent call last):
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/bin/mkdocs", line 10, in <module>
sys.exit(cli())
File "/home/user/.guix-extra-profiles/extras/extras/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/user/.guix-extra-profiles/extras/extras/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/user/.guix-extra-profiles/extras/extras/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/user/.guix-extra-profiles/extras/extras/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/user/.guix-extra-profiles/extras/extras/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs/__main__.py", line 183, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs/commands/build.py", line 309, in build
config['plugins'].run_event('post_build', config=config)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs/plugins.py", line 96, in run_event
result = method(**kwargs)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/plugin.py", line 134, in on_post_build
self.generator.on_post_build(config, self.config['output_path'])
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/generator.py", line 126, in on_post_build
content = self._get_content(soup, page)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/generator.py", line 248, in _get_content
content = self._get_content(soup, c)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/generator.py", line 248, in _get_content
content = self._get_content(soup, c)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/generator.py", line 264, in _get_content
page_path = self._page_path_for_id(page)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/generator.py", line 185, in _page_path_for_id
path = get_section_path(page)
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/utils/section.py", line 11, in get_section_path
slugs = list(map(lambda sec: _section_slug(sec), section.ancestors))
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/utils/section.py", line 11, in <lambda>
slugs = list(map(lambda sec: _section_slug(sec), section.ancestors))
File "/home/user/.cache/venv/mobile-sre-docs-3.8.2/lib/python3.8/site-packages/mkdocs_with_pdf/utils/section.py", line 26, in _section_slug
title = section.title if len(section.title) else str(uuid4)
TypeError: object of type 'int' has no len()
- with-pdf:
copyright: Copyright © Shanghai LianWei Digits Technology Group Co., Ltd.,All Rights Resevered.
author: Jes.Xiao
#cover_title:
cover_subtitle: LIANWEI EES Technical documentation
cover_logo: assets/lw-logo.png
back_cover: true
toc_level: 3
# excludes_children:
# - 'releases/changelog/:upgrading'
# convert_iframe:
# - src: https://streamable.com/e/zmtb00
# img: https://cdn-cf-east.streamable.com/image/zmtb00-screenshot75403.jpg
# two_columns_level: 3
output_path: ../document.pdf
#debug_html: true
#verbose: true
#show_anchors: true
enabled_if_env: ENABLE_PDF_EXPORT
# headless chrome using 'MathJax', 'Twemoji' or any more.
render_js: true
headless_chrome_path: 'C:\Program Files\Google\Chrome\Application\chrome.exe'
- i18n:
default_language: en
default_language_only: false
languages:
en: english
fr: français
nav_translations:
fr:
Home: Domicile
The result:
mkdocs.exe build
WARNING - Language 'fr' is not supported by lunr.js, not setting it in the 'plugins.search.lang' option
INFO - Cleaning site directory
INFO - Building documentation to directory: C:\projects\lianwei\framework\lianwei-doc\contents\site
Traceback (most recent call last):
File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python39\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
File "c:\python39\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\python39\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\python39\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\python39\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\python39\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\python39\lib\site-packages\mkdocs\__main__.py", line 152, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "c:\python39\lib\site-packages\mkdocs\commands\build.py", line 261, in build
files = config['plugins'].run_event('files', files, config=config)
File "c:\python39\lib\site-packages\mkdocs\plugins.py", line 94, in run_event
result = method(item, **kwargs)
File "c:\python39\lib\site-packages\mkdocs_static_i18n\plugin.py", line 367, in on_files
self.i18n_configs[language] = deepcopy(config)
File "c:\python39\lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "c:\python39\lib\copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\python39\lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "c:\python39\lib\copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 205, in _deepcopy_list
append(deepcopy(a, memo))
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 237, in _deepcopy_method
return type(x)(x.__func__, deepcopy(x.__self__, memo))
File "c:\python39\lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "c:\python39\lib\copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\python39\lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "c:\python39\lib\copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "c:\python39\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\python39\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\python39\lib\copy.py", line 161, in deepcopy
rv = reductor(4)
TypeError: cannot pickle 'module' object
Thanks a lot!
If I include a link to another page in the Markdown using [link description](page.md)
syntax the link doesn't not work in the generated PDF - the generated web site works OK.
There is an error output when the mkdocs build command is run, that corresponds to each instance of a page link in the Markdown docs : ERROR - No anchor #page.html: for internal URI reference.
It doesn't matter if the Markdown pages are in the same directory, in the root docs directory or in a subdirectories of the docs directory - none of the internal links work.
I have the recommended toc extension with the permalink: true option set and the use_directory_urls option set to false as specified in the documentation.
Using the debug_html option I can see there is no id attribute on the article tag for a page, so looks like there is no anchor being created for pages, just a data-url tag.
Version 0.3.3 + MkDocs 1.1.2
Link to sections from subdirs aren't connected depending on the value of use_directory_urls
:
huh.md:
# TEST
## One
- [Link 1: to subdir (file)](subdir/huh.md)
- [Link 2: to subdir (section)](subdir/huh.md#one)
subdir/huh.md:
# SUBDIR TEST
# One
- [Link 3: to parent (file)](../huh.md)
- [Link 4: to parent (section)](../huh.md#one)
use_directory_urls: true
(default): Links 2 & 4 ok, 1 & 3 broken ('The application can’t be opened.')use_directory_urls: false
: Links 1, 2 & 3 ok. Link 4 inactive.How to exclude a single page?
For example, i have a landing page in my docs folder with directory docs/index.md
.
And i want to exlude that in my generated PDF? How to do that?
The sample only show us how to exclude folder.
Thanks in advance @orzih
I'm using material for Mkdocs. In markdown a horizontal line can be added with the following code:
---
it looks like this
this is not rendered in the PDF.
I want to change the PDF footer.
I added extra_css such as the following:
@page {
@bottom-center {
font-size: 6pt;
content: string(copyright);
}
@bottom-right {
font-size: 8pt;
content: '- 'counter(page)'/'counter(pages)' -';
}
}
But it didn't change.
Is there any way to change the style of the output PDF ?
Hi,
When generating a pdf, I would like to change the phrase "table of content" for its French equivalent "Table des matières". I tried to change it with CSS :
article#doc-toc > h1 {
content:"Table des matières" !important;
}
However it did not change. Please advise.
Usage of exclude_pages
causes whatever pages are excluded to not only be excluded from generated PDF (desired behavior), but also to be skipped when mkdocs generates the site html (undesired behavior).
I have tested this multiple times with both mkdocs build
and mkdocs serve
as did a colleague of mine on a different mkdocs project. When attempting to navigate to the page on the development server (localhost:8000), when I click the link it changes the browser URL to reflect the target page, but only shows previous pages' content. If I click it again, it updates the URL with additional paths that make the link nonsensical (something like localhost:8000/this/is/a/test/page/
to localhost:8000/this/is/a/test/page/a/test/page/
) and I get an error 404. If I attempt to navigate to the page directly by URL, it displays a blank page, with absolutely no content. This is consistent across Chrome and Firefox.
The output file for an excluded site page contains only <!-- skipped 'Page(title='TITLE', url='this/is/a/test/page/')' -->
(edited to reflect example used earlier).
I'm using:
I don't know why it would be intended behavior if a user could simply remove a page from their documentation to the same effect. I don't believe that this is intended behavior, but if it is then it should probably be clearly reflected in the documentation.
Hello, if the table row data is too much, some rows will be lost after the PDF is generated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.