Markdown
A markdown takes the place of a layout in a section and holds Markdown, which Lpdf sets as a styled, paginated PDF. It is for a body that is written as Markdown, such as release notes, an article or documentation, or that comes from a CMS, a database or a user. The page, the header, the footer and a cover are not Markdown, so they stay in the XML around it.
<markdown margin="54pt"> <markdown-content><.
- Faster layout - A `markdown` element
> A quote, with a bar beside it. ]]></markdown-content></markdown>L.markdown({ margin: '54pt' }, [ LMarkdown.content(NoAttr, ['# Release notes\n\nVersion 2 adds *Markdown* to **Lpdf**. See the [docs](https://lpdf.io).\n\n- Faster layout\n- A `markdown` element\n\n> A quote, with a bar beside it.']),])L.markdown(MarkdownAttr(margin='54pt'), [ LMarkdown.content(NoAttr, ['# Release notes\n\nVersion 2 adds *Markdown* to **Lpdf**. See the [docs](https://lpdf.io).\n\n- Faster layout\n- A `markdown` element\n\n> A quote, with a bar beside it.'])])L.markdown(new MarkdownAttr().margin("54pt"), List.of( LMarkdown.content(NoAttr, List.of("# Release notes\n\nVersion 2 adds *Markdown* to **Lpdf**. See the [docs](https://lpdf.io).\n\n- Faster layout\n- A `markdown` element\n\n> A quote, with a bar beside it."))))L.Markdown(new() { Margin = "54pt" }, [ LMarkdown.Content(NoAttr, ["# Release notes\n\nVersion 2 adds *Markdown* to **Lpdf**. See the [docs](https://lpdf.io).\n\n- Faster layout\n- A `markdown` element\n\n> A quote, with a bar beside it."]),])L::markdown(new MarkdownAttr(margin: '54pt'), [ LMarkdown::content(NoAttr, ["# Release notes\n\nVersion 2 adds *Markdown* to **Lpdf**. See the [docs](https://lpdf.io).\n\n- Faster layout\n- A `markdown` element\n\n> A quote, with a bar beside it."]),])A markdown holds an optional markdown-styles, which says how each part looks, and one markdown-content, which holds the text. With no styles it looks as rendered Markdown does on a project page: clear steps between the headings, comfortable line spacing, code in a thin outline, links in a color. The blocks flow down the page and across pages as the content of a layout does.
Attributes
Section titled “Attributes”| Attribute | Type | Default | Description |
|---|---|---|---|
margin |
spacing | 36pt |
The space between the page edges and the Markdown: one value for all four sides, or two to four in the order top, right, bottom, left. A layer draws a header or a footer in it |
font |
string | the document’s | The font of the Markdown, which a rule can change |
font-size |
token/length | m (11pt) |
The size of its text, which a rule can change |
color |
color | the text token |
The color of its text, which a rule can change |
gap |
token/length | l (14pt) |
The space between blocks: headings, paragraphs, lists, code, quotes, tables and images |
bookmarks |
integer | 6 |
How many levels of headings are bookmarks: 2 keeps the levels 1 and 2, 0 none |
debug |
boolean | false |
Draw the outline of each box |
A section holds one layout or one markdown, not both. Put the Markdown in a section of its own, and a cover or a table of contents in sections around it.
Where the Markdown comes from
Section titled “Where the Markdown comes from”markdown-content holds the text in one of three ways.
Inline. Markdown uses < and & freely, so write it in a CDATA section. The indent that all its lines share is removed first, so that indenting the XML does not make a code block of it, and an indent beyond that one is part of the Markdown.
From the data. data-value is a path in the data to a string that holds the Markdown, as it fills a text. The text written inside the element is what a document with no data shows. A path the data lacks leaves the Markdown empty, and a value that is not a string is an error.
<markdown> <markdown-content data-value="body"><![CDATA[ # The text that shows without data ]]></markdown-content></markdown>From code. The builders take the text as a string, from wherever the program has it: LMarkdown.content(NoAttr, [body]). See In code.
What it turns into
Section titled “What it turns into”The Markdown is CommonMark, with tables, strikethrough and footnotes. Each part becomes the Lpdf element in the second column, so what that element does, it does here.
| Markdown | Becomes | Note |
|---|---|---|
# … ###### |
a text for each of h1 to h6, kept on a page with the block after it |
Also a bookmark: see Headings |
| a paragraph | a text |
widows and orphans apply as on any text. A word or a run longer than a line breaks at the last character that fits, so nothing runs past the margin or out of a table cell |
*em*, **strong**, ~~del~~ |
a span | A built-in font gets its italic and bold face by itself. An embedded font names them: see Styling |
`code` |
a code-span |
The code font on a tint |
[text](url), [text](#id) |
a span with href |
#id jumps to the heading whose text is that id: see Headings |
 |
an image as wide as the page allows | JPEG, PNG, WebP, GIF, TIFF, BMP or SVG (see Formats), named as under Images. The alt text is the image’s alt, which a tagged document, with pdfua or a pdfa of level a, reads;  marks decoration |
--- |
a divider | |
> quote |
a bar beside the blocks of the quote | The quote splits across pages between its blocks. Quotes nest only so deep: see How deep it nests |
- item, 1. item |
a list of items, with a disc, a circle or a square for the level, or the numbers | A number list starts at the number its first item has. Lists nest only so deep: see How deep it nests |
| a fenced or indented block | a code | It keeps its spaces and lines and wraps what is long. The language of a fence is ignored: there is no highlighting by language |
| a table | a table with a header row | The columns are auto: each takes the width its cells need, and a name that does not fit breaks. A column takes its alignment from the :---: row, and the header row repeats on each page |
[^1] |
a footnote | A note that holds more than a paragraph is cut down to its words, and a note in a table is an error |
| a newline in a paragraph | a space | |
two spaces or a \ at the end of a line, <br>, <br/>, <br /> |
a new line in the same paragraph, cell or item | A hard break, as CommonMark has it, and a <br> in any case. The lines stand close, with no paragraph gap. A table cell is one line of the source, so a <br> is how it holds more than a line. Breaks in a row make one break, and a heading takes one as a space. A <br> alone on a line breaks nothing: write it at the end of the line it breaks |
| front matter | nothing | See A .md file |
- [ ] task, - [x] task |
an li with checked: a box in place of the marker |
The box is an outline in the line color, ticked in the color of the item’s words when it is [x]. A plain item in the same list keeps its bullet, and a task in a number list takes its number. [ ] anywhere but at the start of an item is text |
| a definition list | plain text | It is not read as such |
<img src="name" width="…" height="…"> |
an image, at that size | The one thing an <img> says that ![]() can’t: see Images |
| other raw HTML | its words | Raw HTML is for an HTML output, which a PDF is not, so a tag is left out and the words in it are kept. A block such as a <p>, a <div> or an <h2> puts the words around it on lines of their own. A comment, a <script> and a <style> leave nothing, and a character reference such as & or is its character. Nothing says that a tag was left out, so a <tag> that is meant as text is written in backticks, `<tag>`, or as \<tag> |
a $ |
text | $5 and $1M—$10M are drawn as written: there is no math |
Headings
Section titled “Headings”A heading is a bookmark, so the viewer’s outline and a table of contents fill themselves, with the level of the heading. bookmarks says how many levels count: bookmarks="2" leaves the third level and below out of the outline.
The id of a heading is made from its text as a bookmark’s is: lowercase, with every run of other characters than letters and digits made one hyphen, and -2, -3 added when an earlier bookmark has it. # 3.1 Methods is 3-1-methods, so [the methods](#3-1-methods) links to it. A link to a heading that is not a bookmark, because bookmarks leaves it out, goes nowhere.
A running header that shows the heading of the page needs capture-ref on a layer’s text-at, which Lpdf does not have yet. A header and a footer can show the page number and fixed words.
Headers and footers
Section titled “Headers and footers”A markdown has no region. Its margin reserves the space, and a layer draws in it, under the Markdown if it comes before it, over it if it comes after. {page} and {pages} and data-value work in a layer’s text-at.
<section> <layer> <rect x="0pt" y="0pt" width="595pt" height="10pt" fill="primary"/> <text-at anchor="bottom-center" y="-24pt" font-size="xs" color="text-muted">Page {page} of {pages}</text-at> </layer> <markdown margin="54pt 54pt 60pt 54pt" gap="m"> <markdown-content><![CDATA[ # Quarterly report
The page number is a layer, drawn in the margin the Markdown leaves. ]]></markdown-content> </markdown></section>L.section(NoAttr, [ L.layer(NoAttr, [ L.rect({ x: '0pt', y: '0pt', width: '595pt', height: '10pt', fill: 'primary' }), L.textAt({ anchor: 'bottom-center', y: '-24pt', fontSize: 'xs', color: 'text-muted' }, ['Page {page} of {pages}']), ]), L.markdown({ margin: '54pt 54pt 60pt 54pt', gap: 'm' }, [ LMarkdown.content(NoAttr, ['# Quarterly report\n\nThe page number is a layer, drawn in the margin the Markdown leaves.']), ]),])L.section(NoAttr, [ L.layer(NoAttr, [ L.rect(RectAttr(x='0pt', y='0pt', width='595pt', height='10pt', fill='primary')), L.text_at(TextAtAttr(anchor='bottom-center', y='-24pt', font_size='xs', color='text-muted'), ['Page {page} of {pages}']) ]), L.markdown(MarkdownAttr(margin='54pt 54pt 60pt 54pt', gap='m'), [ LMarkdown.content(NoAttr, ['# Quarterly report\n\nThe page number is a layer, drawn in the margin the Markdown leaves.']) ])])L.section(NoAttr, List.of( L.layer(NoAttr, List.of( L.rect(new RectAttr().x("0pt").y("0pt").width("595pt").height("10pt").fill("primary")), L.textAt(new TextAtAttr().anchor("bottom-center").y("-24pt").fontSize("xs").color("text-muted"), List.of("Page {page} of {pages}")) )), L.markdown(new MarkdownAttr().margin("54pt 54pt 60pt 54pt").gap("m"), List.of( LMarkdown.content(NoAttr, List.of("# Quarterly report\n\nThe page number is a layer, drawn in the margin the Markdown leaves.")) ))))L.Section(NoAttr, [ L.Layer(NoAttr, [ L.Rect(new() { X = "0pt", Y = "0pt", Width = "595pt", Height = "10pt", Fill = "primary" }), L.TextAt(new() { Anchor = "bottom-center", Y = "-24pt", FontSize = "xs", Color = "text-muted" }, ["Page {page} of {pages}"]), ]), L.Markdown(new() { Margin = "54pt 54pt 60pt 54pt", Gap = "m" }, [ LMarkdown.Content(NoAttr, ["# Quarterly report\n\nThe page number is a layer, drawn in the margin the Markdown leaves."]), ]),])L::section(NoAttr, [ L::layer(NoAttr, [ L::rect(new RectAttr(x: '0pt', y: '0pt', width: '595pt', height: '10pt', fill: 'primary')), L::textAt(new TextAtAttr(anchor: 'bottom-center', y: '-24pt', fontSize: 'xs', color: 'text-muted'), ['Page {page} of {pages}']), ]), L::markdown(new MarkdownAttr(margin: '54pt 54pt 60pt 54pt', gap: 'm'), [ LMarkdown::content(NoAttr, ["# Quarterly report\n\nThe page number is a layer, drawn in the margin the Markdown leaves."]), ]),])Styling
Section titled “Styling”A rule is an element named after the Markdown it styles, and it takes the attributes of the Lpdf element it becomes. The rules go in markdown-styles, so h1 and p mean nothing anywhere else.
<markdown gap="m"> <markdown-styles> <h1 font-size="xxl" color="primary"/> <h2 font-size="xl"/> <p align="justify" line-height="1.5"/> <quote bar-color="primary" bar-width="4pt" background="surface-alt"/> <li bullet="square" gap="s"/> <a underline="false"/> </markdown-styles> <markdown-content>< in it.
- A square bullet - Another ]]></markdown-content></markdown>L.markdown({ gap: 'm' }, [ LMarkdown.styles(NoAttr, [ LMarkdown.h1({ fontSize: 'xxl', color: 'primary' }), LMarkdown.h2({ fontSize: 'xl' }), LMarkdown.p({ align: 'justify', lineHeight: 1.5 }), LMarkdown.quote({ barColor: 'primary', barWidth: '4pt', background: 'surface-alt' }), LMarkdown.li({ bullet: 'square', gap: 's' }), LMarkdown.a({ underline: false }), ]), LMarkdown.content(NoAttr, ['# A heading in blue\n\nA paragraph with a [link](https://lpdf.io) in it.\n\n- A square bullet\n- Another']),])L.markdown(MarkdownAttr(gap='m'), [ LMarkdown.styles(NoAttr, [ LMarkdown.h1(MarkdownH1Attr(font_size='xxl', color='primary')), LMarkdown.h2(MarkdownH2Attr(font_size='xl')), LMarkdown.p(MarkdownPAttr(align='justify', line_height=1.5)), LMarkdown.quote(MarkdownQuoteAttr(bar_color='primary', bar_width='4pt', background='surface-alt')), LMarkdown.li(MarkdownLiAttr(bullet='square', gap='s')), LMarkdown.a(MarkdownAAttr(underline=False)) ]), LMarkdown.content(NoAttr, ['# A heading in blue\n\nA paragraph with a [link](https://lpdf.io) in it.\n\n- A square bullet\n- Another'])])L.markdown(new MarkdownAttr().gap("m"), List.of( LMarkdown.styles(NoAttr, List.of( LMarkdown.h1(new MarkdownH1Attr().fontSize("xxl").color("primary")), LMarkdown.h2(new MarkdownH2Attr().fontSize("xl")), LMarkdown.p(new MarkdownPAttr().align("justify").lineHeight(1.5)), LMarkdown.quote(new MarkdownQuoteAttr().barColor("primary").barWidth("4pt").background("surface-alt")), LMarkdown.li(new MarkdownLiAttr().bullet("square").gap("s")), LMarkdown.a(new MarkdownAAttr().underline(false)) )), LMarkdown.content(NoAttr, List.of("# A heading in blue\n\nA paragraph with a [link](https://lpdf.io) in it.\n\n- A square bullet\n- Another"))))L.Markdown(new() { Gap = "m" }, [ LMarkdown.Styles(NoAttr, [ LMarkdown.H1(new() { FontSize = "xxl", Color = "primary" }), LMarkdown.H2(new() { FontSize = "xl" }), LMarkdown.P(new() { Align = "justify", LineHeight = 1.5 }), LMarkdown.Quote(new() { BarColor = "primary", BarWidth = "4pt", Background = "surface-alt" }), LMarkdown.Li(new() { Bullet = "square", Gap = "s" }), LMarkdown.A(new() { Underline = false }), ]), LMarkdown.Content(NoAttr, ["# A heading in blue\n\nA paragraph with a [link](https://lpdf.io) in it.\n\n- A square bullet\n- Another"]),])L::markdown(new MarkdownAttr(gap: 'm'), [ LMarkdown::styles(NoAttr, [ LMarkdown::h1(new MarkdownH1Attr(fontSize: 'xxl', color: 'primary')), LMarkdown::h2(new MarkdownH2Attr(fontSize: 'xl')), LMarkdown::p(new MarkdownPAttr(align: 'justify', lineHeight: 1.5)), LMarkdown::quote(new MarkdownQuoteAttr(barColor: 'primary', barWidth: '4pt', background: 'surface-alt')), LMarkdown::li(new MarkdownLiAttr(bullet: 'square', gap: 's')), LMarkdown::a(new MarkdownAAttr(underline: false)), ]), LMarkdown::content(NoAttr, ["# A heading in blue\n\nA paragraph with a [link](https://lpdf.io) in it.\n\n- A square bullet\n- Another"]),])Values are the tokens (font-size="xxl", color="primary") or plain lengths and colors, and fonts are names from assets. An attribute a rule does not set stays as it was: the rules written here are laid over the rules of a file and the defaults one attribute at a time, so <h1 color="primary"/> changes the color and nothing else of a heading.
| Rule | Styles | Attributes |
|---|---|---|
h1 to h6, p |
the words of a heading and of a paragraph, and of a list item, a quote and a table cell where they hold paragraphs | font font-size bold color align line-height, and for the box around them padding background border radius |
code |
a block of code, and a run of code in a line | font font-size color line-height tab-size, and padding background border radius of the box. A run takes font, color and background |
quote |
a block quote | The words: font font-size bold color align line-height. The box: padding background border radius. The bar: bar-color and bar-width, a length or a token of the space row |
li |
a list and its items | indent, bullet (a bullet list’s only) and gap of the list, padding background border of an item, and font font-size color of its words |
hr |
a thematic break, --- |
color and thickness, a length or a token of the border row. The default is the line color at xs, a thin grey line, as a divider is |
a, strong, em, del |
a link, strong text, emphasis, struck-through text | font color, and underline and bold for a link, bold for strong text, strike for struck-through text |
table |
a table | border stripe head-border row-border gap padding background. The default has a line under the header and under each row, in the line-muted color, and no stripe: stripe="surface-alt" turns the stripe on, and head-border="none" row-border="none" the lines off |
th, td |
a cell of the header row, a cell of the others | font font-size bold color align padding background border |
A rule that is not one of these, or an attribute it does not take, is an error that names it, and so is a value that does not read.
Characters a built-in font has not got. A built-in font draws the Windows-1252 characters and the comparison signs ≥, ≤, ≠ and ≈. For the lines and corners of a box it draws -, | and +, for the arrows >, <, ^ and v, and for the other characters it has not got, such as ✓ or 日本, a ?. A document that needs them as they are sets the font of the rule, code for a diagram, to an embedded font that has them.
Italic and bold in an embedded font are fonts. A span has bold but no italic, and bold picks the bold face of a built-in font only. A document that sets the Markdown in an embedded font names the faces:
<markdown font="body"> <markdown-styles> <em font="body-italic"/> <strong font="body-bold"/> </markdown-styles> <markdown-content>Words in *italic* and **bold**.</markdown-content></markdown>L.markdown({ font: 'body' }, [ LMarkdown.styles(NoAttr, [ LMarkdown.em({ font: 'body-italic' }), LMarkdown.strong({ font: 'body-bold' }), ]), LMarkdown.content(NoAttr, ['Words in *italic* and **bold**.']),])L.markdown(MarkdownAttr(font='body'), [ LMarkdown.styles(NoAttr, [ LMarkdown.em(MarkdownEmAttr(font='body-italic')), LMarkdown.strong(MarkdownStrongAttr(font='body-bold')) ]), LMarkdown.content(NoAttr, ['Words in *italic* and **bold**.'])])L.markdown(new MarkdownAttr().font("body"), List.of( LMarkdown.styles(NoAttr, List.of( LMarkdown.em(new MarkdownEmAttr().font("body-italic")), LMarkdown.strong(new MarkdownStrongAttr().font("body-bold")) )), LMarkdown.content(NoAttr, List.of("Words in *italic* and **bold**."))))L.Markdown(new() { Font = "body" }, [ LMarkdown.Styles(NoAttr, [ LMarkdown.Em(new() { Font = "body-italic" }), LMarkdown.Strong(new() { Font = "body-bold" }), ]), LMarkdown.Content(NoAttr, ["Words in *italic* and **bold**."]),])L::markdown(new MarkdownAttr(font: 'body'), [ LMarkdown::styles(NoAttr, [ LMarkdown::em(new MarkdownEmAttr(font: 'body-italic')), LMarkdown::strong(new MarkdownStrongAttr(font: 'body-bold')), ]), LMarkdown::content(NoAttr, ['Words in *italic* and **bold**.']),])Rules in a file
Section titled “Rules in a file”src on markdown-styles names a file whose root is a markdown-styles. Its rules sit between the defaults and the rules written inline, which override them, so one file can serve every Markdown a template renders, and a template points its rules at token names, so that a token file restyles them all.
<markdown-styles src="styles/markdown-styles.xml"> <h1 color="primary"/></markdown-styles>LMarkdown.styles({ src: 'styles/markdown-styles.xml' }, [ LMarkdown.h1({ color: 'primary' }),])LMarkdown.styles(MarkdownStylesAttr(src='styles/markdown-styles.xml'), [ LMarkdown.h1(MarkdownH1Attr(color='primary'))])LMarkdown.styles(new MarkdownStylesAttr().src("styles/markdown-styles.xml"), List.of( LMarkdown.h1(new MarkdownH1Attr().color("primary"))))LMarkdown.Styles(new() { Src = "styles/markdown-styles.xml" }, [ LMarkdown.H1(new() { Color = "primary" }),])LMarkdown::styles(new MarkdownStylesAttr(src: 'styles/markdown-styles.xml'), [ LMarkdown::h1(new MarkdownH1Attr(color: 'primary')),])The engine reads no files: the SDK, the command line or the extension reads the src, as it reads the src of a font or an image, and a file it cannot read is an error that names the src.
The defaults
Section titled “The defaults”The defaults are rules like any other. Their colors are token names, so that a token file alone rebrands them, and the headings are one scale, 20, 15.5, 13, 12, 11 and 10pt for h1 to h6, against a paragraph of 11pt. The Serif and Typewriter looks of VS Code keep that scale with a paragraph of 12pt and 10pt. The engine carries them, so a markdown with no styles renders the same in every SDK. markdown-styles.xml in the core’s repository is the file, and in VS Code Lpdf: Link Markdown Styles… writes its Sans look, which is these defaults, beside a .md file to start from (VS Code).
Images
Section titled “Images”An image of the Markdown names an asset in the way it is written: by its name, or by its src. Declaring <image name="photo" src="img/photo.png"/> answers  and , so a .md file can keep the relative paths it has everywhere else. An image that is neither is an error that names the line. One at a URL is left out, as ![]() or as an <img>, since Lpdf does not download: the badges and logos of a README leave nothing, and the words around them stay. The image is as wide as the page allows and as tall as its proportions make it.
An <img> names an asset in its src in the same way, and its width and height give it a size, which Markdown’s own image has no way to say. They are pixels, with or without px, and a pixel is 0.75pt: width="320" is 240pt wide. With one of them, the other follows the image’s proportions. A percentage is ignored, and the image is as wide as the page allows.
<lpdf version="1"> <assets> <image name="photo" src="img/photo.png"/> </assets> <document> <section> <markdown> <markdown-content><
<img src="photo" width="200"> ]]></markdown-content> </markdown> </section> </document></lpdf>L.document({ assets: { images: [{ name: 'photo', src: 'img/photo.png' }] } }, [ L.section(NoAttr, [ L.markdown(NoAttr, [ LMarkdown.content(NoAttr, ['\n\n<img src="photo" width="200">']), ]), ]),])L.document(DocumentAttr(assets=DocumentAssets(images=[ImageAttr(name='photo', src='img/photo.png')])), [ L.section(NoAttr, [ L.markdown(NoAttr, [ LMarkdown.content(NoAttr, ['\n\n<img src="photo" width="200">']) ]) ])])L.document(new DocumentAttr().assets(new DocumentAssets().images(List.of(new ImageAttr().name("photo").src("img/photo.png")))), List.of( L.section(NoAttr, List.of( L.markdown(NoAttr, List.of( LMarkdown.content(NoAttr, List.of("\n\n<img src=\"photo\" width=\"200\">")) )) ))))L.Document(new() { Assets = new DocumentAssets(Images: [new ImageAttr { Name = "photo", Src = "img/photo.png" }]) }, [ L.Section(NoAttr, [ L.Markdown(NoAttr, [ LMarkdown.Content(NoAttr, ["\n\n<img src=\"photo\" width=\"200\">"]), ]), ]),])L::document(new DocumentAttr(assets: new DocumentAssets(images: [new ImageAttr(name: 'photo', src: 'img/photo.png')])), [ L::section(NoAttr, [ L::markdown(NoAttr, [ LMarkdown::content(NoAttr, ["\n\n<img src=\"photo\" width=\"200\">"]), ]), ]),])A .md file
Section titled “A .md file”A .md file is wrapped in a template: a document with a markdown that reads its text from the data markdown, which the file’s front matter goes with. The VS Code extension and the command line do it the same way.
- A YAML block at the top of the file, from
---to---, is not drawn. Itskey: valuelines are data beside the text, so a template can show them:<text-at data-value="title">. A value that is not on the line, a list and a nested field are left out. - A relative image, in
![]()or in an<img>, is declared in the template as an asset, read relative to the.mdfile. - With no template of its own, the file is set on an A4 page with a margin of 54pt and the page number at the foot.
lpdf convert --input notes.md --output notes.pdflpdf convert --input notes.md --template markdown-template.xml --output notes.pdf--template is a document like the one below, with --data adding fields to those of the front matter.
<lpdf version="1"> <document size="a4"> <section> <layer> <text-at anchor="bottom-center" y="-24pt" font-size="xs" color="text-muted">Page {page} of {pages}</text-at> </layer> <markdown margin="54pt"> <markdown-styles src="markdown-styles.xml"/> <markdown-content data-value="markdown"/> </markdown> </section> </document></lpdf>In VS Code, Lpdf: Preview PDF on a .md file shows it as a PDF beside the file, and updates it when the Markdown, its document, its styles file or an image changes. The extension links a file of styles and a document like the one above to a .md file, with commands: see VS Code.
How deep it nests
Section titled “How deep it nests”Quotes and lists nest in one another, and a document nests 100 levels at most (see XML Schema). A markdown is level 4, as a layout is, since lpdf, document and section are above it. A quote is written as a table, a row and a cell, so it takes 3 levels, and a list item as a list and an li, so it takes 2. The words, the table or the code inside the deepest one need a level too, so a Markdown holds 31 quotes or 47 list items in one another, and fewer of each in a mix: 19 times a quote with a list item in it, for one.
Emphasis, strong text, strikethrough and links nest 100 deep at most. They are spans of one text, not levels of the document, so they add none to the count above.
Markdown that nests deeper fails with an error that names the line it begins on, and what it may hold, not a crash. A Markdown from the data is held to it too: its error comes when the data is bound.
markdown line 3: a quote is nested too deep: a Markdown nests 31 quotes or 47 list items in one another at most, and fewer of each in a mix, since a document nests 100 levels at most and a quote counts 3 of them and a list item 2markdown line 8: emphasis, strong text, strikethrough and links are nested too deep: a Markdown nests 100 of them in one another at mostErrors
Section titled “Errors”The Markdown is read strictly, because it is in the hands of whoever renders it, and a mistake is an error that names the line of the Markdown and what to write instead. An application that renders Markdown of its users catches the error and shows it. Raw HTML is not a mistake: it is left out, as What it turns into says, so that a README renders.
markdown line 12: an image's source must be the name or the src of an asset: 'missing.png' is neithermarkdown line 5: the footnote [^2] has no definition; define it with [^2]: and its words, or write \[ to show it as textIn code
Section titled “In code”The builders have a markdown that holds styles and content, and the rules are LMarkdown.h1(), LMarkdown.quote(), LMarkdown.hr() and so on, in the language’s case. A builder has no data binding, so the text is a string the program passes in. In Python the rule of struck-through text is LMarkdown.del_, since del is a keyword; in Java it is LMarkdown.del, as del is no keyword there.
import { L, LMarkdown, NoAttr } from '@lpdfio/lpdf'
const document = L.document(NoAttr, [ L.section(NoAttr, [ L.markdown({ margin: '54pt', gap: 'm' }, [ LMarkdown.styles({ src: 'markdown-styles.xml' }, [LMarkdown.h1({ color: 'primary' })]), LMarkdown.content(NoAttr, [body]), ]), ]),])