A lightweight, fast, native VCL component for Delphi (from Delphi 7 up to Delphi 13) designed to render Markdown documents without relying on heavy external browser engines (such as WebView2 or CEF).
Built on top of the modernized native TRichView core and sgmVersions.
- Headings & Checkpoints (Slugs): Supports heading levels
#-######with automatic checkpoint generation for internal anchor navigation. - Inline Formatting: Bold, italic, bold italic, strikethrough, inline code, and proper handling of backslash-escaped characters (
\). - Links & Callbacks: Supports named links (
[text](url)), auto-links (URLs), internal#anchorlinks, and theOnLinkClickevent to intercept navigation. - Lists: Ordered (
1.) and unordered (-,*,+) lists with multi-level nesting support. - GFM Tables: Supports GitHub Flavored Markdown tables (
| col1 | col2 |) with column alignment (:---,:---:,---:), inline cell styling, selection/clipboard copy, and HTML table export. - Block Elements & Images: Blockquotes (
>), horizontal rules (---,***), fenced code blocks preserving original formatting and indentation, and local image rendering (including JPEG support in Delphi 7). - Paragraphs, Streams & HTML Export: Smart paragraph line joining, direct loading from files or
UTF-8streams (LoadFromStream), and built-in export to HTML (SaveHTML). - Wide Compatibility & x86/x64 Support: Compatible with legacy Delphi 7 (Win32) as well as modern Unicode Delphi versions (Win32 & Win64).
- TRichView Modernized Core - Single-unit native VCL rendering, table, and printing engine used as the foundation for
TMarkdownView. - MarkdownView TC Plugin - Fast native Lister plugin (
wlx/wlx64) for Total Commander (F3/Ctrl+Q) powered byTMarkdownView. - sgmVersions - Cross-version compiler directives include file (
Delphi 2-Delphi 13).
src/- Core source files forTMarkdownView.pkg/- Component packages for different IDE versions (MarkdownView_D7,MarkdownView_D13, etc.).demo/(MarkdownViewDemo.dpr/.dproj) - Sample application showcasing live Markdown rendering, link navigation, and HTML export.test/(MarkdownViewTests.dpr) - DUnit test suite (test\dunit) covering the parser and rendering logic.bin/&dcu/- Output directories for compiled binaries (bin\,bin\x64\) and intermediate units (d7,d13\x86,d13\x64).
- Ensure TRichView and sgmVersions are added to your Delphi Search Path.
- Open the project group
pgMain.groupprojor select the package matching your IDE version inside thepkg/folder (e.g.,MarkdownView_D7.dpkfor Delphi 7 orMarkdownView_D13.dprojfor Delphi 13). - Right-click the package in the Project Manager and choose Compile, then Install.
- Drop
TMarkdownViewonto your VCL form from the Tool Palette (make sure thesrc/path is added to your Delphi Library Path if you want to use it across projects).
uses
MarkdownView;
procedure TForm1.LoadDocument;
var
LStream: TFileStream;
begin
// Load directly from a file
MarkdownView1.LoadFromFile('README.md');
// Or load from a UTF-8 stream
LStream := TFileStream.Create('README.md', fmOpenRead or fmShareDenyWrite);
try
MarkdownView1.LoadFromStream(LStream);
finally
LStream.Free;
end;
// Or assign Markdown text / TStrings directly
// MarkdownView1.MarkdownText := '# Hello, World!' + sLineBreak + 'Text with **bold** styling.';
// MarkdownView1.MarkdownLines := Memo1.Lines;
end;procedure TForm1.MarkdownView1LinkClick(Sender: TObject; const URL: string);
begin
// Handle internal anchor links (#section) or open external URLs in the browser
ShellExecute(Handle, 'open', PChar(URL), nil, nil, SW_SHOWNORMAL);
end;The project includes a DUnit test suite located in test/ (MarkdownViewTests.dpr). To run the tests, open pgMain.groupproj, activate MarkdownViewTests, build, and run the compiled executable from bin\ (Win32) or bin\x64\ (Win64).
Distributed under the MIT License. See LICENSE for more information.
