1<?php
2/**
3 * Mikio Syntax Plugin: Text
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_text extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'text';
15    public $hasEndTag           = true;
16    public $options             = array(
17        'color'                 => array('type'    => 'color',    'default' => ''),
18        'size'                  => array('type'    => 'size',     'default' => ''),
19        'weight'                => array('type'    => 'choice',
20                                         'data'    => array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900', 'initial', 'inherit'),
21                                         'default' => 'normal'),
22        'style'                 => array('type'    => 'text',     'default' => ''),
23        'background-color'      => array('type'    => 'color',    'default' => ''),
24        'line-height'           => array('type'    => 'float',    'default' => ''),
25        'text-decoration'       => array('type'    => 'text',     'default' => '1'),
26        'block'                 => array('type'    => 'boolean',    'default' => 'false'),
27    );
28
29    public function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
30    public function getPType() { return 'normal'; }
31
32    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
33
34        $styles = $this->buildStyle(array(
35            'color'             => $data['color'],
36            'font-size'         => $data['size'],
37            'font-weight'       => $data['weight'],
38            'font-style'        => $data['style'],
39            'background-color'  => $data['background-color'],
40            'line-height'       => $data['line-height'],
41            'text-decoration'   => $data['text-decoration'],
42            'display'           => ($data['block'] ? 'block' : 'inline-block'),
43        ), TRUE);
44
45        $renderer->doc .= '<span' . $styles . '>';
46    }
47
48
49    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
50        $renderer->doc .= '</span>';
51    }
52}
53
54?>