'', 'CODE' => [ 'attributes' => [ 'lang' => [ 'filterChain' => ['#simpletext'], 'required' => false ] ], 'template' => '
					
						
							
								language-
								
							
						
						
					
				
' ], 'DEL' => '', 'EM' => '', 'EMAIL' => [ 'attributes' => ['email' => ['filterChain' => ['#email']]], 'template' => '' ], 'H1' => '

', 'H2' => '

', 'H3' => '

', 'H4' => '

', 'H5' => '
', 'H6' => '
', 'HR' => '
', 'IMG' => [ 'attributes' => [ 'alt' => ['required' => false ], 'src' => ['filterChain' => ['#url']], 'title' => ['required' => false ] ], 'template' => '' ], 'ISPOILER' => '', 'LI' => '
  • ', 'LIST' => [ 'attributes' => [ 'start' => [ 'filterChain' => ['#uint'], 'required' => false ], 'type' => [ 'filterChain' => ['#simpletext'], 'required' => false ] ], 'template' => '
    ' ], 'QUOTE' => '
    ', 'SPOILER' => '
    ', 'STRONG' => '', 'SUB' => '', 'SUP' => '', 'URL' => [ 'attributes' => [ 'title' => ['required' => false ], 'url' => ['filterChain' => ['#url']] ], 'template' => '' ] ]; /** * {@inheritdoc} */ protected function setUp() { $this->configurator->rulesGenerator->append('ManageParagraphs'); foreach ($this->tags as $tagName => $tagConfig) { // Skip this tag if it already exists if (isset($this->configurator->tags[$tagName])) { continue; } // If the tag's config is a single string, it's really its default template if (is_string($tagConfig)) { $tagConfig = ['template' => $tagConfig]; } // Add this tag $this->configurator->tags->add($tagName, $tagConfig); } } /** * Add an "id" attribute to headers * * @param string $prefix Prefix used for the "id" value * @return void */ public function addHeadersId(string $prefix = ''): void { for ($i = 1; $i <= 6; ++$i) { $tagName = 'H' . $i; if (isset($this->configurator->tags[$tagName])) { $this->addHeaderId($this->configurator->tags[$tagName], $prefix); } } } /** * Add an "id" attribute to given tag * * @param Tag $tag * @param string $prefix Prefix used for the "id" value * @return void */ protected function addHeaderId(Tag $tag, string $prefix): void { if (!isset($tag->attributes['slug'])) { unset($tag->attributes['slug']); } $tag->attributes->add('slug')->required = false; $tag->filterChain ->append(Slugger::class . '::setTagSlug($tag, $innerText)') ->setJS(Slugger::getJS()); $dom = $tag->template->asDOM(); foreach ($dom->query('//xsl:if[@test = "@slug"]') as $if) { // Remove any pre-existing xsl:if from previous invocations $if->remove(); } foreach ($dom->query('//h1 | //h2 | //h3 | //h4 | //h5 | //h6') as $header) { $header->prependXslIf('@slug') ->appendXslAttribute('id', $prefix) ->appendXslValueOf('@slug'); } $dom->saveChanges(); } /** * {@inheritdoc} */ public function asConfig() { return ['decodeHtmlEntities' => (bool) $this->decodeHtmlEntities]; } /** * {@inheritdoc} */ public function getJSHints() { return ['LITEDOWN_DECODE_HTML_ENTITIES' => (int) $this->decodeHtmlEntities]; } /** * {@inheritdoc} */ public function getJSParser() { $js = file_get_contents(__DIR__ . '/Parser/ParsedText.js') . "\n" . file_get_contents(__DIR__ . '/Parser/Passes/AbstractInlineMarkup.js') . "\n" . file_get_contents(__DIR__ . '/Parser/Passes/AbstractScript.js') . "\n" . file_get_contents(__DIR__ . '/Parser/LinkAttributesSetter.js'); $passes = [ 'Blocks', 'LinkReferences', 'InlineCode', 'Images', 'InlineSpoiler', 'Links', 'Strikethrough', 'Subscript', 'Superscript', 'Emphasis', 'ForcedLineBreaks' ]; foreach ($passes as $pass) { $js .= "\n(function(){\n" . file_get_contents(__DIR__ . '/Parser/Passes/' . $pass . '.js') . "\n" . "parse();\n" . "})();"; } return $js; } }