API Documentation

ConvertsMarkdownToPlainText
in package

Converts Markdown to plain text.

Table of Contents

Constants

ATX_HEADERS  = ['/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/m' => '$1$2$3']
BLOCKQUOTES  = ['/^\s{0,3}>\s?/' => '']
CODE_BLOCKS  = ['/(`{3,})(.*?)\1/m' => '$2']
DOUBLE_EMPHASIS  = self::EMPHASIS
Emphasis (repeat the line to remove double emphasis)
EMPHASIS  = ['/([\*_]{1,3})(\S.*?\S{0,1})\1/' => '$2']
FENCED_CODEBLOCKS  = ['/`{3}.*\n/' => '', '/`{3}/' => '']
FOOTNOTES  = ['/\[\^.+?\](\: .*?$)?/' => '']
HORIZONTAL_RULES  = ['/^(-\s*?|\*\s*?|_\s*?){3,}\s*/m' => '']
HTML_TAGS  = ['/<[^>]*>/' => '']
IMAGES  = ['/\!\[(.*?)\][\[\(].*?[\]\)]/' => '$1']
INLINE_CODE  = ['/`(.+?)`/' => '$1']
INLINE_LINKS  = ['/\[(.*?)\][\[\(].*?[\]\)]/' => '$1']
REFERENCE_LINKS  = ['/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/' => '']
REPEATED_NEWLINES  = ['/\n{2,}/' => "\n\n"]
Replace two or more newlines with exactly two
SETEXT_HEADERS  = ['/\n={2,}/' => "\n"]
STRIKETHROUGH  = ['/~~/' => '']
TILDE_FENCED_CODEBLOCKS  = ['/~{3}.*\n/' => '', '/~{3}/' => '']

Properties

$markdown  : string

Methods

__construct()  : mixed
execute()  : string
Regex based on https://github.com/stiang/remove-markdown, licensed under MIT.
applyRegexTransformations()  : string
applyStringTransformations()  : string
removeBlockquotes()  : string
removeTables()  : string
trimWhitespace()  : string

Constants

ATX_HEADERS

protected mixed ATX_HEADERS = ['/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/m' => '$1$2$3']

DOUBLE_EMPHASIS

Emphasis (repeat the line to remove double emphasis)

protected mixed DOUBLE_EMPHASIS = self::EMPHASIS

REPEATED_NEWLINES

Replace two or more newlines with exactly two

protected mixed REPEATED_NEWLINES = ['/\n{2,}/' => "\n\n"]

Properties

Methods

execute()

Regex based on https://github.com/stiang/remove-markdown, licensed under MIT.

public execute() : string
Return values
string

applyRegexTransformations()

protected applyRegexTransformations(string $markdown) : string
Parameters
$markdown : string
Return values
string

applyStringTransformations()

protected applyStringTransformations(string $markdown) : string
Parameters
$markdown : string
Return values
string

removeBlockquotes()

protected removeBlockquotes(string $contents) : string
Parameters
$contents : string
Return values
string

removeTables()

protected removeTables(string $contents) : string
Parameters
$contents : string
Return values
string

trimWhitespace()

protected trimWhitespace(string $contents) : string
Parameters
$contents : string
Return values
string

        
On this page

Search results