0

My trainings were inspired by the following (one of the questions didn't work):

And the tutorial:

Converting Markdown to Beautiful PDF with Pandoc

My platform:

  • Endeavour OS (derived of Arch Linux)
  • KDE Plasma
  • MikTeX
  • Terminator

I have Lua installed.

My goal is to:

  • convert multiple Markdown to one single PDF page (not multiple PDF pages)
  • include multiple CSS files;
  • use LaTeX macros (for example: $\LaTeX$ on Markdown file)
  • to preserve YAML header data

I tried to run the command:

$ cd diários
$ pandoc -s \
  # Because of few LaTeX macros on one Markdown file
  -f markdown \
  # I need to use HTML 5, but the result warned it is not compatible with the format output (xelatex)
  -t html5 \
  # Accoridng to https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/
  --pdf-engine=xelatex \
  --self-contained \
  # Multiple CSS files
  --css ../assets/css/colours.css,../assets/css/fonts.css,../assets/css/global.css \
  # To preserve YAML data
  --lua-filter=../scripts/demote.lua \
  # Multiple Markdown files
  -V geometry:margin=1in \
  *.md \
  # Output as PDF
  -o combined.pdf

Tree

.
├── assets
│   ├── css
│   │   ├── colours.css
│   │   ├── fonts.css
│   │   ├── global.css
│   ├── fonts
│   │   ├── Latin Modern
│   │   │   ├── LM-bold-italic.woff
│   │   │   ├── LM-bold-italic.woff2
│   │   │   ├── LM-bold.woff
│   │   │   ├── LM-bold.woff2
│   │   │   ├── LM-italic.woff
│   │   │   ├── LM-italic.woff2
│   │   │   ├── LM-regular.woff
│   │   │   └── LM-regular.woff2
│   │   
│   ├── images
│   │   ├── 2021-12-27-camiseta-do-hackathon-do-itau.jpeg
│   │   ├── emojis
│   │   │   ├── 32
│   │   │   │   ├── 1-emoji-excited.png
│   │   │   │   ├── 2-emoji-happy.png
│   │   │   │   ├── 3-emoji-neutral.png
│   │   │   │   ├── 4-emoji-sad.png
│   │   │   │   └── 5-emoji-down.png
│   ├── videos
│   │   └── 2021-12-27 – Comboio no temrinal em dois monitores.mp4
├── diários
│   ├── 2021-05-28.md
│   ├── 2021-12-25.md
│   ├── 2021-12-26.md
│   ├── 2021-12-27.md
│   ├── 2021-12-28.md
│   ├── 2021-12-29.md
│   ├── 2021-12-30.md
│   ├── 2021-12-31.md
│   ├── 2022-01-01.md
│   ├── 2022-01-02.md
│   ├── 2022-01-03.md
│   ├── 2022-01-04.md
│   ├── 2022-01-05.md
│   ├── 2022-01-06.md
│   ├── 2022-01-07.md
│   ├── 2022-01-10.md
│   ├── 2022-01-11.md
├── scripts
│   └── demote.lua

Errors

pdf-engine xelatex is not compatible with output format html5

And with -t html5, another error:

Error running filter ../scripts/demote.lua:
[string "--[[..."]:227: Constructor for Header failed: [string "--[[..."]:258: attempt to index a nil value (local 'x')

stack traceback:
        [C]: in function 'error'
        [string "--[[..."]:227: in field 'Header'
        ../scripts/demote.lua:11: in function 'Pandoc'

With --lua-filter=../scripts/demote.lua removed, it almost worked, but it did not capture the CSS files. I believe the problem is in the pdf-engine=xelatex.

Oo'-
  • 203
  • 6
  • 22
  • Done. Updated command code, added tree displaying and errors, @KJ. – Oo'- Jan 18 '22 at 03:43
  • @KJ, added platform info. Done. – Oo'- Jan 18 '22 at 03:45
  • If you want to use CSS, you cannot use LaTeX (or XeLaTeX) to generate the PDF, but one of the other options pandoc supports as well. See https://pandoc.org/MANUAL.html#creating-a-pdf – mb21 Jan 19 '22 at 15:58

0 Answers0