FilterMarkdown Method  
 

Filters out Markdown text from the input string and returns plain text.

Syntax

PlainText = object.FilterMarkdown( InputText )

Parameters

InputText
A variant type which may specify either a string or byte array. If a string type is passed to this method, the text will be filtered and normalized. If a byte array is passed to this method, it will be processed as UTF-8 encoded characters, with the result returned as a filtered string. No other data types are accepted by this method and an exception will be thrown if an invalid data type is provided as the input text.

Return Value

If the method is successful it returns a string which contains the filtered text. If the method fails, it will return an empty string.

Remarks

The FilterMarkdown method processes a text string containing Markdown formatting and returns a simplified version with the formatting removed. This preserves the readable content while stripping away syntax such as headings, list markers, emphasis markers, links, and other Markdown elements that are intended for display formatting.

The method works by scanning the text from start to finish and applying a set of rules to recognize common Markdown constructs. For example, headings have their leading hash markers are removed, list markers are normalized to a simple dash or number, emphasis markers such as the asterisk and underscore are stripped, and link text is preserved with the URL shown in parentheses. Code blocks and inline code are retained without the backtick markers. Whitespace is also normalized to make the output easier to read.

Filtering can used in situations where you need plain text output from Markdown input, such as displaying content in a non-HTML context, preparing it for indexing, or passing it to other text-based utilities. It works best when you are confident that the input is actually Markdown; using it on arbitrary text may result in loss of characters that were mistaken for formatting.

The filtering is based on a set of common Markdown patterns and does not attempt to fully parse the Markdown specification. As a result, it may not recognize every possible variation of Markdown and there may be some cases where not all of the formatting is removed.

See Also

FilterHtml, FilterUnicode