Skip to content

Notes

  • anytype
  • Beaver notes To convert your Markdown pages into:

  • A PDF book

  • A single HTML file

You can use Pandoc – the best tool for this kind of task.


🔧 Requirements

Install Pandoc and a PDF engine:

On Linux (Debian/Ubuntu/Raspberry Pi):

sudo apt update
sudo apt install pandoc texlive-xetex

On Termux (Android):

pkg install pandoc texlive

📁 Step 1: Organize your markdown files

Make sure your files are in order, e.g.:

book/
├── Step 1.md
├── Step 2.md
├── Step 3.md
└── Step 4.md

Create a file like book.txt listing them in order:

Step 1.md
Step 2.md
Step 3.md
Step 4.md

📘 Generate PDF book

Use this command:

pandoc $(cat book.txt) -o MyBook.pdf --pdf-engine=xelatex

Or for a fancier look with a title page:

pandoc $(cat book.txt) -o MyBook.pdf --pdf-engine=xelatex --metadata title="My Book Title"

🌐 Generate single HTML file

pandoc $(cat book.txt) -o MyBook.html --standalone

You can also embed all styles and images:

pandoc $(cat book.txt) -o MyBook.html --standalone --self-contained

Would you like a custom CSS theme or a cover page added to your book?

You’re asking if there is a way to convert Markdown files that reference images in a local ./assets folder into a single HTML file where those images are embedded as base64 (inline), right?


✅ Short answer:

Yes, there are tools and workflows that convert Markdown to single self-contained HTML with images embedded as Base64 data URIs.


How to do this? Here are some common methods:


  1. Pandoc with --self-contained option

Pandoc is a powerful universal document converter.

It can convert .md to .html

The flag --self-contained embeds local images as base64 inside the HTML

Example command:

pandoc input.md -o output.html --self-contained

Requirements:

Images referenced in Markdown like:

Alt text

Pandoc must be able to find the images in the relative path

Result:

One single HTML file with images embedded as Base64 data URLs


  1. Markdown-it + Plugin (for Node.js)

If you prefer a Node.js approach:

Use markdown-it

Use a plugin like markdown-it-imsize or write a custom plugin

Write a script to:

Read the markdown file

Detect image references

Convert images to Base64 data URIs

Replace image links in the rendered HTML


  1. Other tools

Typora (Markdown editor) — exports to HTML with embedded images (configurable)

Grip + custom scripts

md-to-html converters with base64 embed support


Sample Pandoc usage in Termux or Linux:

sudo apt install pandoc pandoc ./README.md -o ./output.html --self-contained


Summary:

Tool Embed Images as Base64 Output Ease of Use

Pandoc Yes (--self-contained) Single HTML Very easy (CLI) markdown-it + custom scripts Yes, customizable Single HTML Requires Node.js scripting Typora Yes (export option) Single HTML GUI-based


If you want, I can help you:

Write a Pandoc command for your files

Write a Node.js script that converts Markdown + local images to single HTML with base64 images embedded

Would you prefer CLI or Node.js approach?