1<?php 2 3if(!defined('DOKU_INC')) die(); 4if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 5 6require_once DOKU_INC . 'inc/parser/xhtml.php'; 7 8/** 9 * The Renderer 10 */ 11class renderer_plugin_html5 extends Doku_Renderer_xhtml 12{ 13 /** 14 * Get the informations about the plugin 15 * 16 * @return The informations 17 */ 18 function getInfo() 19 { 20 return array( 21 'author' => 'neolao', 22 'email' => 'neo@neolao.com', 23 'date' => '2010-01-09', 24 'name' => 'HTML5', 25 'desc' => 'Plugin to add HTML5 Renderer.', 26 'url' => '', 27 ); 28 } 29 30 /** 31 * Get the format name 32 * 33 * @return The format name 34 */ 35 function getFormat() 36 { 37 return 'html5'; 38 } 39 40 /** 41 * Indicate that the plugin can render the specified format 42 * 43 * @param string $format The format 44 * @return bool true if the plugin can render the format, false otherwise 45 */ 46 function canRender( $format ) 47 { 48 return ( $format == 'xhtml' ); 49 } 50 51 /** 52 * 53 */ 54 function document_end() 55 { 56 // Close section 57 if( $this->lastlevel > 1 ) 58 { 59 $this->doc .= str_repeat( DOKU_LF.'</section>' , $this->lastlevel -1 ); 60 } 61 62 parent::document_end(); 63 } 64 65 66 /** 67 * Print a header 68 * 69 * @param string $text The header content 70 * @param int $level The header level 71 * @param ??? $pos ??? 72 */ 73 function header( $text, $level, $pos ) 74 { 75 if( !$text ) return; //skip empty headlines 76 77 $hid = $this->_headerToLink( $text, true ); 78 79 // Only add items within configured levels 80 $this->toc_additem( $hid, $text, $level ); 81 82 // Adjust $node to reflect hierarchy of levels 83 $this->node[$level-1]++; 84 if ($level < $this->lastlevel) { 85 for ($i = 0; $i < $this->lastlevel-$level; $i++) { 86 $this->node[$this->lastlevel-$i-1] = 0; 87 } 88 } 89 $lastLevel = $this->lastlevel; 90 $this->lastlevel = $level; 91 92 // Close section 93 if( $lastLevel >= $level ) 94 { 95 $this->doc .= str_repeat( DOKU_LF.'</section>' , $lastLevel - $level + 1 ); 96 } 97 98 // Open section 99 if( $level > 1 ) 100 { 101 $this->doc .= DOKU_LF.'<section>'; 102 } 103 104 // Write the header 105 $this->doc .= DOKU_LF.'<h1><a name="'.$hid.'" id="'.$hid.'">'; 106 $this->doc .= $this->_xmlEntities( $text ); 107 $this->doc .= '</a></h1>'.DOKU_LF; 108 } 109 110 /** 111 * Section edit marker is replaced by an edit button when 112 * the page is editable. Replacement done in 'inc/html.php#html_secedit' 113 */ 114 function section_edit( $start, $end, $level, $name ) 115 { 116 } 117 118 /** 119 * Open a section 120 * 121 * @param int $level The section level 122 */ 123 function section_open( $level ) 124 { 125 } 126 127 /** 128 * Close a section 129 */ 130 function section_close() 131 { 132 } 133 134 /** 135 *Open list content 136 */ 137 function listcontent_open() { 138 } 139 140 /** 141 * Close list content 142 */ 143 function listcontent_close() { 144 } 145 146 147 /** 148 * Add a smiley 149 */ 150 function smiley($smiley) { 151 if ( array_key_exists($smiley, $this->smileys) ) { 152 $title = $this->_xmlEntities($this->smileys[$smiley]); 153 $this->doc .= '<img src="'.DOKU_BASE.'lib/images/smileys/'.$this->smileys[$smiley]. 154 '" class="smiley" alt="'. 155 $this->_xmlEntities($smiley).'" />'; 156 } else { 157 $this->doc .= $this->_xmlEntities($smiley); 158 } 159 } 160 161 162 163} 164