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