You are here

public function ReadmeHelpMarkdownConverter::convertMarkdownText in README Help 8

Converts markdown to markup.

Parameters

string $text: The text string to be filtered.

string $language: The language code to use for filtering.

string $file_path: The path to a module's directory. Example: modules/contrib/my_module.

Return value

string The text with HTML markup.

See also

\Drupal\readmehelp\Plugin\Filter\ReadmehelpMarkdown

\Drupal\filter\Plugin\Filter\FilterAutoP

\Drupal\filter\Plugin\Filter\FilterUrl

\Drupal\Component\Utility\Html::normalize()

\Drupal\Component\Utility\Xss::filter()

1 call to ReadmeHelpMarkdownConverter::convertMarkdownText()
ReadmeHelpMarkdownConverter::convertMarkdownFile in src/ReadmeHelpMarkdownConverter.php
Converts markdown into HTML markup in a file.

File

src/ReadmeHelpMarkdownConverter.php, line 197

Class

ReadmeHelpMarkdownConverter
Default implementation of the ReadmeHelpMarkdownConverter.

Namespace

Drupal\readmehelp

Code

public function convertMarkdownText($text, $language = 'en', $file_path = NULL) {
  $text = $this->filterManager
    ->createInstance('readmehelp_markdown')
    ->process($text, $language, $file_path)
    ->getProcessedText();
  $text = $this->filterManager
    ->createInstance('filter_autop')
    ->process($text, $language)
    ->getProcessedText();
  $filter_url = $this->filterManager
    ->createInstance('filter_url');
  $text = $filter_url
    ->setConfiguration($filter_url
    ->defaultConfiguration())
    ->process($text, $language)
    ->getProcessedText();

  // Does the same as the filter_htmlcorrector.
  $text = Html::normalize($text);
  $text = $text ? Xss::filter($this
    ->t($text), $this->tags) : '';
  return $text;
}