diff --git a/Makefile b/Makefile index ea0e26adfce03..7da8ec6ccdbbf 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,9 @@ epub: @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: + $(PYTHON) docs/prepare_readme_for_latex.py $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + mv README.rst.bak README.rst @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ @@ -164,14 +166,18 @@ latex: # seems to be malfunctioning latexpdf: + $(PYTHON) docs/prepare_readme_for_latex.py $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + mv README.rst.bak README.rst @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." # seems to be malfunctioning latexpdfja: + $(PYTHON) docs/prepare_readme_for_latex.py $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + mv README.rst.bak README.rst @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." diff --git a/docs/prepare_readme_for_latex.py b/docs/prepare_readme_for_latex.py new file mode 100644 index 0000000000000..a22abbdeb8a0a --- /dev/null +++ b/docs/prepare_readme_for_latex.py @@ -0,0 +1,18 @@ +import shutil + +with open("README.rst", "r") as f: + readme_content = f.read() + +shutil.copyfile("README.rst", "README.rst.bak") + +# turn badge into text only +modified_readme_content = readme_content.replace("|Weblate|", "Weblate", 1) + +# remove image link +badge_link_lines = """.. |Weblate| image:: https://hosted.weblate.org/widgets/circuitpython/-/svg-badge.svg + :target: https://hosted.weblate.org/engage/circuitpython/?utm_source=widget""" + +modified_readme_content = modified_readme_content.replace(badge_link_lines, "") + +with open("README.rst", "w") as f: + f.write(modified_readme_content)