*/ class renderer_plugin_dbquery extends \Doku_Renderer { protected $codeBlocks = []; protected $lastHeader = ''; /** @inheritDoc */ public function getFormat() { return 'dbquery'; } /** @inheritDoc */ public function header($text, $level, $pos) { $this->lastHeader = $text; } /** @inheritDoc */ public function code($text, $lang = null, $file = null) { if (!isset($this->codeBlocks['_'])) { // first code block is always the SQL query $this->codeBlocks['_'] = trim($text); } else { // all other code blocks are treated as HTML named by their header $this->codeBlocks[$this->lastHeader] = trim($text); } } /** @inheritdoc */ public function document_start() { parent::document_start(); $this->info['dbquery']['transpose'] = false; } /** @inheritDoc */ public function document_end() { $this->doc = json_encode([ 'codeblocks' => $this->codeBlocks, 'macros' => $this->info['dbquery'], ]); } }