Skip to content

Markdown Viewer Demo ​

Folder: Demos\MarkdownViewer. Project: MarkdownViewerDemo.dproj.

The folder contains a simple Markdown viewer component, TSynMarkdownViewer (unit SynMarkdownViewer), derived from TSynEdit, and a demo application that shows how it works. It is not a full Markdown viewer, but it can be sufficient in many situations in which using a Markdown processor with an HTML browser would be overkill. It also demonstrates the power of the SynEdit indicators.

Supported syntax ​

  • Headers
  • Horizontal rulers
  • Emphasis tags (bold, italic and bold italic)
  • Links
  • Bullets
  • Code tags (backticks)
  • Paragraph formatting, including the use of <br>

How it works ​

TSynMarkdownViewer has the method SetMarkdown that loads the text, and the event OnCLickLink, fired when the user clicks a link. The formatting is not done by changing the text, but with indicators (TSynIndicatorSpec) drawn over it, one for each element: InlineCode, Heading1, Heading2, Heading3, HeadingOther, Bold, Italic, BoldItalic, Underline and Link. The links are found with regular expressions.

The demo (frmMain) opens a Markdown file (the folder contains readme.md) in the viewer.

TIP

For editing Markdown, the library has also the Markdown highlighter TSynMarkdownSyn.

Released under the MPL 1.1 / GPL 2 dual license.