public function HashAutolinker::alterGuidelines in Markdown 3.0.x
Alters existing guides on how to use the Markdown Parser.
Parameters
array $guides: The guides array, passed by reference.
Overrides MarkdownGuidelinesAlterInterface::alterGuidelines
File
- src/
Plugin/ Markdown/ Extension/ HashAutolinker.php, line 28
Class
- HashAutolinker
- Plugin annotation @MarkdownExtension( id = "hash_autolinker", label = @Translation("# Autolinker"), installed = TRUE, description = @Translation("Automatically link commonly used references that come after a hash character (#) without having…
Namespace
Drupal\markdown\Plugin\Markdown\ExtensionCode
public function alterGuidelines(array &$guides = []) {
if ($this
->getSetting('type') === 'node') {
$description = [
t('Text that starts with hash symbol (#) followed by numbers will be automatically be linked to a node on this site.'),
];
if ($this
->getSetting('node_title')) {
$description[] = t('The node title will be used in place the text.');
}
$description[] = t('If the node does not exist, it will not automatically link.');
$guides['links']['items'][] = [
'title' => t('# Autolinker'),
'description' => $description,
];
}
elseif ($this
->getSetting('type') === 'url') {
$description = [
t('Text that starts with a hash symbol (#) followed by any character other than a space will automatically be linked to the following URL: <code>@url</code>', [
'@url' => $this
->getSetting('url'),
]),
];
if ($this
->getSetting('url_title')) {
$description[] = t('The URL title will be used in place of the original text.');
}
$guides['links']['items'][] = [
'title' => t('@ Autolinker'),
'description' => $description,
'tags' => [
'a' => [
'#3060',
'#2562913',
'#259843',
],
],
];
}
}