1<?php 2 3/** 4 * Description plugin. 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Matthias Schulte <dokuwiki@lupo49.de> 8 * @author Mark C. Prins <mprins@users.sf.net> 9 * 10 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps 11 * @noinspection AutoloadingIssuesInspection 12 */ 13 14use dokuwiki\Extension\SyntaxPlugin; 15 16class syntax_plugin_description extends SyntaxPlugin 17{ 18 final public function getType(): string 19 { 20 return 'substition'; 21 } 22 23 final public function getPType(): string 24 { 25 return 'block'; 26 } 27 28 final public function getSort(): int 29 { 30 return 98; 31 } 32 33 final public function connectTo($mode): void 34 { 35 $this->Lexer->addSpecialPattern('\{\{description>.+?\}\}', $mode, 'plugin_description'); 36 } 37 38 final public function handle($match, $state, $pos, Doku_Handler $handler): array 39 { 40 $match = substr($match, 14, -2); // strip markup 41 $match = hsc($match); 42 43 return [$match]; 44 } 45 46 final public function render($format, Doku_Renderer $renderer, $data): bool 47 { 48 $description = $data[0]; 49 if (empty($description)) { 50 return false; 51 } 52 53 if ($format === 'metadata') { 54 $renderer->meta['plugin_description']['keywords'] = $description; 55 return true; 56 } 57 return false; 58 } 59} 60