summaryrefslogtreecommitdiff
path: root/vendor/league/commonmark/src/Extension/TableOfContents/TableOfContentsPlaceholderParser.php
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2020-06-27 11:39:49 +0100
committerGreg Roach <greg@subaqua.co.uk>2020-06-27 11:39:49 +0100
commitbd0ff478da33656c3ba72eace965e6c0a71a0435 (patch)
tree31568744134c5a7d5835166bab1f640bd24e9651 /vendor/league/commonmark/src/Extension/TableOfContents/TableOfContentsPlaceholderParser.php
parent1b7bacc801fa6671beced176a48a0fb537951f25 (diff)
downloadwebtrees-bd0ff478da33656c3ba72eace965e6c0a71a0435.tar.gz
webtrees-bd0ff478da33656c3ba72eace965e6c0a71a0435.tar.bz2
webtrees-bd0ff478da33656c3ba72eace965e6c0a71a0435.zip
Update vendor dependencies
Diffstat (limited to 'vendor/league/commonmark/src/Extension/TableOfContents/TableOfContentsPlaceholderParser.php')
-rw-r--r--vendor/league/commonmark/src/Extension/TableOfContents/TableOfContentsPlaceholderParser.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/league/commonmark/src/Extension/TableOfContents/TableOfContentsPlaceholderParser.php b/vendor/league/commonmark/src/Extension/TableOfContents/TableOfContentsPlaceholderParser.php
new file mode 100644
index 0000000000..bae6787207
--- /dev/null
+++ b/vendor/league/commonmark/src/Extension/TableOfContents/TableOfContentsPlaceholderParser.php
@@ -0,0 +1,47 @@
+<?php
+
+/*
+ * This file is part of the league/commonmark package.
+ *
+ * (c) Colin O'Dell <colinodell@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace League\CommonMark\Extension\TableOfContents;
+
+use League\CommonMark\Block\Parser\BlockParserInterface;
+use League\CommonMark\ContextInterface;
+use League\CommonMark\Cursor;
+use League\CommonMark\Extension\TableOfContents\Node\TableOfContentsPlaceholder;
+use League\CommonMark\Util\ConfigurationAwareInterface;
+use League\CommonMark\Util\ConfigurationInterface;
+
+final class TableOfContentsPlaceholderParser implements BlockParserInterface, ConfigurationAwareInterface
+{
+ /** @var ConfigurationInterface */
+ private $config;
+
+ public function parse(ContextInterface $context, Cursor $cursor): bool
+ {
+ $placeholder = $this->config->get('table_of_contents/placeholder');
+ if ($placeholder === null) {
+ return false;
+ }
+
+ // The placeholder must be the only thing on the line
+ if ($cursor->match('/^' . \preg_quote($placeholder, '/') . '$/') === null) {
+ return false;
+ }
+
+ $context->addBlock(new TableOfContentsPlaceholder());
+
+ return true;
+ }
+
+ public function setConfiguration(ConfigurationInterface $configuration)
+ {
+ $this->config = $configuration;
+ }
+}