TRVMarkdownProperties

Properties

<< Click to display table of contents >>

TRVMarkdownProperties

Properties

This is a type of TRichView.MarkdownProperties. It contains properties for controlling Markdown export and import.

Do not create objects of this class yourself, use this property instead.

Unit RVMarkdown.

Syntax

TRVMarkdownProperties = class (TPersistent)

Properties

For exporting:

ImagesPrefix;

LineWidth;

NotesSavedAsFootnotes;

SaveHiddenText;

SaveOptions.

For importing:

DefaultItemProperties;

LoadOptions.

Common:

Extensions.

About Markdown

Markdown is a lightweight markup language with plain-text-formatting syntax.

TRichView implementation follows CommonMark specification.

TRichView implementation of table extension follows GitHub Flavored Markdown specification.

About Markdown export

TRichView can export to Markdown:

text (with italic and bold attributes)

headings

bullets and numbering

horizontal lines

tables (optionally)

footnotes, endnotes, sidenotes, text boxes (optionally, as footnotes)

pictures

hyperlinks

Headings

Headings are determined by OutlineLevel properties of paragraphs.

Markdown format supports two kinds of headings:

Setext headings (paragraphs underlined with '=' (for heading 1) or '-' (for heading 2) characters)

ATX headings (paragraphs started from '#' characters: '# ' for heading 1, '## ' for heading 2, ..., up to level 6).

When a Markdown file is read, only a heading level matters, Setext and ATX headings are loaded identically.

Setext headings can be multiline and may include hard line breaks but they can represent only headings of level 1 and 2. Note: some Markdown readers do not support multiline Setext headings.

See also rvmdsoUseSetextHeadings option in SaveOptions.

Text attributes

If StyleTemplates are not used, the following rules are applied when exporting text:

for headings, bold and italic attributes are not saved

for normal text, bold and italic attributes are taken from text formatting (Style property)

If StyleTemplates are used, the following rules are applied when exporting text:

if text is formatted using a style template named 'Emphasis', 'Subtle Emphasis', 'Intense Emphasis', it is saved as an emphasis

if text is formatted using a style template named 'Strong', it is saved as a strong emphasis

otherwise, formatting that is applied on top of paragraph style template is used (Style property). For headings, a difference is calculated from 'heading #' style template; for normal text, a difference is calculated from 'Normal' style; for block quotes, a difference is calculated from the style template that is actually used for the text paragraph. For hyperlinks, 'Hyperlink' style template is taken into account as well.

Block quotes

If StyleTemplates are not used, block quotes are not saved.

If StyleTemplates are used, paragraphs formatted using a style template named 'Quote' or 'Intense Quote' are saved as block quotes.

TRichView supports exporting only a single level of block quotes.

See also rvmdsoListInBlockQuote option in SaveOptions.

Tables

The original Markdown format cannot contain tables. However, there is a Markdown extension that supports very simple tables (single-line text content, no cell merging, no nested tables, no additional table properties; content of columns can be left- or right- aligned or centered).

To enable saving tables as tables, include rvmdeTables in Extensions. Otherwise, contents of cells are saved as normal paragraphs.

Notes

The original Markdown format cannot contain notes. However, there is a Markdown extension that supports footnotes.

To enable saving selected notes as footnotes, include rvmdeFootnotes in Extensions, and choose note types in NotesSavedAsFootnotes. Otherwise, contents of notes are saved in place where they are inserted, as text inside [ ].

Encoding

TRichView exports Markdown in UTF-8 encoding.

It you want to convert output to some ANSI encoding, I suggest to change the value of the global typed constant RVMarkdownSmallSpace (defined in RVMarkdownSave unit) to space character ('#32;') or another space character that exists in the target encoding.

  RVMarkdownSmallSpace: TRVUnicodeString = '#8202;'// UNI_HAIR_SPACE

