[More quick guides]

A quick guide to using
MarkDown in Prince

Browsers, where art thou?

Prince is a HTML-to-PDF-via-CSS converter which is often used for creating books from HTML and CSS. The most recent version also adds support for Markdown, a lightweight markup language. Markdown is easier to write by hand than regular HTML, and you can achieve impressive results with minimal markup. Ehh, markdown.

Hello, World!

We start with very simple document, which only has one line of text:

mdHello, World!

By saving this to a file which as a .md extension, we can make Prince read the input as Markdown:

prince sample-1.md

If it doesn't work, make sure you use the more recent version of Prince.

A real document

md# Showing off Markdown

This is a simple paragraph. Here's a list:

- **Bold** text
- *Italic* text
- `inline code`
- [Hyperlinks](https://www.markdownguide.org)

## More features

1. Hello, World!
2. Hei, verden!

Blockquotes are easy:

> I'm a blocky quote

### Links

- [Markdown Guide](https://www.markdownguide.org)
- [GitHub Markdown Docs](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)

Math

md# Simple Markdown with Mathematical Formulas

This document demonstrates math formulas that can be processed nicely with Prince XML.

## Inline Formulas

The area of a circle is $A = \pi r^2$, where $r$ is the radius.

Energy and mass are related by Einstein's equation: $E = mc^2$.

The speed of light is approximately $c \approx 3 \times 10^8$ m/s.

## Display (Block) Formulas

The quadratic formula is:

$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$

Pythagorean theorem:

$$
a^2 + b^2 = c^2
$$

The famous limit definition of $e$:

$$
e = \lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n
$$

## Another Example

The derivative of $f(x) = x^2$ is $f'(x) = 2x$.

> These formulas use standard LaTeX syntax inside Markdown.  
> For best results with Prince, convert this Markdown to HTML first (using Pandoc recommended), then run Prince on the HTML file.

You can add as many formulas as you like using `$...$` or `$$...$$`.

Smart quotes, dashes, and ellipses

md# Smart Typography Demo

Straight quotes: "double quotes" and 'single quotes'.

- The **en dash** `--` is used for ranges and connections: 2020–2025, pages 45–52, or New York–London.
- The **em dash** `---` is used for interruptions or asides — like this one right here.

An ellipsis indicates a pause, omission, or trailing thought...

These features must be turned on with command-like switches.

Styling Markdown with CSS

You can add HTML elements inside Markdown files. This allows for adding a style sheet through the style element:

md<style>
@import url('https://fonts.googleapis.com/css2?family=Sorts+Mill+Goudy');
@page { size: a4 landscape; margin: 0 }
html { background: red; font: bold 10vw Sorts Mill Goudy; color: white; text-align: center }
</style>

Hello, World!

Cheat Sheet

Prince converts Markdown to HTML before formatting. Here's an overview of transformations:

Markdown Syntax HTML Output Meaning / Purpose
*italic text* or _italic text_ <em>italic text</em> Italic / emphasis
**bold text** or __bold text__ <strong>bold text</strong> Bold / strong importance
***bold and italic*** <em><strong>bold and italic</strong></em> Bold + Italic
`inline code` <code>inline code</code> Inline code
> This is a blockquote <blockquote>...</blockquote> Blockquote
- Item or * Item <ul><li>Item</li></ul> Unordered (bullet) list
1. Item <ol><li>Item</li></ol> Ordered (numbered) list
[Link text](https://example.com) <a href="https://example.com">Link text</a> Hyperlink
![Alt text](image.jpg) <img src="image.jpg" alt="Alt text"> Image with alt text
<img src="image.jpg"> <img src="image.jpg"> Image without any alt attribute (raw HTML)
# Heading 1 <h1>Heading 1</h1> Level 1 Heading
## Heading 2 <h2>Heading 2</h2> Level 2 Heading
### Heading 3 <h3>Heading 3</h3> Level 3 Heading
--- or *** or ___ <hr> Horizontal rule (separator line)
~~strikethrough~~ <del>strikethrough</del> Strikethrough
"double quotes" “double quotes” Smart double quotes
'single quotes' ‘single quotes’ Smart single quotes
-- En dash (used for ranges, e.g. 2020–2025)
--- Em dash (used for interruptions — like this)
... Ellipsis
^superscript^ <sup>superscript</sup> Requires --markdown-superscript command-line switch
^subscript^ <sup>subscript</sup> Requires --markdown-subscript command-line switch

2026-04-06 Håkon Wium Lie