MarkdownToHTML

Text, Markdown, HTML text

Description

Converts Markdown into the HTML subset accepted by the built-in layout and drawing methods

Syntax

Delphi

Function TPDFlib.MarkdownToHTML(Const Markdown: WideString): WideString;

ActiveX

Function PDFlib::MarkdownToHTML(Markdown As String) As String

DLL

const wchar_t* DLMarkdownToHTML(int InstanceID, const wchar_t* Markdown);
const char* DLMarkdownToHTMLA(int InstanceID, const char* Markdown);

Parameters

MarkdownSource text using the supported Markdown syntax

Return values

Returns HTML containing headings, paragraphs, lists, quotations, tables, code, links, images, and inline emphasis

Remarks

Backslash line endings and two trailing spaces produce hard line breaks, ordered lists retain their first number, and a leading tab introduces an indented code block

Link labels may contain balanced square brackets, destinations may contain balanced parentheses or use angle brackets, and common email autolinks become mailto: links

Inline code closes only at a backtick run of the opening length, including inside table cells; pipes inside such code spans remain cell text. Reference labels match after whitespace is collapsed and case is ignored

Raw angle brackets are escaped as text, so source content does not inject arbitrary HTML

Use SetHTMLImage to bind image destinations before drawing the converted result

The DLL DLMarkdownToHTMLA variant accepts and returns text according to the configured ANSI mode

Code spans and fenced or indented code blocks escape ampersands and angle brackets, preserving literal entity spellings such as < when rendered

Rich Markdown syntax

Inline character references decode common named HTML entities and decimal or hexadecimal Unicode references once; code spans keep their literal entity spellings

Triple emphasis combines bold and italic, delimiter boundaries keep identifiers such as snake_case literal, and link captions cannot create nested hyperlinks

Links and images support quoted titles, including reference definitions; link destinations and titles decode entities before attribute escaping

Code spans may continue across paragraph lines, with each internal line ending normalized to a space; fenced code records a safe language identifier in its language-* class

Indented list continuations remain in their list item, nested lists remain within their parent item, task items display checked or unchecked boxes, and unmarked quote continuation lines remain within the current quoted paragraph

Footnote references link to unique note anchors, and each note supplies return links for all references

The unit-level PDFlibMarkdownToHTML function accepts an optional integer options argument; set PDFLIB_MARKDOWN_AUTOLINK_BARE_URLS to link bare HTTP and HTTPS URLs while excluding terminal sentence punctuation and code spans; the default is zero and keeps bare URLs as text