TRichView may insert this code between a punctuation and a letter character to allow making the punctuation bold or italic (because otherwise

About Markdown import

TRichView can import from Markdown:

text (with emphasis and strong emphasis, code spans)

headings

multilevel block quotes

code blocks

bullets and numbering

horizontal lines

tables (optionally)

pictures

hyperlinks

StyleTemplates

If StyleTemplates are used, imported text and paragraph attributes depend on them.

StyleTemplates of the following names are used, if exist:

'Normal' (normal paragraphs)

'heading 1' ... 'heading 2' (heading paragraphs)

'Quote' or 'Intense Quote' (block quote paragraphs)

'HTML Preformatted' (code block paragraphs)

'HTML Code' (text in code blocks and code spans)

'Emphasis' (emphasis)

'Strong' (strong emphasis and text in table heading row)

'Hyperlink' (hyperlinks)

If style templates are not used, or the corresponding style template is missing, TRichView uses defaults.

Headings

Headings are imported as paragraphs having positive values of OutlineLevel.

If StyleTemplates are used, 'heading 1' ... 'heading 2' StyleTemplates are applied to heading paragraphs.

If StyleTemplates are not used (or the corresponding StyleTemplate does not exist), TRichView uses defaults for text attributes (you can modify them in the global singleton object RVDefaultLoadProperties from RVDefReadProps unit: DefaultProperties[] property).

Block quotes

All content of block quotes is imported as indented paragraphs.

While the export understands only a single block quote level, the import uses indents to display multilevel lists and block quotes.

If StyleTemplates are used, 'Quote' or 'Intense Quote' StyleTemplates are applied to paragraphs. Nested quotes are additionally indented by the left indent specified in the used style template.

If StyleTemplates are not used, these paragraphs are indented by DefaultItemProperties.ListMarkerIndentPix and colored by DefaultItemProperties.BlockQuoteBackColor.

Code blocks

All content of code blocks are imported as paragraphs.

The current version of TRichView cannot export code blocks, it can only import them.

If StyleTemplates are used, 'HTML Preformatted' StyleTemplates is applied to paragraphs, 'HTML Code' StyleTemplate is applied to text.

If StyleTemplates are not used, these paragraphs are colored by DefaultItemProperties.CodeBlockBackColor, and text is formatted using 'Courier New' font (you can assign another font name in the global singleton object RVDefaultLoadProperties from RVDefReadProps unit: DefaultMonoSpacedFontName property).

Text attributes

If StyleTemplates are not used, the following rules are applied when importing text:

emphasis is imported as italic text

strong emphasis is imported as bold text

code spans are formatted using 'Courier New' font (you can assign another font name in the global singleton object RVDefaultLoadProperties from RVDefReadProps unit: DefaultMonoSpacedFontName property)

hyperlinks are blue and underlined (you can modify link appearance in the global singleton object RVDefaultLoadProperties from RVDefReadProps unit: DefaultProperties[rvftHyperlink] property).

If StyleTemplates are used, the following rules are applied when exporting text:

emphasis is formatted using 'Emphasis' StyleTemplate

strong emphasis is formatted using Strong' StyleTemplate

code spans are formatted using 'HTML Code' StyleTemplate

hyperlinks are formatted using 'Hyperlink' StyleTemplate.

Since only one StyleTemplate can be applied to text, for text having multiple attributes (such as code spans inside emphasis), only the main StyleTemplate is applied, other attributes are applied as if StyleTemplates are not used. The following priorities of StyleTemplates are used (from highest to lowest): 'Hyperlink', 'HTML Code', 'Strong', 'Emphasis'.

The current version of TRichView cannot export code spans, it can only import them.

Lists

List levels are indented according to DefaultItemProperties.ListMarkerIndentPix and ListLeftIndentPix properties.

For complex nested list, you can choose either keeping level nesting (include rvmdloEnforceListLevels in LoadOptions) or list type (exclude rvmdloEnforceListLevels from LoadOptions).

Tables

To enable table loading, include rvmdeTables in Extensions.

The first row is imported as a header row. Text in this row is formatted as if it has a strong emphasis.

Table cells have widths specified in DefaultItemProperties.TableCellWidthPix.