class Parsedown in Markdown 3.0.x
Plugin annotation
@MarkdownParser(
id = "erusev/parsedown",
label = @Translation("Parsedown"),
url = "https://parsedown.org",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\markdown\Plugin\Markdown\BaseParser implements MarkdownGuidelinesInterface, MarkdownParserInterface
- class \Drupal\markdown\Plugin\Markdown\Parsedown implements MarkdownParserBenchmarkInterface uses MarkdownParserBenchmarkTrait
- class \Drupal\markdown\Plugin\Markdown\BaseParser implements MarkdownGuidelinesInterface, MarkdownParserInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of Parsedown
File
- src/
Plugin/ Markdown/ Parsedown.php, line 15
Namespace
Drupal\markdown\Plugin\MarkdownView source
class Parsedown extends BaseParser implements MarkdownParserBenchmarkInterface {
use MarkdownParserBenchmarkTrait;
/**
* The parser class.
*
* @var string
*/
protected static $parserClass = '\\Parsedown';
/**
* MarkdownExtra parsers, keyed by filter identifier.
*
* @var \Parsedown[]
*/
protected static $parsers = [];
/**
* {@inheritdoc}
*/
public static function installed() : bool {
return class_exists(static::$parserClass);
}
/**
* {@inheritdoc}
*/
public static function version() : string {
if (static::installed()) {
$class = static::$parserClass;
return $class::version;
}
}
/**
* {@inheritdoc}
*/
public function convertToHtml($markdown, LanguageInterface $language = NULL) {
return $this
->getParser()
->text($markdown);
}
/**
* Retrieves the PHP Markdown parser.
*
* @return \Parsedown
* A PHP Markdown parser.
*/
public function getParser() {
if (!isset(static::$parsers[$this->filterId])) {
$parser = new static::$parserClass();
if ($this->filter) {
foreach ($this->settings as $name => $value) {
if ($method = $this
->getSettingMethod($name)) {
$parser
->{$method}($value);
}
}
}
static::$parsers[$this->filterId] = $parser;
}
return static::$parsers[$this->filterId];
}
/**
* Retrieves the method used to configure a specific setting.
*
* @param string $name
* The name of the setting.
*
* @return string|null
* The method name or NULL if method does not exist.
*/
protected function getSettingMethod($name) {
$map = static::settingMethodMap();
return isset($map[$name]) ? $map[$name] : NULL;
}
/**
* A map of setting <-> method.
*
* @return array
*/
protected static function settingMethodMap() {
return [
'breaks_enabled' => 'setBreaksEnabled',
'markup_escaped' => 'setMarkupEscaped',
'safe_mode' => 'setSafeMode',
'strict_mode' => 'setStrictMode',
'urls_linked' => 'setUrlsLinked',
];
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseParser:: |
protected | property | The allowed HTML tags, if set. | |
BaseParser:: |
protected static | property | MarkdownExtension plugins specific to a parser. | 1 |
BaseParser:: |
protected | property | The current filter being used. | |
BaseParser:: |
protected | property | The filter identifier. | |
BaseParser:: |
protected | property | The parser settings. | |
BaseParser:: |
public | function |
Retrieves allowed HTML tags, if set. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Retrieves the description of the plugin, if set. Overrides MarkdownInstallablePluginInterface:: |
|
BaseParser:: |
public | function |
Retrieves the markdown filter plugin, if set. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Retrieves a filter format entity. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Builds a guide on how to use the Markdown Parser. Overrides MarkdownGuidelinesInterface:: |
1 |
BaseParser:: |
public | function |
Displays the human-readable label of the plugin. Overrides MarkdownInstallablePluginInterface:: |
|
BaseParser:: |
public | function |
Retrieves a short summary of what the MarkdownParser does. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Retrieves the URL for the parser, if any. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
The current version of the parser. Overrides MarkdownInstallablePluginInterface:: |
|
BaseParser:: |
public | function |
Indicates whether the parser is installed. Overrides MarkdownInstallablePluginInterface:: |
|
BaseParser:: |
public | function |
Loads a cached ParsedMarkdown object. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Loads a cached ParsedMarkdown object for a local file system path. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Loads a cached ParsedMarkdown object for a URL. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Parses markdown from a local file into HTML. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Parses markdown from an external URL into HTML. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Sets the allowed HTML tags. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Generates a filter's tip. Overrides MarkdownParserInterface:: |
|
BaseParser:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
MarkdownParserBenchmarkTrait:: |
protected static | property | Flag indicating whether this is currently in the process of a benchmark. | |
MarkdownParserBenchmarkTrait:: |
public | function | ||
MarkdownParserBenchmarkTrait:: |
public | function | ||
MarkdownParserBenchmarkTrait:: |
public | function | ||
MarkdownParserBenchmarkTrait:: |
public | function | ||
MarkdownParserBenchmarkTrait:: |
public | function | ||
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
Parsedown:: |
protected static | property | The parser class. | 1 |
Parsedown:: |
protected static | property | MarkdownExtra parsers, keyed by filter identifier. | |
Parsedown:: |
public | function |
Converts Markdown into HTML. Overrides BaseParser:: |
|
Parsedown:: |
public | function | Retrieves the PHP Markdown parser. | |
Parsedown:: |
protected | function | Retrieves the method used to configure a specific setting. | |
Parsedown:: |
public static | function |
Indicates whether the parser is installed. Overrides BaseParser:: |
|
Parsedown:: |
protected static | function | A map of setting <-> method. | |
Parsedown:: |
public static | function |
Retrieves the version of the installed parser. Overrides BaseParser:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |