PHP Class League\CommonMark\Util\RegexHelper

Singletons are generally bad, but it allows us to build the regexes once (and only once).
Datei anzeigen Open project: colinodell/commonmark-php Class Usage Examples

Protected Properties

Property Type Description
$instance
$regex

Public Methods

Method Description
getHtmlBlockCloseRegex ( integer $type ) : string | null
getHtmlBlockOpenRegex ( integer $type ) : string | null
getHtmlTagRegex ( ) : string
getInstance ( ) : RegexHelper
getLinkDestinationBracesRegex ( ) : string
getLinkDestinationRegex ( ) : string
getLinkTitleRegex ( ) : string
getPartialRegex ( integer $const ) : string Returns a partial regex
getThematicBreakRegex ( ) : string
isLinkPotentiallyUnsafe ( string $url ) : boolean
matchAll ( string $pattern, string $subject, integer $offset ) : array | null Functional wrapper around preg_match_all
matchAt ( string $regex, string $string, integer $offset ) : integer | null Attempt to match a regex in string s at offset offset
unescape ( string $string ) : string Replace backslash escapes with literal characters

Protected Methods

Method Description
__construct ( ) Constructor
buildRegexPatterns ( ) Builds the regular expressions required to parse Markdown

Method Details

__construct() protected method

Constructor
protected __construct ( )

buildRegexPatterns() protected method

We could hard-code them all as pre-built constants, but that would be more difficult to manage.
protected buildRegexPatterns ( )

getHtmlBlockCloseRegex() public static method

public static getHtmlBlockCloseRegex ( integer $type ) : string | null
$type integer HTML block type
return string | null

getHtmlBlockOpenRegex() public static method

public static getHtmlBlockOpenRegex ( integer $type ) : string | null
$type integer HTML block type
return string | null

getHtmlTagRegex() public method

public getHtmlTagRegex ( ) : string
return string

getInstance() public static method

public static getInstance ( ) : RegexHelper
return RegexHelper

getLinkDestinationBracesRegex() public method

getLinkDestinationRegex() public method

public getLinkDestinationRegex ( ) : string
return string

getLinkTitleRegex() public method

public getLinkTitleRegex ( ) : string
return string

getPartialRegex() public method

It'll need to be wrapped with /.../ before use
public getPartialRegex ( integer $const ) : string
$const integer
return string

getThematicBreakRegex() public method

public getThematicBreakRegex ( ) : string
return string

isLinkPotentiallyUnsafe() public static method

public static isLinkPotentiallyUnsafe ( string $url ) : boolean
$url string
return boolean

matchAll() public static method

Functional wrapper around preg_match_all
public static matchAll ( string $pattern, string $subject, integer $offset ) : array | null
$pattern string
$subject string
$offset integer
return array | null

matchAt() public static method

Attempt to match a regex in string s at offset offset
public static matchAt ( string $regex, string $string, integer $offset ) : integer | null
$regex string
$string string
$offset integer
return integer | null Index of match, or null

unescape() public static method

Replace backslash escapes with literal characters
public static unescape ( string $string ) : string
$string string
return string

Property Details

$instance protected_oe static_oe property

protected static $instance

$regex protected_oe property

protected $regex