You are here

public static function BlazyMarkdown::parse in Blazy 8.2

Processes Markdown text, and convert into HTML suitable for the help text.

Parameters

string $string: The string to apply the Markdown filter to.

bool $sanitize: True, if the string should be sanitized.

Return value

string The filtered, or raw converted string.

1 call to BlazyMarkdown::parse()
blazy_parse_markdown in ./blazy.module
Provides a shortcut to parse the markdown string for better hook_help().

File

src/Utility/BlazyMarkdown.php, line 32

Class

BlazyMarkdown
Provides markdown utilities only useful for the help text.

Namespace

Drupal\blazy\Utility

Code

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;
}