1<?php 2 3/* 4 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps 5 * @noinspection AutoloadingIssuesInspection 6 */ 7 8/** 9 * Description plugin. 10 * 11 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 12 * @author Matthias Schulte <dokuwiki@lupo49.de> 13 * @author Mark C. Prins <mprins@users.sf.net> 14 * 15 */ 16 17use dokuwiki\Extension\SyntaxPlugin; 18 19class syntax_plugin_description extends SyntaxPlugin 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 [$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