You are here

public function BaseParser::parsePath in Markdown 3.0.x

Parses markdown from a local file into HTML.

Parameters

string $path: A filesystem path of a markdown file to parse.

\Drupal\Core\Language\LanguageInterface $language: Optional. The language of the markdown that is being parsed.

Return value

\Drupal\markdown\ParsedMarkdownInterface A ParsedMarkdownInterface object.

Throws

\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException When the provided $path does not exist in the local file system.

Overrides MarkdownParserInterface::parsePath

File

src/Plugin/Markdown/BaseParser.php, line 416

Class

BaseParser
Plugin annotation @MarkdownParser( id = "_broken", label = @Translation("Missing Parser"), )

Namespace

Drupal\markdown\Plugin\Markdown

Code

public function parsePath($path, LanguageInterface $language = NULL) {
  if (!file_exists($path)) {
    throw new FileNotFoundException((string) $path);
  }
  return $this
    ->parse(file_get_contents($path) ?: '', $language);
}