pingcap / docs

TiDB database documentation.
https://docs.pingcap.com
Other
579 stars 671 forks source link

PDF generation uses obsoleted options #5634

Open dveeden opened 3 years ago

dveeden commented 3 years ago

Error Report

$ ./scripts/generate_pdf.sh 
--smart/-S has been removed.  Use +smart or -smart extension instead.
For example: pandoc -f markdown+smart -t markdown-smart.
--latex-engine has been removed.  Use --pdf-engine instead.
Try pandoc --help for more information.
$ pandoc -v
pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.2, skylighting 0.8.5
Default user data directory: /home/dvaneeden/.local/share/pandoc or /home/dvaneeden/.pandoc
Copyright (C) 2006-2020 John MacFarlane
Web:  https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
TomShawn commented 3 years ago

@YiniXu9506 Could you please also take a look? Thanks!

dveeden commented 3 years ago

https://hub.docker.com/r/andelf/doc-build/tags?page=1&ordering=last_updated The doc-build image seems to be quite old.

https://github.com/andelf/dockerfiles/blob/master/doc-build/Dockerfile shows that this uses pandoc 1.19.2

dveeden commented 3 years ago

I created an updated version of that Dockerfile:

FROM circleci/python:3.9

RUN mkdir -p /tmp/prepare && \
    cd /tmp/prepare && \
    curl -L https://github.com/jgm/pandoc/releases/download/2.13/pandoc-2.13-1-amd64.deb -o pandoc.deb && \
    sudo dpkg -i pandoc.deb && \
    sudo apt-get -y install texlive-xetex texlive-latex-extra texlive-lang-cjk && \
    sudo apt-get -y install ttf-wqy-microhei && \
    sudo pip3 install qiniu && \
    sudo rm -rf /tmp/prepare && \
    sudo rm -rf /var/lib/apt/lists/* && \
    sudo bash -c 'echo "119.188.128.5 uc.qbox.me" >> /etc/hosts'
dveeden commented 3 years ago

In generate_pdf.sh:

diff --git a/scripts/generate_pdf.sh b/scripts/generate_pdf.sh
index fb2cf3e5..f2881117 100755
--- a/scripts/generate_pdf.sh
+++ b/scripts/generate_pdf.sh
@@ -15,7 +15,8 @@ _version_tag="$(date '+%Y%m%d')"
 # default version: `pandoc --latex-engine=xelatex doc.md -s -o output2.pdf`
 # used to debug template setting error

-pandoc -N --toc --smart --latex-engine=xelatex \
+pandoc -N --toc --pdf-engine=xelatex \
+-f markdown+smart \
 --template=templates/template.tex \
 --columns=80 \
 --listings \

Looks like templates/template.tex needs to be updated as well:

diff --git a/templates/template.tex b/templates/template.tex
index cf372e56..7f89fbb6 100644
--- a/templates/template.tex
+++ b/templates/template.tex
@@ -67,6 +67,7 @@ $if(listings)$

 \usepackage{xcolor}
 \usepackage{listings}
+\newcommand{\passthrough}[1]{#1}
 \lstset{
     basicstyle=\ttfamily,
     keywordstyle=\color[rgb]{0.13,0.29,0.53}\bfseries,
dveeden commented 3 years ago

There might be other things as well from https://raw.githubusercontent.com/jgm/pandoc-templates/master/default.latex that need to be merged into templates/template.tex

dveeden commented 8 months ago

A Makefile like this might be useful:

default: output.pdf

doc.md:
    ./scripts/merge_by_toc.py

output.pdf: doc.md
    ./scripts/generate_pdf.sh
dveeden commented 8 months ago

For newer pandoc versions this is needed as well:

diff --git a/templates/deeplist.tex b/templates/deeplist.tex
index 3776db45b..6413f3be9 100644
--- a/templates/deeplist.tex
+++ b/templates/deeplist.tex
@@ -1,4 +1,6 @@
 \usepackage{enumitem}
+\usepackage{array}
+\usepackage{calc}
 \setlistdepth{9}

 \setlist[itemize,1]{label=$\bullet$}
dveeden commented 8 months ago

Probably good to update the Git ignore file as well:

diff --git a/.gitignore b/.gitignore
index bbf3d54d0..5cff00ad1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,5 @@ gen
 /node_modules/

 tmp/
+doc.md
+output.pdf