class BlazyMarkdown in Blazy 8.2
Provides markdown utilities only useful for the help text.
Hierarchy
- class \Drupal\blazy\Utility\BlazyMarkdown
Expanded class hierarchy of BlazyMarkdown
1 file declares its use of BlazyMarkdown
- blazy.module in ./
blazy.module - Provides basic Blazy integration for lazy loading and multi-serving images.
File
- src/
Utility/ BlazyMarkdown.php, line 12
Namespace
Drupal\blazy\UtilityView source
class BlazyMarkdown {
/**
* Checks if we have the needed classes.
*/
public static function isApplicable() {
return class_exists('Michelf\\MarkdownExtra') || class_exists('League\\CommonMark\\CommonMarkConverter');
}
/**
* Processes Markdown text, and convert into HTML suitable for the help text.
*
* @param string $string
* The string to apply the Markdown filter to.
* @param bool $sanitize
* True, if the string should be sanitized.
*
* @return string
* The filtered, or raw converted string.
*/
public static function parse($string = '', $sanitize = TRUE) {
if (!self::isApplicable()) {
return '<pre>' . $string . '</pre>';
}
if (class_exists('Michelf\\MarkdownExtra')) {
$string = MarkdownExtra::defaultTransform($string);
}
elseif (class_exists('League\\CommonMark\\CommonMarkConverter')) {
$converter = new CommonMarkConverter();
$string = $converter
->convertToHtml($string);
}
// We do not pass it to FilterProcessResult, as this is meant simple.
return $sanitize ? Xss::filterAdmin($string) : $string;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlazyMarkdown:: |
public static | function | Checks if we have the needed classes. | |
BlazyMarkdown:: |
public static | function | Processes Markdown text, and convert into HTML suitable for the help text. |