1<?php
2/**
3 * Mikio Syntax Plugin: Heading
4 *
5 * @link        http://github.com/nomadjimbob/mikioplugin
6 * @license     GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author      James Collins <james.collins@outlook.com.au>
8 */
9if (!defined('DOKU_INC')) die();
10if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(dirname(__FILE__).'/core.php');
12
13class syntax_plugin_mikioplugin_heading extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'heading';
15    public $hasEndTag           = true;
16    public $options             = array(
17        'color'             => array('type'    => 'color',    'default' => ''),
18        'size'              => array('type'    => 'choice',
19                                     'data'    => array('1', '2', '3', '4', '5', '6'),
20                                     'default' => '1'),
21        'text-decoration'   => array('type'    => 'text',     'default' => '1'),
22    );
23    //
24    public function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
25    public function getPType() { return 'normal'; }
26
27    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
28        $styles = $this->buildStyle(array(
29            'color'             => $data['color'],
30            'text-decoration'   => $data['text-decoration'],
31        ), TRUE);
32
33        $renderer->doc .= '<h' . $data['size'] . ' class="' . $this->elemClass. ' ' . $this->classPrefix . 'heading ' . $this->classPrefix . 'heading-' . $data['size'] . '"' . $styles . '>';
34    }
35
36
37    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
38        $renderer->doc .= '</h' . $data['size'] . '>';
39    }
40}
41
42?>