1<?php 2 3declare(strict_types=1); 4 5if (!defined('DOKU_INC')) die(); 6 7class renderer_plugin_mermaid extends Doku_Renderer_xhtml 8{ 9 private function formattedXhtml(string $xhtml): string 10 { 11 return str_replace(['"'], ['\''], htmlentities($xhtml, ENT_NOQUOTES)); 12 } 13 14 public function underline_open() 15 { 16 $this->doc .= $this->FormattedXhtml('<em class="u">'); 17 } 18 19 public function underline_close() 20 { 21 $this->doc .= $this->FormattedXhtml('</em>'); 22 } 23 24 public function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') 25 { 26 $xhtml = $this->formattedXhtml(parent::internallink($id, $name, $search, true, $linktype)); 27 28 if ($returnonly) { 29 return $xhtml; 30 } 31 32 $this->doc .= $xhtml; 33 } 34 35 public function externallink($url, $name = null, $returnonly = false) 36 { 37 $xhtml = $this->formattedXhtml(parent::externallink($url, $name, true)); 38 39 if ($returnonly) { 40 return $xhtml; 41 } 42 43 $this->doc .= $xhtml; 44 } 45 46 public function internalmedia($src, $title = null, $align = null, $width = null, $height = null, $cache = null, $linking = null, $return = false) 47 { 48 $xhtml = $this->formattedXhtml(parent::internalmedia($src, $title, $align, $width, $height, $cache, $linking, true)); 49 50 if ($return) { 51 return $xhtml; 52 } 53 54 $this->doc .= $xhtml; 55 } 56 57 public function cdata($text) 58 { 59 $this->doc .= $text; 60 } 61 62 public function p_open() {} 63 64 public function p_close() {} 65}