1<?php 2/** 3 * Bootstrap Wrapper Plugin: Useful Macros 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> 7 * @copyright (C) 2015-2020, Giuseppe Di Terlizzi 8 */ 9 10class syntax_plugin_bootswrapper_macros extends DokuWiki_Syntax_Plugin 11{ 12 13 private $macros = array( 14 '~~CLEARFIX~~', 15 '~~PAGEBREAK~~', 16 ); 17 18 public function getType() 19 { 20 return 'substition'; 21 } 22 23 public function getSort() 24 { 25 return 99; 26 } 27 28 public function getPType() 29 { 30 return 'normal'; 31 } 32 33 public function connectTo($mode) 34 { 35 36 foreach ($this->macros as $macro) { 37 $this->Lexer->addSpecialPattern($macro, $mode, 'plugin_bootswrapper_macros'); 38 } 39 40 } 41 42 public function handle($match, $state, $pos, Doku_Handler $handler) 43 { 44 return array($match, $state, $pos); 45 } 46 47 public function render($mode, Doku_Renderer $renderer, $data) 48 { 49 if (empty($data)) { 50 return false; 51 } 52 53 if ($mode !== 'xhtml') { 54 return false; 55 } 56 57 list($match, $state, $pos) = $data; 58 59 switch ($match) { 60 case '~~CLEARFIX~~': 61 $renderer->doc .= '<span class="clearfix"></span>'; 62 break; 63 case '~~PAGEBREAK~~': 64 $renderer->doc .= '<span class="bs-page-break"></span>'; 65 break; 66 } 67 } 68} 69