1<?php 2/** 3 * DokuWiki Plugin Typography; Syntax typography smallcaps 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Satoshi Sahara <sahara.satoshi@gmail.com> 7 * 8 */ 9 10require_once(dirname(__FILE__).'/base.php'); 11 12class syntax_plugin_typography_smallcaps extends syntax_plugin_typography_base 13{ 14 /** 15 * Connect pattern to lexer 16 */ 17 public function preConnect() 18 { 19 // drop 'syntax_' from class name 20 $this->mode = substr(get_class($this), 7); 21 22 // syntax pattern 23 $this->pattern[1] = '<smallcaps\b.*?>(?=.*?</smallcaps>)'; 24 $this->pattern[4] = '</smallcaps>'; 25 } 26 27 //protected $styler = null; 28 29 /* 30 * Handle the match 31 */ 32 public function handle($match, $state, $pos, Doku_Handler $handler) 33 { 34 switch($state) { 35 case DOKU_LEXER_ENTER: 36 // load prameter parser utility 37 if (is_null($this->styler)) { 38 $this->styler = $this->loadHelper('typography_parser'); 39 } 40 41 // get inline CSS parameter 42 $params = 'fv:small-caps;'.strtolower(ltrim(substr($match, 10, -1))); 43 44 // get css property:value pairs as an associative array 45 $tag_data = $this->styler->parse_inlineCSS($params); 46 47 return $data = array($state, $tag_data); 48 49 case DOKU_LEXER_UNMATCHED: 50 $handler->base($match, $state, $pos); 51 return false; 52 53 case DOKU_LEXER_EXIT: 54 return $data = array($state, ''); 55 } 56 return array(); 57 } 58 59} 60