Completed
Push — master ( 9ad54b...895d73 )
by Federico
03:21
created
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Nodes/Literal.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@
 block discarded – undo
4 4
 
5 5
 class Literal extends Node
6 6
 {
7
-    public $string;
7
+	public $string;
8 8
 
9
-    public function __construct($string)
10
-    {
11
-        // escape the chars '\', '\n', '\r\n' and "'"
12
-        $this->string = preg_replace(array('/\\\\/', '/\\n|\\r\\n/', '/\'/'), array('\\\\', "\r", "\\'"), $string);
13
-    }
9
+	public function __construct($string)
10
+	{
11
+		// escape the chars '\', '\n', '\r\n' and "'"
12
+		$this->string = preg_replace(array('/\\\\/', '/\\n|\\r\\n/', '/\'/'), array('\\\\', "\r", "\\'"), $string);
13
+	}
14 14
 }
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Nodes/Mixin.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@
 block discarded – undo
4 4
 
5 5
 class Mixin extends Attributes
6 6
 {
7
-    public $name;
8
-    public $arguments;
9
-    public $block;
10
-    public $attributes;
11
-    public $call;
7
+	public $name;
8
+	public $arguments;
9
+	public $block;
10
+	public $attributes;
11
+	public $call;
12 12
 
13
-    public function __construct($name, $arguments, $block, $call)
14
-    {
15
-        $this->name = $name;
16
-        $this->arguments = $arguments;
17
-        $this->block = $block;
18
-        $this->attributes = array();
19
-        $this->call = $call;
20
-    }
13
+	public function __construct($name, $arguments, $block, $call)
14
+	{
15
+		$this->name = $name;
16
+		$this->arguments = $arguments;
17
+		$this->block = $block;
18
+		$this->attributes = array();
19
+		$this->call = $call;
20
+	}
21 21
 }
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Nodes/Code.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@
 block discarded – undo
4 4
 
5 5
 class Code extends Node
6 6
 {
7
-    public $value;
8
-    public $buffer;
9
-    public $escape;
7
+	public $value;
8
+	public $buffer;
9
+	public $escape;
10 10
 
11
-    public function __construct($value, $buffer, $escape)
12
-    {
13
-        $this->value = $value;
14
-        $this->buffer = $buffer;
15
-        $this->escape = $escape;
16
-    }
11
+	public function __construct($value, $buffer, $escape)
12
+	{
13
+		$this->value = $value;
14
+		$this->buffer = $buffer;
15
+		$this->escape = $escape;
16
+	}
17 17
 }
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/pug-php/pug/src/Jade/Nodes/Each.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 
5 5
 class Each extends Node
6 6
 {
7
-    public $obj;
8
-    public $value;
9
-    public $key;
10
-    public $block;
7
+	public $obj;
8
+	public $value;
9
+	public $key;
10
+	public $block;
11 11
 
12
-    public function __construct($obj, $value, $key, $block = null)
13
-    {
14
-        $this->obj = $obj;
15
-        $this->value = $value;
16
-        $this->key = $key;
17
-        $this->block = $block;
18
-    }
12
+	public function __construct($obj, $value, $key, $block = null)
13
+	{
14
+		$this->obj = $obj;
15
+		$this->value = $value;
16
+		$this->key = $key;
17
+		$this->block = $block;
18
+	}
19 19
 }
Please login to merge, or discard this patch.
jate/modules/ExternalModules/pug-php/pug/src/Jade/Nodes/CustomKeyword.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@
 block discarded – undo
4 4
 
5 5
 class CustomKeyword extends Node
6 6
 {
7
-    public $keyWord;
8
-    public $args;
9
-    public $block;
7
+	public $keyWord;
8
+	public $args;
9
+	public $block;
10 10
 
11
-    public function __construct($keyWord, $args, $block = null)
12
-    {
13
-        $this->keyWord = $keyWord;
14
-        $this->args = $args;
15
-        $this->block = $block;
16
-    }
11
+	public function __construct($keyWord, $args, $block = null)
12
+	{
13
+		$this->keyWord = $keyWord;
14
+		$this->args = $args;
15
+		$this->block = $block;
16
+	}
17 17
 }
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/composer/autoload_namespaces.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,6 +6,6 @@
 block discarded – undo
6 6
 $baseDir = dirname($vendorDir);
7 7
 
8 8
 return array(
9
-    'Pug\\' => array($vendorDir . '/pug-php/pug/src'),
10
-    'Jade\\' => array($vendorDir . '/pug-php/pug/src'),
9
+	'Pug\\' => array($vendorDir . '/pug-php/pug/src'),
10
+	'Jade\\' => array($vendorDir . '/pug-php/pug/src'),
11 11
 );
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,6 +6,6 @@
 block discarded – undo
6 6
 $baseDir = dirname($vendorDir);
7 7
 
8 8
 return array(
9
-    'Pug\\' => array($vendorDir . '/pug-php/pug/src'),
10
-    'Jade\\' => array($vendorDir . '/pug-php/pug/src'),
9
+    'Pug\\' => array($vendorDir.'/pug-php/pug/src'),
10
+    'Jade\\' => array($vendorDir.'/pug-php/pug/src'),
11 11
 );
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/composer/autoload_static.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210
8 8
 {
9
-    public static $prefixesPsr0 = array (
10
-        'P' => 
11
-        array (
12
-            'Pug\\' => 
13
-            array (
14
-                0 => __DIR__ . '/..' . '/pug-php/pug/src',
15
-            ),
16
-        ),
17
-        'J' => 
18
-        array (
19
-            'Jade\\' => 
20
-            array (
21
-                0 => __DIR__ . '/..' . '/pug-php/pug/src',
22
-            ),
23
-        ),
24
-    );
9
+	public static $prefixesPsr0 = array (
10
+		'P' => 
11
+		array (
12
+			'Pug\\' => 
13
+			array (
14
+				0 => __DIR__ . '/..' . '/pug-php/pug/src',
15
+			),
16
+		),
17
+		'J' => 
18
+		array (
19
+			'Jade\\' => 
20
+			array (
21
+				0 => __DIR__ . '/..' . '/pug-php/pug/src',
22
+			),
23
+		),
24
+	);
25 25
 
26
-    public static function getInitializer(ClassLoader $loader)
27
-    {
28
-        return \Closure::bind(function () use ($loader) {
29
-            $loader->prefixesPsr0 = ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210::$prefixesPsr0;
26
+	public static function getInitializer(ClassLoader $loader)
27
+	{
28
+		return \Closure::bind(function () use ($loader) {
29
+			$loader->prefixesPsr0 = ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210::$prefixesPsr0;
30 30
 
31
-        }, null, ClassLoader::class);
32
-    }
31
+		}, null, ClassLoader::class);
32
+	}
33 33
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210
8 8
 {
9
-    public static $prefixesPsr0 = array (
9
+    public static $prefixesPsr0 = array(
10 10
         'P' => 
11
-        array (
11
+        array(
12 12
             'Pug\\' => 
13
-            array (
14
-                0 => __DIR__ . '/..' . '/pug-php/pug/src',
13
+            array(
14
+                0 => __DIR__.'/..'.'/pug-php/pug/src',
15 15
             ),
16 16
         ),
17 17
         'J' => 
18
-        array (
18
+        array(
19 19
             'Jade\\' => 
20
-            array (
21
-                0 => __DIR__ . '/..' . '/pug-php/pug/src',
20
+            array(
21
+                0 => __DIR__.'/..'.'/pug-php/pug/src',
22 22
             ),
23 23
         ),
24 24
     );
25 25
 
26 26
     public static function getInitializer(ClassLoader $loader)
27 27
     {
28
-        return \Closure::bind(function () use ($loader) {
28
+        return \Closure::bind(function() use ($loader) {
29 29
             $loader->prefixesPsr0 = ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210::$prefixesPsr0;
30 30
 
31 31
         }, null, ClassLoader::class);
Please login to merge, or discard this patch.
dist/jate/modules/ExternalModules/composer/autoload_real.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -4,49 +4,49 @@
 block discarded – undo
4 4
 
5 5
 class ComposerAutoloaderInitb1e7ddc74da87434be0b5632a8bb4210
6 6
 {
7
-    private static $loader;
8
-
9
-    public static function loadClassLoader($class)
10
-    {
11
-        if ('Composer\Autoload\ClassLoader' === $class) {
12
-            require __DIR__ . '/ClassLoader.php';
13
-        }
14
-    }
15
-
16
-    public static function getLoader()
17
-    {
18
-        if (null !== self::$loader) {
19
-            return self::$loader;
20
-        }
21
-
22
-        spl_autoload_register(array('ComposerAutoloaderInitb1e7ddc74da87434be0b5632a8bb4210', 'loadClassLoader'), true, true);
23
-        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
-        spl_autoload_unregister(array('ComposerAutoloaderInitb1e7ddc74da87434be0b5632a8bb4210', 'loadClassLoader'));
25
-
26
-        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
27
-        if ($useStaticLoader) {
28
-            require_once __DIR__ . '/autoload_static.php';
29
-
30
-            call_user_func(\Composer\Autoload\ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210::getInitializer($loader));
31
-        } else {
32
-            $map = require __DIR__ . '/autoload_namespaces.php';
33
-            foreach ($map as $namespace => $path) {
34
-                $loader->set($namespace, $path);
35
-            }
36
-
37
-            $map = require __DIR__ . '/autoload_psr4.php';
38
-            foreach ($map as $namespace => $path) {
39
-                $loader->setPsr4($namespace, $path);
40
-            }
41
-
42
-            $classMap = require __DIR__ . '/autoload_classmap.php';
43
-            if ($classMap) {
44
-                $loader->addClassMap($classMap);
45
-            }
46
-        }
47
-
48
-        $loader->register(true);
49
-
50
-        return $loader;
51
-    }
7
+	private static $loader;
8
+
9
+	public static function loadClassLoader($class)
10
+	{
11
+		if ('Composer\Autoload\ClassLoader' === $class) {
12
+			require __DIR__ . '/ClassLoader.php';
13
+		}
14
+	}
15
+
16
+	public static function getLoader()
17
+	{
18
+		if (null !== self::$loader) {
19
+			return self::$loader;
20
+		}
21
+
22
+		spl_autoload_register(array('ComposerAutoloaderInitb1e7ddc74da87434be0b5632a8bb4210', 'loadClassLoader'), true, true);
23
+		self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+		spl_autoload_unregister(array('ComposerAutoloaderInitb1e7ddc74da87434be0b5632a8bb4210', 'loadClassLoader'));
25
+
26
+		$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
27
+		if ($useStaticLoader) {
28
+			require_once __DIR__ . '/autoload_static.php';
29
+
30
+			call_user_func(\Composer\Autoload\ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210::getInitializer($loader));
31
+		} else {
32
+			$map = require __DIR__ . '/autoload_namespaces.php';
33
+			foreach ($map as $namespace => $path) {
34
+				$loader->set($namespace, $path);
35
+			}
36
+
37
+			$map = require __DIR__ . '/autoload_psr4.php';
38
+			foreach ($map as $namespace => $path) {
39
+				$loader->setPsr4($namespace, $path);
40
+			}
41
+
42
+			$classMap = require __DIR__ . '/autoload_classmap.php';
43
+			if ($classMap) {
44
+				$loader->addClassMap($classMap);
45
+			}
46
+		}
47
+
48
+		$loader->register(true);
49
+
50
+		return $loader;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     public static function loadClassLoader($class)
10 10
     {
11 11
         if ('Composer\Autoload\ClassLoader' === $class) {
12
-            require __DIR__ . '/ClassLoader.php';
12
+            require __DIR__.'/ClassLoader.php';
13 13
         }
14 14
     }
15 15
 
@@ -25,21 +25,21 @@  discard block
 block discarded – undo
25 25
 
26 26
         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
27 27
         if ($useStaticLoader) {
28
-            require_once __DIR__ . '/autoload_static.php';
28
+            require_once __DIR__.'/autoload_static.php';
29 29
 
30 30
             call_user_func(\Composer\Autoload\ComposerStaticInitb1e7ddc74da87434be0b5632a8bb4210::getInitializer($loader));
31 31
         } else {
32
-            $map = require __DIR__ . '/autoload_namespaces.php';
32
+            $map = require __DIR__.'/autoload_namespaces.php';
33 33
             foreach ($map as $namespace => $path) {
34 34
                 $loader->set($namespace, $path);
35 35
             }
36 36
 
37
-            $map = require __DIR__ . '/autoload_psr4.php';
37
+            $map = require __DIR__.'/autoload_psr4.php';
38 38
             foreach ($map as $namespace => $path) {
39 39
                 $loader->setPsr4($namespace, $path);
40 40
             }
41 41
 
42
-            $classMap = require __DIR__ . '/autoload_classmap.php';
42
+            $classMap = require __DIR__.'/autoload_classmap.php';
43 43
             if ($classMap) {
44 44
                 $loader->addClassMap($classMap);
45 45
             }
Please login to merge, or discard this patch.
dist/jate/modules/Parsedown/Parsedown/Parsedown.php 3 patches
Indentation   +1429 added lines, -1429 removed lines patch added patch discarded remove patch
@@ -15,1524 +15,1524 @@
 block discarded – undo
15 15
 
16 16
 class Parsedown
17 17
 {
18
-    # ~
18
+	# ~
19 19
 
20
-    const version = '1.6.0';
20
+	const version = '1.6.0';
21 21
 
22
-    # ~
22
+	# ~
23 23
 
24
-    function text($text)
25
-    {
26
-        # make sure no definitions are set
27
-        $this->DefinitionData = array();
28
-
29
-        # standardize line breaks
30
-        $text = str_replace(array("\r\n", "\r"), "\n", $text);
31
-
32
-        # remove surrounding line breaks
33
-        $text = trim($text, "\n");
34
-
35
-        # split text into lines
36
-        $lines = explode("\n", $text);
37
-
38
-        # iterate through lines to identify blocks
39
-        $markup = $this->lines($lines);
24
+	function text($text)
25
+	{
26
+		# make sure no definitions are set
27
+		$this->DefinitionData = array();
28
+
29
+		# standardize line breaks
30
+		$text = str_replace(array("\r\n", "\r"), "\n", $text);
31
+
32
+		# remove surrounding line breaks
33
+		$text = trim($text, "\n");
34
+
35
+		# split text into lines
36
+		$lines = explode("\n", $text);
37
+
38
+		# iterate through lines to identify blocks
39
+		$markup = $this->lines($lines);
40 40
 
41
-        # trim line breaks
42
-        $markup = trim($markup, "\n");
41
+		# trim line breaks
42
+		$markup = trim($markup, "\n");
43 43
 
44
-        return $markup;
45
-    }
44
+		return $markup;
45
+	}
46 46
 
47
-    #
48
-    # Setters
49
-    #
47
+	#
48
+	# Setters
49
+	#
50 50
 
51
-    function setBreaksEnabled($breaksEnabled)
52
-    {
53
-        $this->breaksEnabled = $breaksEnabled;
51
+	function setBreaksEnabled($breaksEnabled)
52
+	{
53
+		$this->breaksEnabled = $breaksEnabled;
54 54
 
55
-        return $this;
56
-    }
55
+		return $this;
56
+	}
57 57
 
58
-    protected $breaksEnabled;
58
+	protected $breaksEnabled;
59 59
 
60
-    function setMarkupEscaped($markupEscaped)
61
-    {
62
-        $this->markupEscaped = $markupEscaped;
60
+	function setMarkupEscaped($markupEscaped)
61
+	{
62
+		$this->markupEscaped = $markupEscaped;
63 63
 
64
-        return $this;
65
-    }
64
+		return $this;
65
+	}
66 66
 
67
-    protected $markupEscaped;
67
+	protected $markupEscaped;
68 68
 
69
-    function setUrlsLinked($urlsLinked)
70
-    {
71
-        $this->urlsLinked = $urlsLinked;
69
+	function setUrlsLinked($urlsLinked)
70
+	{
71
+		$this->urlsLinked = $urlsLinked;
72 72
 
73
-        return $this;
74
-    }
73
+		return $this;
74
+	}
75 75
 
76
-    protected $urlsLinked = true;
76
+	protected $urlsLinked = true;
77 77
 
78
-    #
79
-    # Lines
80
-    #
78
+	#
79
+	# Lines
80
+	#
81 81
 
82
-    protected $BlockTypes = array(
83
-        '#' => array('Header'),
84
-        '*' => array('Rule', 'List'),
85
-        '+' => array('List'),
86
-        '-' => array('SetextHeader', 'Table', 'Rule', 'List'),
87
-        '0' => array('List'),
88
-        '1' => array('List'),
89
-        '2' => array('List'),
90
-        '3' => array('List'),
91
-        '4' => array('List'),
92
-        '5' => array('List'),
93
-        '6' => array('List'),
94
-        '7' => array('List'),
95
-        '8' => array('List'),
96
-        '9' => array('List'),
97
-        ':' => array('Table'),
98
-        '<' => array('Comment', 'Markup'),
99
-        '=' => array('SetextHeader'),
100
-        '>' => array('Quote'),
101
-        '[' => array('Reference'),
102
-        '_' => array('Rule'),
103
-        '`' => array('FencedCode'),
104
-        '|' => array('Table'),
105
-        '~' => array('FencedCode'),
106
-    );
82
+	protected $BlockTypes = array(
83
+		'#' => array('Header'),
84
+		'*' => array('Rule', 'List'),
85
+		'+' => array('List'),
86
+		'-' => array('SetextHeader', 'Table', 'Rule', 'List'),
87
+		'0' => array('List'),
88
+		'1' => array('List'),
89
+		'2' => array('List'),
90
+		'3' => array('List'),
91
+		'4' => array('List'),
92
+		'5' => array('List'),
93
+		'6' => array('List'),
94
+		'7' => array('List'),
95
+		'8' => array('List'),
96
+		'9' => array('List'),
97
+		':' => array('Table'),
98
+		'<' => array('Comment', 'Markup'),
99
+		'=' => array('SetextHeader'),
100
+		'>' => array('Quote'),
101
+		'[' => array('Reference'),
102
+		'_' => array('Rule'),
103
+		'`' => array('FencedCode'),
104
+		'|' => array('Table'),
105
+		'~' => array('FencedCode'),
106
+	);
107 107
 
108
-    # ~
108
+	# ~
109 109
 
110
-    protected $unmarkedBlockTypes = array(
111
-        'Code',
112
-    );
110
+	protected $unmarkedBlockTypes = array(
111
+		'Code',
112
+	);
113 113
 
114
-    #
115
-    # Blocks
116
-    #
114
+	#
115
+	# Blocks
116
+	#
117 117
 
118
-    protected function lines(array $lines)
119
-    {
120
-        $CurrentBlock = null;
118
+	protected function lines(array $lines)
119
+	{
120
+		$CurrentBlock = null;
121 121
 
122
-        foreach ($lines as $line)
123
-        {
124
-            if (chop($line) === '')
125
-            {
126
-                if (isset($CurrentBlock))
127
-                {
128
-                    $CurrentBlock['interrupted'] = true;
129
-                }
122
+		foreach ($lines as $line)
123
+		{
124
+			if (chop($line) === '')
125
+			{
126
+				if (isset($CurrentBlock))
127
+				{
128
+					$CurrentBlock['interrupted'] = true;
129
+				}
130 130
 
131
-                continue;
132
-            }
131
+				continue;
132
+			}
133 133
 
134
-            if (strpos($line, "\t") !== false)
135
-            {
136
-                $parts = explode("\t", $line);
134
+			if (strpos($line, "\t") !== false)
135
+			{
136
+				$parts = explode("\t", $line);
137 137
 
138
-                $line = $parts[0];
138
+				$line = $parts[0];
139 139
 
140
-                unset($parts[0]);
140
+				unset($parts[0]);
141 141
 
142
-                foreach ($parts as $part)
143
-                {
144
-                    $shortage = 4 - mb_strlen($line, 'utf-8') % 4;
142
+				foreach ($parts as $part)
143
+				{
144
+					$shortage = 4 - mb_strlen($line, 'utf-8') % 4;
145 145
 
146
-                    $line .= str_repeat(' ', $shortage);
147
-                    $line .= $part;
148
-                }
149
-            }
146
+					$line .= str_repeat(' ', $shortage);
147
+					$line .= $part;
148
+				}
149
+			}
150 150
 
151
-            $indent = 0;
151
+			$indent = 0;
152 152
 
153
-            while (isset($line[$indent]) and $line[$indent] === ' ')
154
-            {
155
-                $indent ++;
156
-            }
153
+			while (isset($line[$indent]) and $line[$indent] === ' ')
154
+			{
155
+				$indent ++;
156
+			}
157 157
 
158
-            $text = $indent > 0 ? substr($line, $indent) : $line;
158
+			$text = $indent > 0 ? substr($line, $indent) : $line;
159 159
 
160
-            # ~
160
+			# ~
161 161
 
162
-            $Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
162
+			$Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
163 163
 
164
-            # ~
164
+			# ~
165 165
 
166
-            if (isset($CurrentBlock['continuable']))
167
-            {
168
-                $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
166
+			if (isset($CurrentBlock['continuable']))
167
+			{
168
+				$Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
169 169
 
170
-                if (isset($Block))
171
-                {
172
-                    $CurrentBlock = $Block;
170
+				if (isset($Block))
171
+				{
172
+					$CurrentBlock = $Block;
173 173
 
174
-                    continue;
175
-                }
176
-                else
177
-                {
178
-                    if ($this->isBlockCompletable($CurrentBlock['type']))
179
-                    {
180
-                        $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
181
-                    }
182
-                }
183
-            }
174
+					continue;
175
+				}
176
+				else
177
+				{
178
+					if ($this->isBlockCompletable($CurrentBlock['type']))
179
+					{
180
+						$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
181
+					}
182
+				}
183
+			}
184 184
 
185
-            # ~
185
+			# ~
186 186
 
187
-            $marker = $text[0];
187
+			$marker = $text[0];
188 188
 
189
-            # ~
189
+			# ~
190 190
 
191
-            $blockTypes = $this->unmarkedBlockTypes;
191
+			$blockTypes = $this->unmarkedBlockTypes;
192 192
 
193
-            if (isset($this->BlockTypes[$marker]))
194
-            {
195
-                foreach ($this->BlockTypes[$marker] as $blockType)
196
-                {
197
-                    $blockTypes []= $blockType;
198
-                }
199
-            }
193
+			if (isset($this->BlockTypes[$marker]))
194
+			{
195
+				foreach ($this->BlockTypes[$marker] as $blockType)
196
+				{
197
+					$blockTypes []= $blockType;
198
+				}
199
+			}
200 200
 
201
-            #
202
-            # ~
201
+			#
202
+			# ~
203 203
 
204
-            foreach ($blockTypes as $blockType)
205
-            {
206
-                $Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
204
+			foreach ($blockTypes as $blockType)
205
+			{
206
+				$Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
207 207
 
208
-                if (isset($Block))
209
-                {
210
-                    $Block['type'] = $blockType;
208
+				if (isset($Block))
209
+				{
210
+					$Block['type'] = $blockType;
211 211
 
212
-                    if ( ! isset($Block['identified']))
213
-                    {
214
-                        $Blocks []= $CurrentBlock;
212
+					if ( ! isset($Block['identified']))
213
+					{
214
+						$Blocks []= $CurrentBlock;
215 215
 
216
-                        $Block['identified'] = true;
217
-                    }
216
+						$Block['identified'] = true;
217
+					}
218 218
 
219
-                    if ($this->isBlockContinuable($blockType))
220
-                    {
221
-                        $Block['continuable'] = true;
222
-                    }
219
+					if ($this->isBlockContinuable($blockType))
220
+					{
221
+						$Block['continuable'] = true;
222
+					}
223 223
 
224
-                    $CurrentBlock = $Block;
224
+					$CurrentBlock = $Block;
225 225
 
226
-                    continue 2;
227
-                }
228
-            }
226
+					continue 2;
227
+				}
228
+			}
229 229
 
230
-            # ~
230
+			# ~
231 231
 
232
-            if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
233
-            {
234
-                $CurrentBlock['element']['text'] .= "\n".$text;
235
-            }
236
-            else
237
-            {
238
-                $Blocks []= $CurrentBlock;
232
+			if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
233
+			{
234
+				$CurrentBlock['element']['text'] .= "\n".$text;
235
+			}
236
+			else
237
+			{
238
+				$Blocks []= $CurrentBlock;
239 239
 
240
-                $CurrentBlock = $this->paragraph($Line);
240
+				$CurrentBlock = $this->paragraph($Line);
241 241
 
242
-                $CurrentBlock['identified'] = true;
243
-            }
244
-        }
242
+				$CurrentBlock['identified'] = true;
243
+			}
244
+		}
245 245
 
246
-        # ~
246
+		# ~
247 247
 
248
-        if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
249
-        {
250
-            $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
251
-        }
248
+		if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
249
+		{
250
+			$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
251
+		}
252 252
 
253
-        # ~
253
+		# ~
254 254
 
255
-        $Blocks []= $CurrentBlock;
255
+		$Blocks []= $CurrentBlock;
256 256
 
257
-        unset($Blocks[0]);
257
+		unset($Blocks[0]);
258 258
 
259
-        # ~
259
+		# ~
260 260
 
261
-        $markup = '';
261
+		$markup = '';
262 262
 
263
-        foreach ($Blocks as $Block)
264
-        {
265
-            if (isset($Block['hidden']))
266
-            {
267
-                continue;
268
-            }
263
+		foreach ($Blocks as $Block)
264
+		{
265
+			if (isset($Block['hidden']))
266
+			{
267
+				continue;
268
+			}
269 269
 
270
-            $markup .= "\n";
271
-            $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
272
-        }
270
+			$markup .= "\n";
271
+			$markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
272
+		}
273 273
 
274
-        $markup .= "\n";
274
+		$markup .= "\n";
275 275
 
276
-        # ~
276
+		# ~
277 277
 
278
-        return $markup;
279
-    }
278
+		return $markup;
279
+	}
280 280
 
281
-    protected function isBlockContinuable($Type)
282
-    {
283
-        return method_exists($this, 'block'.$Type.'Continue');
284
-    }
281
+	protected function isBlockContinuable($Type)
282
+	{
283
+		return method_exists($this, 'block'.$Type.'Continue');
284
+	}
285 285
 
286
-    protected function isBlockCompletable($Type)
287
-    {
288
-        return method_exists($this, 'block'.$Type.'Complete');
289
-    }
286
+	protected function isBlockCompletable($Type)
287
+	{
288
+		return method_exists($this, 'block'.$Type.'Complete');
289
+	}
290 290
 
291
-    #
292
-    # Code
291
+	#
292
+	# Code
293 293
 
294
-    protected function blockCode($Line, $Block = null)
295
-    {
296
-        if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
297
-        {
298
-            return;
299
-        }
294
+	protected function blockCode($Line, $Block = null)
295
+	{
296
+		if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
297
+		{
298
+			return;
299
+		}
300 300
 
301
-        if ($Line['indent'] >= 4)
302
-        {
303
-            $text = substr($Line['body'], 4);
301
+		if ($Line['indent'] >= 4)
302
+		{
303
+			$text = substr($Line['body'], 4);
304 304
 
305
-            $Block = array(
306
-                'element' => array(
307
-                    'name' => 'pre',
308
-                    'handler' => 'element',
309
-                    'text' => array(
310
-                        'name' => 'code',
311
-                        'text' => $text,
312
-                    ),
313
-                ),
314
-            );
305
+			$Block = array(
306
+				'element' => array(
307
+					'name' => 'pre',
308
+					'handler' => 'element',
309
+					'text' => array(
310
+						'name' => 'code',
311
+						'text' => $text,
312
+					),
313
+				),
314
+			);
315 315
 
316
-            return $Block;
317
-        }
318
-    }
319
-
320
-    protected function blockCodeContinue($Line, $Block)
321
-    {
322
-        if ($Line['indent'] >= 4)
323
-        {
324
-            if (isset($Block['interrupted']))
325
-            {
326
-                $Block['element']['text']['text'] .= "\n";
327
-
328
-                unset($Block['interrupted']);
329
-            }
330
-
331
-            $Block['element']['text']['text'] .= "\n";
332
-
333
-            $text = substr($Line['body'], 4);
334
-
335
-            $Block['element']['text']['text'] .= $text;
336
-
337
-            return $Block;
338
-        }
339
-    }
340
-
341
-    protected function blockCodeComplete($Block)
342
-    {
343
-        $text = $Block['element']['text']['text'];
344
-
345
-        $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
346
-
347
-        $Block['element']['text']['text'] = $text;
348
-
349
-        return $Block;
350
-    }
351
-
352
-    #
353
-    # Comment
354
-
355
-    protected function blockComment($Line)
356
-    {
357
-        if ($this->markupEscaped)
358
-        {
359
-            return;
360
-        }
361
-
362
-        if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
363
-        {
364
-            $Block = array(
365
-                'markup' => $Line['body'],
366
-            );
367
-
368
-            if (preg_match('/-->$/', $Line['text']))
369
-            {
370
-                $Block['closed'] = true;
371
-            }
372
-
373
-            return $Block;
374
-        }
375
-    }
376
-
377
-    protected function blockCommentContinue($Line, array $Block)
378
-    {
379
-        if (isset($Block['closed']))
380
-        {
381
-            return;
382
-        }
383
-
384
-        $Block['markup'] .= "\n" . $Line['body'];
385
-
386
-        if (preg_match('/-->$/', $Line['text']))
387
-        {
388
-            $Block['closed'] = true;
389
-        }
390
-
391
-        return $Block;
392
-    }
393
-
394
-    #
395
-    # Fenced Code
396
-
397
-    protected function blockFencedCode($Line)
398
-    {
399
-        if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
400
-        {
401
-            $Element = array(
402
-                'name' => 'code',
403
-                'text' => '',
404
-            );
405
-
406
-            if (isset($matches[1]))
407
-            {
408
-                $class = 'language-'.$matches[1];
409
-
410
-                $Element['attributes'] = array(
411
-                    'class' => $class,
412
-                );
413
-            }
414
-
415
-            $Block = array(
416
-                'char' => $Line['text'][0],
417
-                'element' => array(
418
-                    'name' => 'pre',
419
-                    'handler' => 'element',
420
-                    'text' => $Element,
421
-                ),
422
-            );
423
-
424
-            return $Block;
425
-        }
426
-    }
427
-
428
-    protected function blockFencedCodeContinue($Line, $Block)
429
-    {
430
-        if (isset($Block['complete']))
431
-        {
432
-            return;
433
-        }
434
-
435
-        if (isset($Block['interrupted']))
436
-        {
437
-            $Block['element']['text']['text'] .= "\n";
438
-
439
-            unset($Block['interrupted']);
440
-        }
441
-
442
-        if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
443
-        {
444
-            $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
445
-
446
-            $Block['complete'] = true;
447
-
448
-            return $Block;
449
-        }
450
-
451
-        $Block['element']['text']['text'] .= "\n".$Line['body'];;
452
-
453
-        return $Block;
454
-    }
455
-
456
-    protected function blockFencedCodeComplete($Block)
457
-    {
458
-        $text = $Block['element']['text']['text'];
459
-
460
-        $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
461
-
462
-        $Block['element']['text']['text'] = $text;
463
-
464
-        return $Block;
465
-    }
466
-
467
-    #
468
-    # Header
469
-
470
-    protected function blockHeader($Line)
471
-    {
472
-        if (isset($Line['text'][1]))
473
-        {
474
-            $level = 1;
475
-
476
-            while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
477
-            {
478
-                $level ++;
479
-            }
480
-
481
-            if ($level > 6)
482
-            {
483
-                return;
484
-            }
485
-
486
-            $text = trim($Line['text'], '# ');
487
-
488
-            $Block = array(
489
-                'element' => array(
490
-                    'name' => 'h' . min(6, $level),
491
-                    'text' => $text,
492
-                    'handler' => 'line',
493
-                ),
494
-            );
495
-
496
-            return $Block;
497
-        }
498
-    }
499
-
500
-    #
501
-    # List
502
-
503
-    protected function blockList($Line)
504
-    {
505
-        list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
506
-
507
-        if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
508
-        {
509
-            $Block = array(
510
-                'indent' => $Line['indent'],
511
-                'pattern' => $pattern,
512
-                'element' => array(
513
-                    'name' => $name,
514
-                    'handler' => 'elements',
515
-                ),
516
-            );
517
-
518
-            $Block['li'] = array(
519
-                'name' => 'li',
520
-                'handler' => 'li',
521
-                'text' => array(
522
-                    $matches[2],
523
-                ),
524
-            );
525
-
526
-            $Block['element']['text'] []= & $Block['li'];
316
+			return $Block;
317
+		}
318
+	}
319
+
320
+	protected function blockCodeContinue($Line, $Block)
321
+	{
322
+		if ($Line['indent'] >= 4)
323
+		{
324
+			if (isset($Block['interrupted']))
325
+			{
326
+				$Block['element']['text']['text'] .= "\n";
327
+
328
+				unset($Block['interrupted']);
329
+			}
330
+
331
+			$Block['element']['text']['text'] .= "\n";
332
+
333
+			$text = substr($Line['body'], 4);
334
+
335
+			$Block['element']['text']['text'] .= $text;
336
+
337
+			return $Block;
338
+		}
339
+	}
340
+
341
+	protected function blockCodeComplete($Block)
342
+	{
343
+		$text = $Block['element']['text']['text'];
344
+
345
+		$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
346
+
347
+		$Block['element']['text']['text'] = $text;
348
+
349
+		return $Block;
350
+	}
351
+
352
+	#
353
+	# Comment
354
+
355
+	protected function blockComment($Line)
356
+	{
357
+		if ($this->markupEscaped)
358
+		{
359
+			return;
360
+		}
361
+
362
+		if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!')
363
+		{
364
+			$Block = array(
365
+				'markup' => $Line['body'],
366
+			);
367
+
368
+			if (preg_match('/-->$/', $Line['text']))
369
+			{
370
+				$Block['closed'] = true;
371
+			}
372
+
373
+			return $Block;
374
+		}
375
+	}
376
+
377
+	protected function blockCommentContinue($Line, array $Block)
378
+	{
379
+		if (isset($Block['closed']))
380
+		{
381
+			return;
382
+		}
383
+
384
+		$Block['markup'] .= "\n" . $Line['body'];
385
+
386
+		if (preg_match('/-->$/', $Line['text']))
387
+		{
388
+			$Block['closed'] = true;
389
+		}
390
+
391
+		return $Block;
392
+	}
393
+
394
+	#
395
+	# Fenced Code
396
+
397
+	protected function blockFencedCode($Line)
398
+	{
399
+		if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
400
+		{
401
+			$Element = array(
402
+				'name' => 'code',
403
+				'text' => '',
404
+			);
405
+
406
+			if (isset($matches[1]))
407
+			{
408
+				$class = 'language-'.$matches[1];
409
+
410
+				$Element['attributes'] = array(
411
+					'class' => $class,
412
+				);
413
+			}
414
+
415
+			$Block = array(
416
+				'char' => $Line['text'][0],
417
+				'element' => array(
418
+					'name' => 'pre',
419
+					'handler' => 'element',
420
+					'text' => $Element,
421
+				),
422
+			);
423
+
424
+			return $Block;
425
+		}
426
+	}
427
+
428
+	protected function blockFencedCodeContinue($Line, $Block)
429
+	{
430
+		if (isset($Block['complete']))
431
+		{
432
+			return;
433
+		}
434
+
435
+		if (isset($Block['interrupted']))
436
+		{
437
+			$Block['element']['text']['text'] .= "\n";
438
+
439
+			unset($Block['interrupted']);
440
+		}
441
+
442
+		if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text']))
443
+		{
444
+			$Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1);
445
+
446
+			$Block['complete'] = true;
447
+
448
+			return $Block;
449
+		}
450
+
451
+		$Block['element']['text']['text'] .= "\n".$Line['body'];;
452
+
453
+		return $Block;
454
+	}
455
+
456
+	protected function blockFencedCodeComplete($Block)
457
+	{
458
+		$text = $Block['element']['text']['text'];
459
+
460
+		$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
461
+
462
+		$Block['element']['text']['text'] = $text;
463
+
464
+		return $Block;
465
+	}
466
+
467
+	#
468
+	# Header
469
+
470
+	protected function blockHeader($Line)
471
+	{
472
+		if (isset($Line['text'][1]))
473
+		{
474
+			$level = 1;
475
+
476
+			while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
477
+			{
478
+				$level ++;
479
+			}
480
+
481
+			if ($level > 6)
482
+			{
483
+				return;
484
+			}
485
+
486
+			$text = trim($Line['text'], '# ');
487
+
488
+			$Block = array(
489
+				'element' => array(
490
+					'name' => 'h' . min(6, $level),
491
+					'text' => $text,
492
+					'handler' => 'line',
493
+				),
494
+			);
495
+
496
+			return $Block;
497
+		}
498
+	}
499
+
500
+	#
501
+	# List
502
+
503
+	protected function blockList($Line)
504
+	{
505
+		list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
506
+
507
+		if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches))
508
+		{
509
+			$Block = array(
510
+				'indent' => $Line['indent'],
511
+				'pattern' => $pattern,
512
+				'element' => array(
513
+					'name' => $name,
514
+					'handler' => 'elements',
515
+				),
516
+			);
517
+
518
+			$Block['li'] = array(
519
+				'name' => 'li',
520
+				'handler' => 'li',
521
+				'text' => array(
522
+					$matches[2],
523
+				),
524
+			);
525
+
526
+			$Block['element']['text'] []= & $Block['li'];
527 527
 
528
-            return $Block;
529
-        }
530
-    }
528
+			return $Block;
529
+		}
530
+	}
531 531
 
532
-    protected function blockListContinue($Line, array $Block)
533
-    {
534
-        if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
535
-        {
536
-            if (isset($Block['interrupted']))
537
-            {
538
-                $Block['li']['text'] []= '';
539
-
540
-                unset($Block['interrupted']);
541
-            }
542
-
543
-            unset($Block['li']);
544
-
545
-            $text = isset($matches[1]) ? $matches[1] : '';
546
-
547
-            $Block['li'] = array(
548
-                'name' => 'li',
549
-                'handler' => 'li',
550
-                'text' => array(
551
-                    $text,
552
-                ),
553
-            );
554
-
555
-            $Block['element']['text'] []= & $Block['li'];
556
-
557
-            return $Block;
558
-        }
559
-
560
-        if ($Line['text'][0] === '[' and $this->blockReference($Line))
561
-        {
562
-            return $Block;
563
-        }
564
-
565
-        if ( ! isset($Block['interrupted']))
566
-        {
567
-            $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
568
-
569
-            $Block['li']['text'] []= $text;
570
-
571
-            return $Block;
572
-        }
573
-
574
-        if ($Line['indent'] > 0)
575
-        {
576
-            $Block['li']['text'] []= '';
577
-
578
-            $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
579
-
580
-            $Block['li']['text'] []= $text;
581
-
582
-            unset($Block['interrupted']);
583
-
584
-            return $Block;
585
-        }
586
-    }
587
-
588
-    #
589
-    # Quote
590
-
591
-    protected function blockQuote($Line)
592
-    {
593
-        if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
594
-        {
595
-            $Block = array(
596
-                'element' => array(
597
-                    'name' => 'blockquote',
598
-                    'handler' => 'lines',
599
-                    'text' => (array) $matches[1],
600
-                ),
601
-            );
602
-
603
-            return $Block;
604
-        }
605
-    }
606
-
607
-    protected function blockQuoteContinue($Line, array $Block)
608
-    {
609
-        if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
610
-        {
611
-            if (isset($Block['interrupted']))
612
-            {
613
-                $Block['element']['text'] []= '';
614
-
615
-                unset($Block['interrupted']);
616
-            }
617
-
618
-            $Block['element']['text'] []= $matches[1];
619
-
620
-            return $Block;
621
-        }
622
-
623
-        if ( ! isset($Block['interrupted']))
624
-        {
625
-            $Block['element']['text'] []= $Line['text'];
626
-
627
-            return $Block;
628
-        }
629
-    }
630
-
631
-    #
632
-    # Rule
633
-
634
-    protected function blockRule($Line)
635
-    {
636
-        if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
637
-        {
638
-            $Block = array(
639
-                'element' => array(
640
-                    'name' => 'hr'
641
-                ),
642
-            );
643
-
644
-            return $Block;
645
-        }
646
-    }
647
-
648
-    #
649
-    # Setext
650
-
651
-    protected function blockSetextHeader($Line, array $Block = null)
652
-    {
653
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
654
-        {
655
-            return;
656
-        }
657
-
658
-        if (chop($Line['text'], $Line['text'][0]) === '')
659
-        {
660
-            $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
661
-
662
-            return $Block;
663
-        }
664
-    }
665
-
666
-    #
667
-    # Markup
668
-
669
-    protected function blockMarkup($Line)
670
-    {
671
-        if ($this->markupEscaped)
672
-        {
673
-            return;
674
-        }
675
-
676
-        if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
677
-        {
678
-            $element = strtolower($matches[1]);
679
-
680
-            if (in_array($element, $this->textLevelElements))
681
-            {
682
-                return;
683
-            }
684
-
685
-            $Block = array(
686
-                'name' => $matches[1],
687
-                'depth' => 0,
688
-                'markup' => $Line['text'],
689
-            );
690
-
691
-            $length = strlen($matches[0]);
692
-
693
-            $remainder = substr($Line['text'], $length);
694
-
695
-            if (trim($remainder) === '')
696
-            {
697
-                if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
698
-                {
699
-                    $Block['closed'] = true;
700
-
701
-                    $Block['void'] = true;
702
-                }
703
-            }
704
-            else
705
-            {
706
-                if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
707
-                {
708
-                    return;
709
-                }
710
-
711
-                if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
712
-                {
713
-                    $Block['closed'] = true;
714
-                }
715
-            }
716
-
717
-            return $Block;
718
-        }
719
-    }
720
-
721
-    protected function blockMarkupContinue($Line, array $Block)
722
-    {
723
-        if (isset($Block['closed']))
724
-        {
725
-            return;
726
-        }
727
-
728
-        if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
729
-        {
730
-            $Block['depth'] ++;
731
-        }
732
-
733
-        if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
734
-        {
735
-            if ($Block['depth'] > 0)
736
-            {
737
-                $Block['depth'] --;
738
-            }
739
-            else
740
-            {
741
-                $Block['closed'] = true;
742
-            }
743
-        }
744
-
745
-        if (isset($Block['interrupted']))
746
-        {
747
-            $Block['markup'] .= "\n";
748
-
749
-            unset($Block['interrupted']);
750
-        }
751
-
752
-        $Block['markup'] .= "\n".$Line['body'];
753
-
754
-        return $Block;
755
-    }
756
-
757
-    #
758
-    # Reference
759
-
760
-    protected function blockReference($Line)
761
-    {
762
-        if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
763
-        {
764
-            $id = strtolower($matches[1]);
765
-
766
-            $Data = array(
767
-                'url' => $matches[2],
768
-                'title' => null,
769
-            );
770
-
771
-            if (isset($matches[3]))
772
-            {
773
-                $Data['title'] = $matches[3];
774
-            }
775
-
776
-            $this->DefinitionData['Reference'][$id] = $Data;
777
-
778
-            $Block = array(
779
-                'hidden' => true,
780
-            );
781
-
782
-            return $Block;
783
-        }
784
-    }
785
-
786
-    #
787
-    # Table
788
-
789
-    protected function blockTable($Line, array $Block = null)
790
-    {
791
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
792
-        {
793
-            return;
794
-        }
795
-
796
-        if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '')
797
-        {
798
-            $alignments = array();
799
-
800
-            $divider = $Line['text'];
801
-
802
-            $divider = trim($divider);
803
-            $divider = trim($divider, '|');
804
-
805
-            $dividerCells = explode('|', $divider);
806
-
807
-            foreach ($dividerCells as $dividerCell)
808
-            {
809
-                $dividerCell = trim($dividerCell);
810
-
811
-                if ($dividerCell === '')
812
-                {
813
-                    continue;
814
-                }
815
-
816
-                $alignment = null;
817
-
818
-                if ($dividerCell[0] === ':')
819
-                {
820
-                    $alignment = 'left';
821
-                }
822
-
823
-                if (substr($dividerCell, - 1) === ':')
824
-                {
825
-                    $alignment = $alignment === 'left' ? 'center' : 'right';
826
-                }
827
-
828
-                $alignments []= $alignment;
829
-            }
830
-
831
-            # ~
832
-
833
-            $HeaderElements = array();
834
-
835
-            $header = $Block['element']['text'];
836
-
837
-            $header = trim($header);
838
-            $header = trim($header, '|');
532
+	protected function blockListContinue($Line, array $Block)
533
+	{
534
+		if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
535
+		{
536
+			if (isset($Block['interrupted']))
537
+			{
538
+				$Block['li']['text'] []= '';
539
+
540
+				unset($Block['interrupted']);
541
+			}
542
+
543
+			unset($Block['li']);
544
+
545
+			$text = isset($matches[1]) ? $matches[1] : '';
546
+
547
+			$Block['li'] = array(
548
+				'name' => 'li',
549
+				'handler' => 'li',
550
+				'text' => array(
551
+					$text,
552
+				),
553
+			);
554
+
555
+			$Block['element']['text'] []= & $Block['li'];
556
+
557
+			return $Block;
558
+		}
559
+
560
+		if ($Line['text'][0] === '[' and $this->blockReference($Line))
561
+		{
562
+			return $Block;
563
+		}
564
+
565
+		if ( ! isset($Block['interrupted']))
566
+		{
567
+			$text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
568
+
569
+			$Block['li']['text'] []= $text;
570
+
571
+			return $Block;
572
+		}
573
+
574
+		if ($Line['indent'] > 0)
575
+		{
576
+			$Block['li']['text'] []= '';
577
+
578
+			$text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
579
+
580
+			$Block['li']['text'] []= $text;
581
+
582
+			unset($Block['interrupted']);
583
+
584
+			return $Block;
585
+		}
586
+	}
587
+
588
+	#
589
+	# Quote
590
+
591
+	protected function blockQuote($Line)
592
+	{
593
+		if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
594
+		{
595
+			$Block = array(
596
+				'element' => array(
597
+					'name' => 'blockquote',
598
+					'handler' => 'lines',
599
+					'text' => (array) $matches[1],
600
+				),
601
+			);
602
+
603
+			return $Block;
604
+		}
605
+	}
606
+
607
+	protected function blockQuoteContinue($Line, array $Block)
608
+	{
609
+		if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
610
+		{
611
+			if (isset($Block['interrupted']))
612
+			{
613
+				$Block['element']['text'] []= '';
614
+
615
+				unset($Block['interrupted']);
616
+			}
617
+
618
+			$Block['element']['text'] []= $matches[1];
619
+
620
+			return $Block;
621
+		}
622
+
623
+		if ( ! isset($Block['interrupted']))
624
+		{
625
+			$Block['element']['text'] []= $Line['text'];
626
+
627
+			return $Block;
628
+		}
629
+	}
630
+
631
+	#
632
+	# Rule
633
+
634
+	protected function blockRule($Line)
635
+	{
636
+		if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
637
+		{
638
+			$Block = array(
639
+				'element' => array(
640
+					'name' => 'hr'
641
+				),
642
+			);
643
+
644
+			return $Block;
645
+		}
646
+	}
647
+
648
+	#
649
+	# Setext
650
+
651
+	protected function blockSetextHeader($Line, array $Block = null)
652
+	{
653
+		if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
654
+		{
655
+			return;
656
+		}
657
+
658
+		if (chop($Line['text'], $Line['text'][0]) === '')
659
+		{
660
+			$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
661
+
662
+			return $Block;
663
+		}
664
+	}
665
+
666
+	#
667
+	# Markup
668
+
669
+	protected function blockMarkup($Line)
670
+	{
671
+		if ($this->markupEscaped)
672
+		{
673
+			return;
674
+		}
675
+
676
+		if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
677
+		{
678
+			$element = strtolower($matches[1]);
679
+
680
+			if (in_array($element, $this->textLevelElements))
681
+			{
682
+				return;
683
+			}
684
+
685
+			$Block = array(
686
+				'name' => $matches[1],
687
+				'depth' => 0,
688
+				'markup' => $Line['text'],
689
+			);
690
+
691
+			$length = strlen($matches[0]);
692
+
693
+			$remainder = substr($Line['text'], $length);
694
+
695
+			if (trim($remainder) === '')
696
+			{
697
+				if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
698
+				{
699
+					$Block['closed'] = true;
700
+
701
+					$Block['void'] = true;
702
+				}
703
+			}
704
+			else
705
+			{
706
+				if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
707
+				{
708
+					return;
709
+				}
710
+
711
+				if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
712
+				{
713
+					$Block['closed'] = true;
714
+				}
715
+			}
716
+
717
+			return $Block;
718
+		}
719
+	}
720
+
721
+	protected function blockMarkupContinue($Line, array $Block)
722
+	{
723
+		if (isset($Block['closed']))
724
+		{
725
+			return;
726
+		}
727
+
728
+		if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
729
+		{
730
+			$Block['depth'] ++;
731
+		}
732
+
733
+		if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
734
+		{
735
+			if ($Block['depth'] > 0)
736
+			{
737
+				$Block['depth'] --;
738
+			}
739
+			else
740
+			{
741
+				$Block['closed'] = true;
742
+			}
743
+		}
744
+
745
+		if (isset($Block['interrupted']))
746
+		{
747
+			$Block['markup'] .= "\n";
748
+
749
+			unset($Block['interrupted']);
750
+		}
751
+
752
+		$Block['markup'] .= "\n".$Line['body'];
753
+
754
+		return $Block;
755
+	}
756
+
757
+	#
758
+	# Reference
759
+
760
+	protected function blockReference($Line)
761
+	{
762
+		if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
763
+		{
764
+			$id = strtolower($matches[1]);
765
+
766
+			$Data = array(
767
+				'url' => $matches[2],
768
+				'title' => null,
769
+			);
770
+
771
+			if (isset($matches[3]))
772
+			{
773
+				$Data['title'] = $matches[3];
774
+			}
775
+
776
+			$this->DefinitionData['Reference'][$id] = $Data;
777
+
778
+			$Block = array(
779
+				'hidden' => true,
780
+			);
781
+
782
+			return $Block;
783
+		}
784
+	}
785
+
786
+	#
787
+	# Table
788
+
789
+	protected function blockTable($Line, array $Block = null)
790
+	{
791
+		if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
792
+		{
793
+			return;
794
+		}
795
+
796
+		if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '')
797
+		{
798
+			$alignments = array();
799
+
800
+			$divider = $Line['text'];
801
+
802
+			$divider = trim($divider);
803
+			$divider = trim($divider, '|');
804
+
805
+			$dividerCells = explode('|', $divider);
806
+
807
+			foreach ($dividerCells as $dividerCell)
808
+			{
809
+				$dividerCell = trim($dividerCell);
810
+
811
+				if ($dividerCell === '')
812
+				{
813
+					continue;
814
+				}
815
+
816
+				$alignment = null;
817
+
818
+				if ($dividerCell[0] === ':')
819
+				{
820
+					$alignment = 'left';
821
+				}
822
+
823
+				if (substr($dividerCell, - 1) === ':')
824
+				{
825
+					$alignment = $alignment === 'left' ? 'center' : 'right';
826
+				}
827
+
828
+				$alignments []= $alignment;
829
+			}
830
+
831
+			# ~
832
+
833
+			$HeaderElements = array();
834
+
835
+			$header = $Block['element']['text'];
836
+
837
+			$header = trim($header);
838
+			$header = trim($header, '|');
839 839
 
840
-            $headerCells = explode('|', $header);
840
+			$headerCells = explode('|', $header);
841 841
 
842
-            foreach ($headerCells as $index => $headerCell)
843
-            {
844
-                $headerCell = trim($headerCell);
842
+			foreach ($headerCells as $index => $headerCell)
843
+			{
844
+				$headerCell = trim($headerCell);
845 845
 
846
-                $HeaderElement = array(
847
-                    'name' => 'th',
848
-                    'text' => $headerCell,
849
-                    'handler' => 'line',
850
-                );
846
+				$HeaderElement = array(
847
+					'name' => 'th',
848
+					'text' => $headerCell,
849
+					'handler' => 'line',
850
+				);
851 851
 
852
-                if (isset($alignments[$index]))
853
-                {
854
-                    $alignment = $alignments[$index];
855
-
856
-                    $HeaderElement['attributes'] = array(
857
-                        'style' => 'text-align: '.$alignment.';',
858
-                    );
859
-                }
860
-
861
-                $HeaderElements []= $HeaderElement;
862
-            }
863
-
864
-            # ~
865
-
866
-            $Block = array(
867
-                'alignments' => $alignments,
868
-                'identified' => true,
869
-                'element' => array(
870
-                    'name' => 'table',
871
-                    'handler' => 'elements',
872
-                ),
873
-            );
874
-
875
-            $Block['element']['text'] []= array(
876
-                'name' => 'thead',
877
-                'handler' => 'elements',
878
-            );
879
-
880
-            $Block['element']['text'] []= array(
881
-                'name' => 'tbody',
882
-                'handler' => 'elements',
883
-                'text' => array(),
884
-            );
885
-
886
-            $Block['element']['text'][0]['text'] []= array(
887
-                'name' => 'tr',
888
-                'handler' => 'elements',
889
-                'text' => $HeaderElements,
890
-            );
891
-
892
-            return $Block;
893
-        }
894
-    }
895
-
896
-    protected function blockTableContinue($Line, array $Block)
897
-    {
898
-        if (isset($Block['interrupted']))
899
-        {
900
-            return;
901
-        }
902
-
903
-        if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
904
-        {
905
-            $Elements = array();
906
-
907
-            $row = $Line['text'];
908
-
909
-            $row = trim($row);
910
-            $row = trim($row, '|');
911
-
912
-            preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
913
-
914
-            foreach ($matches[0] as $index => $cell)
915
-            {
916
-                $cell = trim($cell);
917
-
918
-                $Element = array(
919
-                    'name' => 'td',
920
-                    'handler' => 'line',
921
-                    'text' => $cell,
922
-                );
923
-
924
-                if (isset($Block['alignments'][$index]))
925
-                {
926
-                    $Element['attributes'] = array(
927
-                        'style' => 'text-align: '.$Block['alignments'][$index].';',
928
-                    );
929
-                }
930
-
931
-                $Elements []= $Element;
932
-            }
933
-
934
-            $Element = array(
935
-                'name' => 'tr',
936
-                'handler' => 'elements',
937
-                'text' => $Elements,
938
-            );
939
-
940
-            $Block['element']['text'][1]['text'] []= $Element;
941
-
942
-            return $Block;
943
-        }
944
-    }
945
-
946
-    #
947
-    # ~
948
-    #
949
-
950
-    protected function paragraph($Line)
951
-    {
952
-        $Block = array(
953
-            'element' => array(
954
-                'name' => 'p',
955
-                'text' => $Line['text'],
956
-                'handler' => 'line',
957
-            ),
958
-        );
852
+				if (isset($alignments[$index]))
853
+				{
854
+					$alignment = $alignments[$index];
855
+
856
+					$HeaderElement['attributes'] = array(
857
+						'style' => 'text-align: '.$alignment.';',
858
+					);
859
+				}
860
+
861
+				$HeaderElements []= $HeaderElement;
862
+			}
863
+
864
+			# ~
865
+
866
+			$Block = array(
867
+				'alignments' => $alignments,
868
+				'identified' => true,
869
+				'element' => array(
870
+					'name' => 'table',
871
+					'handler' => 'elements',
872
+				),
873
+			);
874
+
875
+			$Block['element']['text'] []= array(
876
+				'name' => 'thead',
877
+				'handler' => 'elements',
878
+			);
879
+
880
+			$Block['element']['text'] []= array(
881
+				'name' => 'tbody',
882
+				'handler' => 'elements',
883
+				'text' => array(),
884
+			);
885
+
886
+			$Block['element']['text'][0]['text'] []= array(
887
+				'name' => 'tr',
888
+				'handler' => 'elements',
889
+				'text' => $HeaderElements,
890
+			);
891
+
892
+			return $Block;
893
+		}
894
+	}
895
+
896
+	protected function blockTableContinue($Line, array $Block)
897
+	{
898
+		if (isset($Block['interrupted']))
899
+		{
900
+			return;
901
+		}
902
+
903
+		if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
904
+		{
905
+			$Elements = array();
906
+
907
+			$row = $Line['text'];
908
+
909
+			$row = trim($row);
910
+			$row = trim($row, '|');
911
+
912
+			preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches);
913
+
914
+			foreach ($matches[0] as $index => $cell)
915
+			{
916
+				$cell = trim($cell);
917
+
918
+				$Element = array(
919
+					'name' => 'td',
920
+					'handler' => 'line',
921
+					'text' => $cell,
922
+				);
923
+
924
+				if (isset($Block['alignments'][$index]))
925
+				{
926
+					$Element['attributes'] = array(
927
+						'style' => 'text-align: '.$Block['alignments'][$index].';',
928
+					);
929
+				}
930
+
931
+				$Elements []= $Element;
932
+			}
933
+
934
+			$Element = array(
935
+				'name' => 'tr',
936
+				'handler' => 'elements',
937
+				'text' => $Elements,
938
+			);
939
+
940
+			$Block['element']['text'][1]['text'] []= $Element;
941
+
942
+			return $Block;
943
+		}
944
+	}
945
+
946
+	#
947
+	# ~
948
+	#
949
+
950
+	protected function paragraph($Line)
951
+	{
952
+		$Block = array(
953
+			'element' => array(
954
+				'name' => 'p',
955
+				'text' => $Line['text'],
956
+				'handler' => 'line',
957
+			),
958
+		);
959 959
 
960
-        return $Block;
961
-    }
960
+		return $Block;
961
+	}
962 962
 
963
-    #
964
-    # Inline Elements
965
-    #
966
-
967
-    protected $InlineTypes = array(
968
-        '"' => array('SpecialCharacter'),
969
-        '!' => array('Image'),
970
-        '&' => array('SpecialCharacter'),
971
-        '*' => array('Emphasis'),
972
-        ':' => array('Url'),
973
-        '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'),
974
-        '>' => array('SpecialCharacter'),
975
-        '[' => array('Link'),
976
-        '_' => array('Emphasis'),
977
-        '`' => array('Code'),
978
-        '~' => array('Strikethrough'),
979
-        '\\' => array('EscapeSequence'),
980
-    );
981
-
982
-    # ~
983
-
984
-    protected $inlineMarkerList = '!"*_&[:<>`~\\';
963
+	#
964
+	# Inline Elements
965
+	#
966
+
967
+	protected $InlineTypes = array(
968
+		'"' => array('SpecialCharacter'),
969
+		'!' => array('Image'),
970
+		'&' => array('SpecialCharacter'),
971
+		'*' => array('Emphasis'),
972
+		':' => array('Url'),
973
+		'<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'),
974
+		'>' => array('SpecialCharacter'),
975
+		'[' => array('Link'),
976
+		'_' => array('Emphasis'),
977
+		'`' => array('Code'),
978
+		'~' => array('Strikethrough'),
979
+		'\\' => array('EscapeSequence'),
980
+	);
981
+
982
+	# ~
983
+
984
+	protected $inlineMarkerList = '!"*_&[:<>`~\\';
985 985
 
986
-    #
987
-    # ~
988
-    #
989
-
990
-    public function line($text)
991
-    {
992
-        $markup = '';
993
-
994
-        # $excerpt is based on the first occurrence of a marker
995
-
996
-        while ($excerpt = strpbrk($text, $this->inlineMarkerList))
997
-        {
998
-            $marker = $excerpt[0];
999
-
1000
-            $markerPosition = strpos($text, $marker);
1001
-
1002
-            $Excerpt = array('text' => $excerpt, 'context' => $text);
1003
-
1004
-            foreach ($this->InlineTypes[$marker] as $inlineType)
1005
-            {
1006
-                $Inline = $this->{'inline'.$inlineType}($Excerpt);
1007
-
1008
-                if ( ! isset($Inline))
1009
-                {
1010
-                    continue;
1011
-                }
1012
-
1013
-                # makes sure that the inline belongs to "our" marker
1014
-
1015
-                if (isset($Inline['position']) and $Inline['position'] > $markerPosition)
1016
-                {
1017
-                    continue;
1018
-                }
1019
-
1020
-                # sets a default inline position
1021
-
1022
-                if ( ! isset($Inline['position']))
1023
-                {
1024
-                    $Inline['position'] = $markerPosition;
1025
-                }
1026
-
1027
-                # the text that comes before the inline
1028
-                $unmarkedText = substr($text, 0, $Inline['position']);
1029
-
1030
-                # compile the unmarked text
1031
-                $markup .= $this->unmarkedText($unmarkedText);
1032
-
1033
-                # compile the inline
1034
-                $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
1035
-
1036
-                # remove the examined text
1037
-                $text = substr($text, $Inline['position'] + $Inline['extent']);
1038
-
1039
-                continue 2;
1040
-            }
1041
-
1042
-            # the marker does not belong to an inline
1043
-
1044
-            $unmarkedText = substr($text, 0, $markerPosition + 1);
1045
-
1046
-            $markup .= $this->unmarkedText($unmarkedText);
1047
-
1048
-            $text = substr($text, $markerPosition + 1);
1049
-        }
1050
-
1051
-        $markup .= $this->unmarkedText($text);
1052
-
1053
-        return $markup;
1054
-    }
1055
-
1056
-    #
1057
-    # ~
1058
-    #
1059
-
1060
-    protected function inlineCode($Excerpt)
1061
-    {
1062
-        $marker = $Excerpt['text'][0];
1063
-
1064
-        if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/s', $Excerpt['text'], $matches))
1065
-        {
1066
-            $text = $matches[2];
1067
-            $text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
1068
-            $text = preg_replace("/[ ]*\n/", ' ', $text);
1069
-
1070
-            return array(
1071
-                'extent' => strlen($matches[0]),
1072
-                'element' => array(
1073
-                    'name' => 'code',
1074
-                    'text' => $text,
1075
-                ),
1076
-            );
1077
-        }
1078
-    }
1079
-
1080
-    protected function inlineEmailTag($Excerpt)
1081
-    {
1082
-        if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
1083
-        {
1084
-            $url = $matches[1];
1085
-
1086
-            if ( ! isset($matches[2]))
1087
-            {
1088
-                $url = 'mailto:' . $url;
1089
-            }
1090
-
1091
-            return array(
1092
-                'extent' => strlen($matches[0]),
1093
-                'element' => array(
1094
-                    'name' => 'a',
1095
-                    'text' => $matches[1],
1096
-                    'attributes' => array(
1097
-                        'href' => $url,
1098
-                    ),
1099
-                ),
1100
-            );
1101
-        }
1102
-    }
1103
-
1104
-    protected function inlineEmphasis($Excerpt)
1105
-    {
1106
-        if ( ! isset($Excerpt['text'][1]))
1107
-        {
1108
-            return;
1109
-        }
1110
-
1111
-        $marker = $Excerpt['text'][0];
1112
-
1113
-        if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
1114
-        {
1115
-            $emphasis = 'strong';
1116
-        }
1117
-        elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1118
-        {
1119
-            $emphasis = 'em';
1120
-        }
1121
-        else
1122
-        {
1123
-            return;
1124
-        }
1125
-
1126
-        return array(
1127
-            'extent' => strlen($matches[0]),
1128
-            'element' => array(
1129
-                'name' => $emphasis,
1130
-                'handler' => 'line',
1131
-                'text' => $matches[1],
1132
-            ),
1133
-        );
1134
-    }
1135
-
1136
-    protected function inlineEscapeSequence($Excerpt)
1137
-    {
1138
-        if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
1139
-        {
1140
-            return array(
1141
-                'markup' => $Excerpt['text'][1],
1142
-                'extent' => 2,
1143
-            );
1144
-        }
1145
-    }
1146
-
1147
-    protected function inlineImage($Excerpt)
1148
-    {
1149
-        if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1150
-        {
1151
-            return;
1152
-        }
1153
-
1154
-        $Excerpt['text']= substr($Excerpt['text'], 1);
1155
-
1156
-        $Link = $this->inlineLink($Excerpt);
1157
-
1158
-        if ($Link === null)
1159
-        {
1160
-            return;
1161
-        }
1162
-
1163
-        $Inline = array(
1164
-            'extent' => $Link['extent'] + 1,
1165
-            'element' => array(
1166
-                'name' => 'img',
1167
-                'attributes' => array(
1168
-                    'src' => $Link['element']['attributes']['href'],
1169
-                    'alt' => $Link['element']['text'],
1170
-                ),
1171
-            ),
1172
-        );
1173
-
1174
-        $Inline['element']['attributes'] += $Link['element']['attributes'];
1175
-
1176
-        unset($Inline['element']['attributes']['href']);
1177
-
1178
-        return $Inline;
1179
-    }
1180
-
1181
-    protected function inlineLink($Excerpt)
1182
-    {
1183
-        $Element = array(
1184
-            'name' => 'a',
1185
-            'handler' => 'line',
1186
-            'text' => null,
1187
-            'attributes' => array(
1188
-                'href' => null,
1189
-                'title' => null,
1190
-            ),
1191
-        );
1192
-
1193
-        $extent = 0;
1194
-
1195
-        $remainder = $Excerpt['text'];
1196
-
1197
-        if (preg_match('/\[((?:[^][]|(?R))*)\]/', $remainder, $matches))
1198
-        {
1199
-            $Element['text'] = $matches[1];
1200
-
1201
-            $extent += strlen($matches[0]);
1202
-
1203
-            $remainder = substr($remainder, $extent);
1204
-        }
1205
-        else
1206
-        {
1207
-            return;
1208
-        }
1209
-
1210
-        if (preg_match('/^[(]((?:[^ ()]|[(][^ )]+[)])+)(?:[ ]+("[^"]*"|\'[^\']*\'))?[)]/', $remainder, $matches))
1211
-        {
1212
-            $Element['attributes']['href'] = $matches[1];
1213
-
1214
-            if (isset($matches[2]))
1215
-            {
1216
-                $Element['attributes']['title'] = substr($matches[2], 1, - 1);
1217
-            }
1218
-
1219
-            $extent += strlen($matches[0]);
1220
-        }
1221
-        else
1222
-        {
1223
-            if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
1224
-            {
1225
-                $definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
1226
-                $definition = strtolower($definition);
1227
-
1228
-                $extent += strlen($matches[0]);
1229
-            }
1230
-            else
1231
-            {
1232
-                $definition = strtolower($Element['text']);
1233
-            }
1234
-
1235
-            if ( ! isset($this->DefinitionData['Reference'][$definition]))
1236
-            {
1237
-                return;
1238
-            }
1239
-
1240
-            $Definition = $this->DefinitionData['Reference'][$definition];
1241
-
1242
-            $Element['attributes']['href'] = $Definition['url'];
1243
-            $Element['attributes']['title'] = $Definition['title'];
1244
-        }
1245
-
1246
-        $Element['attributes']['href'] = str_replace(array('&', '<'), array('&amp;', '&lt;'), $Element['attributes']['href']);
1247
-
1248
-        return array(
1249
-            'extent' => $extent,
1250
-            'element' => $Element,
1251
-        );
1252
-    }
1253
-
1254
-    protected function inlineMarkup($Excerpt)
1255
-    {
1256
-        if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false)
1257
-        {
1258
-            return;
1259
-        }
1260
-
1261
-        if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches))
1262
-        {
1263
-            return array(
1264
-                'markup' => $matches[0],
1265
-                'extent' => strlen($matches[0]),
1266
-            );
1267
-        }
1268
-
1269
-        if ($Excerpt['text'][1] === '!' and preg_match('/^<!---?[^>-](?:-?[^-])*-->/s', $Excerpt['text'], $matches))
1270
-        {
1271
-            return array(
1272
-                'markup' => $matches[0],
1273
-                'extent' => strlen($matches[0]),
1274
-            );
1275
-        }
1276
-
1277
-        if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
1278
-        {
1279
-            return array(
1280
-                'markup' => $matches[0],
1281
-                'extent' => strlen($matches[0]),
1282
-            );
1283
-        }
1284
-    }
1285
-
1286
-    protected function inlineSpecialCharacter($Excerpt)
1287
-    {
1288
-        if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1289
-        {
1290
-            return array(
1291
-                'markup' => '&amp;',
1292
-                'extent' => 1,
1293
-            );
1294
-        }
1295
-
1296
-        $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
1297
-
1298
-        if (isset($SpecialCharacter[$Excerpt['text'][0]]))
1299
-        {
1300
-            return array(
1301
-                'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
1302
-                'extent' => 1,
1303
-            );
1304
-        }
1305
-    }
1306
-
1307
-    protected function inlineStrikethrough($Excerpt)
1308
-    {
1309
-        if ( ! isset($Excerpt['text'][1]))
1310
-        {
1311
-            return;
1312
-        }
1313
-
1314
-        if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
1315
-        {
1316
-            return array(
1317
-                'extent' => strlen($matches[0]),
1318
-                'element' => array(
1319
-                    'name' => 'del',
1320
-                    'text' => $matches[1],
1321
-                    'handler' => 'line',
1322
-                ),
1323
-            );
1324
-        }
1325
-    }
1326
-
1327
-    protected function inlineUrl($Excerpt)
1328
-    {
1329
-        if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1330
-        {
1331
-            return;
1332
-        }
1333
-
1334
-        if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
1335
-        {
1336
-            $Inline = array(
1337
-                'extent' => strlen($matches[0][0]),
1338
-                'position' => $matches[0][1],
1339
-                'element' => array(
1340
-                    'name' => 'a',
1341
-                    'text' => $matches[0][0],
1342
-                    'attributes' => array(
1343
-                        'href' => $matches[0][0],
1344
-                    ),
1345
-                ),
1346
-            );
1347
-
1348
-            return $Inline;
1349
-        }
1350
-    }
1351
-
1352
-    protected function inlineUrlTag($Excerpt)
1353
-    {
1354
-        if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
1355
-        {
1356
-            $url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[1]);
1357
-
1358
-            return array(
1359
-                'extent' => strlen($matches[0]),
1360
-                'element' => array(
1361
-                    'name' => 'a',
1362
-                    'text' => $url,
1363
-                    'attributes' => array(
1364
-                        'href' => $url,
1365
-                    ),
1366
-                ),
1367
-            );
1368
-        }
1369
-    }
1370
-
1371
-    # ~
1372
-
1373
-    protected function unmarkedText($text)
1374
-    {
1375
-        if ($this->breaksEnabled)
1376
-        {
1377
-            $text = preg_replace('/[ ]*\n/', "<br />\n", $text);
1378
-        }
1379
-        else
1380
-        {
1381
-            $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
1382
-            $text = str_replace(" \n", "\n", $text);
1383
-        }
1384
-
1385
-        return $text;
1386
-    }
1387
-
1388
-    #
1389
-    # Handlers
1390
-    #
1391
-
1392
-    protected function element(array $Element)
1393
-    {
1394
-        $markup = '<'.$Element['name'];
1395
-
1396
-        if (isset($Element['attributes']))
1397
-        {
1398
-            foreach ($Element['attributes'] as $name => $value)
1399
-            {
1400
-                if ($value === null)
1401
-                {
1402
-                    continue;
1403
-                }
1404
-
1405
-                $markup .= ' '.$name.'="'.$value.'"';
1406
-            }
1407
-        }
1408
-
1409
-        if (isset($Element['text']))
1410
-        {
1411
-            $markup .= '>';
1412
-
1413
-            if (isset($Element['handler']))
1414
-            {
1415
-                $markup .= $this->{$Element['handler']}($Element['text']);
1416
-            }
1417
-            else
1418
-            {
1419
-                $markup .= $Element['text'];
1420
-            }
1421
-
1422
-            $markup .= '</'.$Element['name'].'>';
1423
-        }
1424
-        else
1425
-        {
1426
-            $markup .= ' />';
1427
-        }
1428
-
1429
-        return $markup;
1430
-    }
1431
-
1432
-    protected function elements(array $Elements)
1433
-    {
1434
-        $markup = '';
1435
-
1436
-        foreach ($Elements as $Element)
1437
-        {
1438
-            $markup .= "\n" . $this->element($Element);
1439
-        }
1440
-
1441
-        $markup .= "\n";
1442
-
1443
-        return $markup;
1444
-    }
1445
-
1446
-    # ~
1447
-
1448
-    protected function li($lines)
1449
-    {
1450
-        $markup = $this->lines($lines);
1451
-
1452
-        $trimmedMarkup = trim($markup);
1453
-
1454
-        if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1455
-        {
1456
-            $markup = $trimmedMarkup;
1457
-            $markup = substr($markup, 3);
1458
-
1459
-            $position = strpos($markup, "</p>");
1460
-
1461
-            $markup = substr_replace($markup, '', $position, 4);
1462
-        }
1463
-
1464
-        return $markup;
1465
-    }
1466
-
1467
-    #
1468
-    # Deprecated Methods
1469
-    #
1470
-
1471
-    function parse($text)
1472
-    {
1473
-        $markup = $this->text($text);
1474
-
1475
-        return $markup;
1476
-    }
1477
-
1478
-    #
1479
-    # Static Methods
1480
-    #
1481
-
1482
-    static function instance($name = 'default')
1483
-    {
1484
-        if (isset(self::$instances[$name]))
1485
-        {
1486
-            return self::$instances[$name];
1487
-        }
1488
-
1489
-        $instance = new static();
1490
-
1491
-        self::$instances[$name] = $instance;
1492
-
1493
-        return $instance;
1494
-    }
986
+	#
987
+	# ~
988
+	#
989
+
990
+	public function line($text)
991
+	{
992
+		$markup = '';
993
+
994
+		# $excerpt is based on the first occurrence of a marker
995
+
996
+		while ($excerpt = strpbrk($text, $this->inlineMarkerList))
997
+		{
998
+			$marker = $excerpt[0];
999
+
1000
+			$markerPosition = strpos($text, $marker);
1001
+
1002
+			$Excerpt = array('text' => $excerpt, 'context' => $text);
1003
+
1004
+			foreach ($this->InlineTypes[$marker] as $inlineType)
1005
+			{
1006
+				$Inline = $this->{'inline'.$inlineType}($Excerpt);
1007
+
1008
+				if ( ! isset($Inline))
1009
+				{
1010
+					continue;
1011
+				}
1012
+
1013
+				# makes sure that the inline belongs to "our" marker
1014
+
1015
+				if (isset($Inline['position']) and $Inline['position'] > $markerPosition)
1016
+				{
1017
+					continue;
1018
+				}
1019
+
1020
+				# sets a default inline position
1021
+
1022
+				if ( ! isset($Inline['position']))
1023
+				{
1024
+					$Inline['position'] = $markerPosition;
1025
+				}
1026
+
1027
+				# the text that comes before the inline
1028
+				$unmarkedText = substr($text, 0, $Inline['position']);
1029
+
1030
+				# compile the unmarked text
1031
+				$markup .= $this->unmarkedText($unmarkedText);
1032
+
1033
+				# compile the inline
1034
+				$markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
1035
+
1036
+				# remove the examined text
1037
+				$text = substr($text, $Inline['position'] + $Inline['extent']);
1038
+
1039
+				continue 2;
1040
+			}
1041
+
1042
+			# the marker does not belong to an inline
1043
+
1044
+			$unmarkedText = substr($text, 0, $markerPosition + 1);
1045
+
1046
+			$markup .= $this->unmarkedText($unmarkedText);
1047
+
1048
+			$text = substr($text, $markerPosition + 1);
1049
+		}
1050
+
1051
+		$markup .= $this->unmarkedText($text);
1052
+
1053
+		return $markup;
1054
+	}
1055
+
1056
+	#
1057
+	# ~
1058
+	#
1059
+
1060
+	protected function inlineCode($Excerpt)
1061
+	{
1062
+		$marker = $Excerpt['text'][0];
1063
+
1064
+		if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(?<!'.$marker.')\1(?!'.$marker.')/s', $Excerpt['text'], $matches))
1065
+		{
1066
+			$text = $matches[2];
1067
+			$text = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
1068
+			$text = preg_replace("/[ ]*\n/", ' ', $text);
1069
+
1070
+			return array(
1071
+				'extent' => strlen($matches[0]),
1072
+				'element' => array(
1073
+					'name' => 'code',
1074
+					'text' => $text,
1075
+				),
1076
+			);
1077
+		}
1078
+	}
1079
+
1080
+	protected function inlineEmailTag($Excerpt)
1081
+	{
1082
+		if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
1083
+		{
1084
+			$url = $matches[1];
1085
+
1086
+			if ( ! isset($matches[2]))
1087
+			{
1088
+				$url = 'mailto:' . $url;
1089
+			}
1090
+
1091
+			return array(
1092
+				'extent' => strlen($matches[0]),
1093
+				'element' => array(
1094
+					'name' => 'a',
1095
+					'text' => $matches[1],
1096
+					'attributes' => array(
1097
+						'href' => $url,
1098
+					),
1099
+				),
1100
+			);
1101
+		}
1102
+	}
1103
+
1104
+	protected function inlineEmphasis($Excerpt)
1105
+	{
1106
+		if ( ! isset($Excerpt['text'][1]))
1107
+		{
1108
+			return;
1109
+		}
1110
+
1111
+		$marker = $Excerpt['text'][0];
1112
+
1113
+		if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
1114
+		{
1115
+			$emphasis = 'strong';
1116
+		}
1117
+		elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1118
+		{
1119
+			$emphasis = 'em';
1120
+		}
1121
+		else
1122
+		{
1123
+			return;
1124
+		}
1125
+
1126
+		return array(
1127
+			'extent' => strlen($matches[0]),
1128
+			'element' => array(
1129
+				'name' => $emphasis,
1130
+				'handler' => 'line',
1131
+				'text' => $matches[1],
1132
+			),
1133
+		);
1134
+	}
1135
+
1136
+	protected function inlineEscapeSequence($Excerpt)
1137
+	{
1138
+		if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
1139
+		{
1140
+			return array(
1141
+				'markup' => $Excerpt['text'][1],
1142
+				'extent' => 2,
1143
+			);
1144
+		}
1145
+	}
1146
+
1147
+	protected function inlineImage($Excerpt)
1148
+	{
1149
+		if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1150
+		{
1151
+			return;
1152
+		}
1153
+
1154
+		$Excerpt['text']= substr($Excerpt['text'], 1);
1155
+
1156
+		$Link = $this->inlineLink($Excerpt);
1157
+
1158
+		if ($Link === null)
1159
+		{
1160
+			return;
1161
+		}
1162
+
1163
+		$Inline = array(
1164
+			'extent' => $Link['extent'] + 1,
1165
+			'element' => array(
1166
+				'name' => 'img',
1167
+				'attributes' => array(
1168
+					'src' => $Link['element']['attributes']['href'],
1169
+					'alt' => $Link['element']['text'],
1170
+				),
1171
+			),
1172
+		);
1173
+
1174
+		$Inline['element']['attributes'] += $Link['element']['attributes'];
1175
+
1176
+		unset($Inline['element']['attributes']['href']);
1177
+
1178
+		return $Inline;
1179
+	}
1180
+
1181
+	protected function inlineLink($Excerpt)
1182
+	{
1183
+		$Element = array(
1184
+			'name' => 'a',
1185
+			'handler' => 'line',
1186
+			'text' => null,
1187
+			'attributes' => array(
1188
+				'href' => null,
1189
+				'title' => null,
1190
+			),
1191
+		);
1192
+
1193
+		$extent = 0;
1194
+
1195
+		$remainder = $Excerpt['text'];
1196
+
1197
+		if (preg_match('/\[((?:[^][]|(?R))*)\]/', $remainder, $matches))
1198
+		{
1199
+			$Element['text'] = $matches[1];
1200
+
1201
+			$extent += strlen($matches[0]);
1202
+
1203
+			$remainder = substr($remainder, $extent);
1204
+		}
1205
+		else
1206
+		{
1207
+			return;
1208
+		}
1209
+
1210
+		if (preg_match('/^[(]((?:[^ ()]|[(][^ )]+[)])+)(?:[ ]+("[^"]*"|\'[^\']*\'))?[)]/', $remainder, $matches))
1211
+		{
1212
+			$Element['attributes']['href'] = $matches[1];
1213
+
1214
+			if (isset($matches[2]))
1215
+			{
1216
+				$Element['attributes']['title'] = substr($matches[2], 1, - 1);
1217
+			}
1218
+
1219
+			$extent += strlen($matches[0]);
1220
+		}
1221
+		else
1222
+		{
1223
+			if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
1224
+			{
1225
+				$definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
1226
+				$definition = strtolower($definition);
1227
+
1228
+				$extent += strlen($matches[0]);
1229
+			}
1230
+			else
1231
+			{
1232
+				$definition = strtolower($Element['text']);
1233
+			}
1234
+
1235
+			if ( ! isset($this->DefinitionData['Reference'][$definition]))
1236
+			{
1237
+				return;
1238
+			}
1239
+
1240
+			$Definition = $this->DefinitionData['Reference'][$definition];
1241
+
1242
+			$Element['attributes']['href'] = $Definition['url'];
1243
+			$Element['attributes']['title'] = $Definition['title'];
1244
+		}
1245
+
1246
+		$Element['attributes']['href'] = str_replace(array('&', '<'), array('&amp;', '&lt;'), $Element['attributes']['href']);
1247
+
1248
+		return array(
1249
+			'extent' => $extent,
1250
+			'element' => $Element,
1251
+		);
1252
+	}
1253
+
1254
+	protected function inlineMarkup($Excerpt)
1255
+	{
1256
+		if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false)
1257
+		{
1258
+			return;
1259
+		}
1260
+
1261
+		if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w*[ ]*>/s', $Excerpt['text'], $matches))
1262
+		{
1263
+			return array(
1264
+				'markup' => $matches[0],
1265
+				'extent' => strlen($matches[0]),
1266
+			);
1267
+		}
1268
+
1269
+		if ($Excerpt['text'][1] === '!' and preg_match('/^<!---?[^>-](?:-?[^-])*-->/s', $Excerpt['text'], $matches))
1270
+		{
1271
+			return array(
1272
+				'markup' => $matches[0],
1273
+				'extent' => strlen($matches[0]),
1274
+			);
1275
+		}
1276
+
1277
+		if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches))
1278
+		{
1279
+			return array(
1280
+				'markup' => $matches[0],
1281
+				'extent' => strlen($matches[0]),
1282
+			);
1283
+		}
1284
+	}
1285
+
1286
+	protected function inlineSpecialCharacter($Excerpt)
1287
+	{
1288
+		if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1289
+		{
1290
+			return array(
1291
+				'markup' => '&amp;',
1292
+				'extent' => 1,
1293
+			);
1294
+		}
1295
+
1296
+		$SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot');
1297
+
1298
+		if (isset($SpecialCharacter[$Excerpt['text'][0]]))
1299
+		{
1300
+			return array(
1301
+				'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';',
1302
+				'extent' => 1,
1303
+			);
1304
+		}
1305
+	}
1306
+
1307
+	protected function inlineStrikethrough($Excerpt)
1308
+	{
1309
+		if ( ! isset($Excerpt['text'][1]))
1310
+		{
1311
+			return;
1312
+		}
1313
+
1314
+		if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
1315
+		{
1316
+			return array(
1317
+				'extent' => strlen($matches[0]),
1318
+				'element' => array(
1319
+					'name' => 'del',
1320
+					'text' => $matches[1],
1321
+					'handler' => 'line',
1322
+				),
1323
+			);
1324
+		}
1325
+	}
1326
+
1327
+	protected function inlineUrl($Excerpt)
1328
+	{
1329
+		if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1330
+		{
1331
+			return;
1332
+		}
1333
+
1334
+		if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
1335
+		{
1336
+			$Inline = array(
1337
+				'extent' => strlen($matches[0][0]),
1338
+				'position' => $matches[0][1],
1339
+				'element' => array(
1340
+					'name' => 'a',
1341
+					'text' => $matches[0][0],
1342
+					'attributes' => array(
1343
+						'href' => $matches[0][0],
1344
+					),
1345
+				),
1346
+			);
1347
+
1348
+			return $Inline;
1349
+		}
1350
+	}
1351
+
1352
+	protected function inlineUrlTag($Excerpt)
1353
+	{
1354
+		if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
1355
+		{
1356
+			$url = str_replace(array('&', '<'), array('&amp;', '&lt;'), $matches[1]);
1357
+
1358
+			return array(
1359
+				'extent' => strlen($matches[0]),
1360
+				'element' => array(
1361
+					'name' => 'a',
1362
+					'text' => $url,
1363
+					'attributes' => array(
1364
+						'href' => $url,
1365
+					),
1366
+				),
1367
+			);
1368
+		}
1369
+	}
1370
+
1371
+	# ~
1372
+
1373
+	protected function unmarkedText($text)
1374
+	{
1375
+		if ($this->breaksEnabled)
1376
+		{
1377
+			$text = preg_replace('/[ ]*\n/', "<br />\n", $text);
1378
+		}
1379
+		else
1380
+		{
1381
+			$text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
1382
+			$text = str_replace(" \n", "\n", $text);
1383
+		}
1384
+
1385
+		return $text;
1386
+	}
1387
+
1388
+	#
1389
+	# Handlers
1390
+	#
1391
+
1392
+	protected function element(array $Element)
1393
+	{
1394
+		$markup = '<'.$Element['name'];
1395
+
1396
+		if (isset($Element['attributes']))
1397
+		{
1398
+			foreach ($Element['attributes'] as $name => $value)
1399
+			{
1400
+				if ($value === null)
1401
+				{
1402
+					continue;
1403
+				}
1404
+
1405
+				$markup .= ' '.$name.'="'.$value.'"';
1406
+			}
1407
+		}
1408
+
1409
+		if (isset($Element['text']))
1410
+		{
1411
+			$markup .= '>';
1412
+
1413
+			if (isset($Element['handler']))
1414
+			{
1415
+				$markup .= $this->{$Element['handler']}($Element['text']);
1416
+			}
1417
+			else
1418
+			{
1419
+				$markup .= $Element['text'];
1420
+			}
1421
+
1422
+			$markup .= '</'.$Element['name'].'>';
1423
+		}
1424
+		else
1425
+		{
1426
+			$markup .= ' />';
1427
+		}
1428
+
1429
+		return $markup;
1430
+	}
1431
+
1432
+	protected function elements(array $Elements)
1433
+	{
1434
+		$markup = '';
1435
+
1436
+		foreach ($Elements as $Element)
1437
+		{
1438
+			$markup .= "\n" . $this->element($Element);
1439
+		}
1440
+
1441
+		$markup .= "\n";
1442
+
1443
+		return $markup;
1444
+	}
1445
+
1446
+	# ~
1447
+
1448
+	protected function li($lines)
1449
+	{
1450
+		$markup = $this->lines($lines);
1451
+
1452
+		$trimmedMarkup = trim($markup);
1453
+
1454
+		if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1455
+		{
1456
+			$markup = $trimmedMarkup;
1457
+			$markup = substr($markup, 3);
1458
+
1459
+			$position = strpos($markup, "</p>");
1460
+
1461
+			$markup = substr_replace($markup, '', $position, 4);
1462
+		}
1463
+
1464
+		return $markup;
1465
+	}
1466
+
1467
+	#
1468
+	# Deprecated Methods
1469
+	#
1470
+
1471
+	function parse($text)
1472
+	{
1473
+		$markup = $this->text($text);
1474
+
1475
+		return $markup;
1476
+	}
1477
+
1478
+	#
1479
+	# Static Methods
1480
+	#
1481
+
1482
+	static function instance($name = 'default')
1483
+	{
1484
+		if (isset(self::$instances[$name]))
1485
+		{
1486
+			return self::$instances[$name];
1487
+		}
1488
+
1489
+		$instance = new static();
1490
+
1491
+		self::$instances[$name] = $instance;
1492
+
1493
+		return $instance;
1494
+	}
1495 1495
 
1496
-    private static $instances = array();
1497
-
1498
-    #
1499
-    # Fields
1500
-    #
1496
+	private static $instances = array();
1497
+
1498
+	#
1499
+	# Fields
1500
+	#
1501 1501
 
1502
-    protected $DefinitionData;
1502
+	protected $DefinitionData;
1503 1503
 
1504
-    #
1505
-    # Read-Only
1504
+	#
1505
+	# Read-Only
1506 1506
 
1507
-    protected $specialCharacters = array(
1508
-        '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|',
1509
-    );
1507
+	protected $specialCharacters = array(
1508
+		'\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|',
1509
+	);
1510 1510
 
1511
-    protected $StrongRegex = array(
1512
-        '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s',
1513
-        '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us',
1514
-    );
1511
+	protected $StrongRegex = array(
1512
+		'*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s',
1513
+		'_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us',
1514
+	);
1515 1515
 
1516
-    protected $EmRegex = array(
1517
-        '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
1518
-        '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
1519
-    );
1516
+	protected $EmRegex = array(
1517
+		'*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
1518
+		'_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
1519
+	);
1520 1520
 
1521
-    protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?';
1521
+	protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?';
1522 1522
 
1523
-    protected $voidElements = array(
1524
-        'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
1525
-    );
1523
+	protected $voidElements = array(
1524
+		'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
1525
+	);
1526 1526
 
1527
-    protected $textLevelElements = array(
1528
-        'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1529
-        'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1530
-        'i', 'rp', 'del', 'code',          'strike', 'marquee',
1531
-        'q', 'rt', 'ins', 'font',          'strong',
1532
-        's', 'tt', 'sub', 'mark',
1533
-        'u', 'xm', 'sup', 'nobr',
1534
-                   'var', 'ruby',
1535
-                   'wbr', 'span',
1536
-                          'time',
1537
-    );
1527
+	protected $textLevelElements = array(
1528
+		'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1529
+		'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1530
+		'i', 'rp', 'del', 'code',          'strike', 'marquee',
1531
+		'q', 'rt', 'ins', 'font',          'strong',
1532
+		's', 'tt', 'sub', 'mark',
1533
+		'u', 'xm', 'sup', 'nobr',
1534
+				   'var', 'ruby',
1535
+				   'wbr', 'span',
1536
+						  'time',
1537
+	);
1538 1538
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
             while (isset($line[$indent]) and $line[$indent] === ' ')
154 154
             {
155
-                $indent ++;
155
+                $indent++;
156 156
             }
157 157
 
158 158
             $text = $indent > 0 ? substr($line, $indent) : $line;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             {
195 195
                 foreach ($this->BlockTypes[$marker] as $blockType)
196 196
                 {
197
-                    $blockTypes []= $blockType;
197
+                    $blockTypes [] = $blockType;
198 198
                 }
199 199
             }
200 200
 
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                 {
210 210
                     $Block['type'] = $blockType;
211 211
 
212
-                    if ( ! isset($Block['identified']))
212
+                    if (!isset($Block['identified']))
213 213
                     {
214
-                        $Blocks []= $CurrentBlock;
214
+                        $Blocks [] = $CurrentBlock;
215 215
 
216 216
                         $Block['identified'] = true;
217 217
                     }
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 
230 230
             # ~
231 231
 
232
-            if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
232
+            if (isset($CurrentBlock) and !isset($CurrentBlock['type']) and !isset($CurrentBlock['interrupted']))
233 233
             {
234 234
                 $CurrentBlock['element']['text'] .= "\n".$text;
235 235
             }
236 236
             else
237 237
             {
238
-                $Blocks []= $CurrentBlock;
238
+                $Blocks [] = $CurrentBlock;
239 239
 
240 240
                 $CurrentBlock = $this->paragraph($Line);
241 241
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
         # ~
254 254
 
255
-        $Blocks []= $CurrentBlock;
255
+        $Blocks [] = $CurrentBlock;
256 256
 
257 257
         unset($Blocks[0]);
258 258
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
     protected function blockCode($Line, $Block = null)
295 295
     {
296
-        if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
296
+        if (isset($Block) and !isset($Block['type']) and !isset($Block['interrupted']))
297 297
         {
298 298
             return;
299 299
         }
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             return;
382 382
         }
383 383
 
384
-        $Block['markup'] .= "\n" . $Line['body'];
384
+        $Block['markup'] .= "\n".$Line['body'];
385 385
 
386 386
         if (preg_match('/-->$/', $Line['text']))
387 387
         {
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             return $Block;
449 449
         }
450 450
 
451
-        $Block['element']['text']['text'] .= "\n".$Line['body'];;
451
+        $Block['element']['text']['text'] .= "\n".$Line['body']; ;
452 452
 
453 453
         return $Block;
454 454
     }
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
             while (isset($Line['text'][$level]) and $Line['text'][$level] === '#')
477 477
             {
478
-                $level ++;
478
+                $level++;
479 479
             }
480 480
 
481 481
             if ($level > 6)
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
             $Block = array(
489 489
                 'element' => array(
490
-                    'name' => 'h' . min(6, $level),
490
+                    'name' => 'h'.min(6, $level),
491 491
                     'text' => $text,
492 492
                     'handler' => 'line',
493 493
                 ),
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 ),
524 524
             );
525 525
 
526
-            $Block['element']['text'] []= & $Block['li'];
526
+            $Block['element']['text'] [] = & $Block['li'];
527 527
 
528 528
             return $Block;
529 529
         }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
         {
536 536
             if (isset($Block['interrupted']))
537 537
             {
538
-                $Block['li']['text'] []= '';
538
+                $Block['li']['text'] [] = '';
539 539
 
540 540
                 unset($Block['interrupted']);
541 541
             }
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
                 ),
553 553
             );
554 554
 
555
-            $Block['element']['text'] []= & $Block['li'];
555
+            $Block['element']['text'] [] = & $Block['li'];
556 556
 
557 557
             return $Block;
558 558
         }
@@ -562,22 +562,22 @@  discard block
 block discarded – undo
562 562
             return $Block;
563 563
         }
564 564
 
565
-        if ( ! isset($Block['interrupted']))
565
+        if (!isset($Block['interrupted']))
566 566
         {
567 567
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
568 568
 
569
-            $Block['li']['text'] []= $text;
569
+            $Block['li']['text'] [] = $text;
570 570
 
571 571
             return $Block;
572 572
         }
573 573
 
574 574
         if ($Line['indent'] > 0)
575 575
         {
576
-            $Block['li']['text'] []= '';
576
+            $Block['li']['text'] [] = '';
577 577
 
578 578
             $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']);
579 579
 
580
-            $Block['li']['text'] []= $text;
580
+            $Block['li']['text'] [] = $text;
581 581
 
582 582
             unset($Block['interrupted']);
583 583
 
@@ -610,19 +610,19 @@  discard block
 block discarded – undo
610 610
         {
611 611
             if (isset($Block['interrupted']))
612 612
             {
613
-                $Block['element']['text'] []= '';
613
+                $Block['element']['text'] [] = '';
614 614
 
615 615
                 unset($Block['interrupted']);
616 616
             }
617 617
 
618
-            $Block['element']['text'] []= $matches[1];
618
+            $Block['element']['text'] [] = $matches[1];
619 619
 
620 620
             return $Block;
621 621
         }
622 622
 
623
-        if ( ! isset($Block['interrupted']))
623
+        if (!isset($Block['interrupted']))
624 624
         {
625
-            $Block['element']['text'] []= $Line['text'];
625
+            $Block['element']['text'] [] = $Line['text'];
626 626
 
627 627
             return $Block;
628 628
         }
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 
651 651
     protected function blockSetextHeader($Line, array $Block = null)
652 652
     {
653
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
653
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
654 654
         {
655 655
             return;
656 656
         }
@@ -727,14 +727,14 @@  discard block
 block discarded – undo
727 727
 
728 728
         if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
729 729
         {
730
-            $Block['depth'] ++;
730
+            $Block['depth']++;
731 731
         }
732 732
 
733 733
         if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
734 734
         {
735 735
             if ($Block['depth'] > 0)
736 736
             {
737
-                $Block['depth'] --;
737
+                $Block['depth']--;
738 738
             }
739 739
             else
740 740
             {
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 
789 789
     protected function blockTable($Line, array $Block = null)
790 790
     {
791
-        if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
791
+        if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
792 792
         {
793 793
             return;
794 794
         }
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
                     $alignment = $alignment === 'left' ? 'center' : 'right';
826 826
                 }
827 827
 
828
-                $alignments []= $alignment;
828
+                $alignments [] = $alignment;
829 829
             }
830 830
 
831 831
             # ~
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
                     );
859 859
                 }
860 860
 
861
-                $HeaderElements []= $HeaderElement;
861
+                $HeaderElements [] = $HeaderElement;
862 862
             }
863 863
 
864 864
             # ~
@@ -872,18 +872,18 @@  discard block
 block discarded – undo
872 872
                 ),
873 873
             );
874 874
 
875
-            $Block['element']['text'] []= array(
875
+            $Block['element']['text'] [] = array(
876 876
                 'name' => 'thead',
877 877
                 'handler' => 'elements',
878 878
             );
879 879
 
880
-            $Block['element']['text'] []= array(
880
+            $Block['element']['text'] [] = array(
881 881
                 'name' => 'tbody',
882 882
                 'handler' => 'elements',
883 883
                 'text' => array(),
884 884
             );
885 885
 
886
-            $Block['element']['text'][0]['text'] []= array(
886
+            $Block['element']['text'][0]['text'] [] = array(
887 887
                 'name' => 'tr',
888 888
                 'handler' => 'elements',
889 889
                 'text' => $HeaderElements,
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
                     );
929 929
                 }
930 930
 
931
-                $Elements []= $Element;
931
+                $Elements [] = $Element;
932 932
             }
933 933
 
934 934
             $Element = array(
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
                 'text' => $Elements,
938 938
             );
939 939
 
940
-            $Block['element']['text'][1]['text'] []= $Element;
940
+            $Block['element']['text'][1]['text'] [] = $Element;
941 941
 
942 942
             return $Block;
943 943
         }
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
             {
1006 1006
                 $Inline = $this->{'inline'.$inlineType}($Excerpt);
1007 1007
 
1008
-                if ( ! isset($Inline))
1008
+                if (!isset($Inline))
1009 1009
                 {
1010 1010
                     continue;
1011 1011
                 }
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 
1020 1020
                 # sets a default inline position
1021 1021
 
1022
-                if ( ! isset($Inline['position']))
1022
+                if (!isset($Inline['position']))
1023 1023
                 {
1024 1024
                     $Inline['position'] = $markerPosition;
1025 1025
                 }
@@ -1083,9 +1083,9 @@  discard block
 block discarded – undo
1083 1083
         {
1084 1084
             $url = $matches[1];
1085 1085
 
1086
-            if ( ! isset($matches[2]))
1086
+            if (!isset($matches[2]))
1087 1087
             {
1088
-                $url = 'mailto:' . $url;
1088
+                $url = 'mailto:'.$url;
1089 1089
             }
1090 1090
 
1091 1091
             return array(
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
     protected function inlineEmphasis($Excerpt)
1105 1105
     {
1106
-        if ( ! isset($Excerpt['text'][1]))
1106
+        if (!isset($Excerpt['text'][1]))
1107 1107
         {
1108 1108
             return;
1109 1109
         }
@@ -1146,12 +1146,12 @@  discard block
 block discarded – undo
1146 1146
 
1147 1147
     protected function inlineImage($Excerpt)
1148 1148
     {
1149
-        if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1149
+        if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
1150 1150
         {
1151 1151
             return;
1152 1152
         }
1153 1153
 
1154
-        $Excerpt['text']= substr($Excerpt['text'], 1);
1154
+        $Excerpt['text'] = substr($Excerpt['text'], 1);
1155 1155
 
1156 1156
         $Link = $this->inlineLink($Excerpt);
1157 1157
 
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
                 $definition = strtolower($Element['text']);
1233 1233
             }
1234 1234
 
1235
-            if ( ! isset($this->DefinitionData['Reference'][$definition]))
1235
+            if (!isset($this->DefinitionData['Reference'][$definition]))
1236 1236
             {
1237 1237
                 return;
1238 1238
             }
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 
1286 1286
     protected function inlineSpecialCharacter($Excerpt)
1287 1287
     {
1288
-        if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
1288
+        if ($Excerpt['text'][0] === '&' and !preg_match('/^&#?\w+;/', $Excerpt['text']))
1289 1289
         {
1290 1290
             return array(
1291 1291
                 'markup' => '&amp;',
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
 
1307 1307
     protected function inlineStrikethrough($Excerpt)
1308 1308
     {
1309
-        if ( ! isset($Excerpt['text'][1]))
1309
+        if (!isset($Excerpt['text'][1]))
1310 1310
         {
1311 1311
             return;
1312 1312
         }
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 
1327 1327
     protected function inlineUrl($Excerpt)
1328 1328
     {
1329
-        if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1329
+        if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
1330 1330
         {
1331 1331
             return;
1332 1332
         }
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 
1436 1436
         foreach ($Elements as $Element)
1437 1437
         {
1438
-            $markup .= "\n" . $this->element($Element);
1438
+            $markup .= "\n".$this->element($Element);
1439 1439
         }
1440 1440
 
1441 1441
         $markup .= "\n";
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 
1452 1452
         $trimmedMarkup = trim($markup);
1453 1453
 
1454
-        if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1454
+        if (!in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '<p>')
1455 1455
         {
1456 1456
             $markup = $trimmedMarkup;
1457 1457
             $markup = substr($markup, 3);
@@ -1527,8 +1527,8 @@  discard block
 block discarded – undo
1527 1527
     protected $textLevelElements = array(
1528 1528
         'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
1529 1529
         'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
1530
-        'i', 'rp', 'del', 'code',          'strike', 'marquee',
1531
-        'q', 'rt', 'ins', 'font',          'strong',
1530
+        'i', 'rp', 'del', 'code', 'strike', 'marquee',
1531
+        'q', 'rt', 'ins', 'font', 'strong',
1532 1532
         's', 'tt', 'sub', 'mark',
1533 1533
         'u', 'xm', 'sup', 'nobr',
1534 1534
                    'var', 'ruby',
Please login to merge, or discard this patch.
Braces   +18 added lines, -26 removed lines patch added patch discarded remove patch
@@ -172,8 +172,7 @@  discard block
 block discarded – undo
172 172
                     $CurrentBlock = $Block;
173 173
 
174 174
                     continue;
175
-                }
176
-                else
175
+                } else
177 176
                 {
178 177
                     if ($this->isBlockCompletable($CurrentBlock['type']))
179 178
                     {
@@ -232,8 +231,7 @@  discard block
 block discarded – undo
232 231
             if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted']))
233 232
             {
234 233
                 $CurrentBlock['element']['text'] .= "\n".$text;
235
-            }
236
-            else
234
+            } else
237 235
             {
238 236
                 $Blocks []= $CurrentBlock;
239 237
 
@@ -700,8 +698,7 @@  discard block
 block discarded – undo
700 698
 
701 699
                     $Block['void'] = true;
702 700
                 }
703
-            }
704
-            else
701
+            } else
705 702
             {
706 703
                 if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
707 704
                 {
@@ -725,18 +722,21 @@  discard block
 block discarded – undo
725 722
             return;
726 723
         }
727 724
 
728
-        if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
725
+        if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) {
726
+        	# open
729 727
         {
730 728
             $Block['depth'] ++;
731 729
         }
730
+        }
732 731
 
733
-        if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
732
+        if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) {
733
+        	# close
734 734
         {
735 735
             if ($Block['depth'] > 0)
736 736
             {
737 737
                 $Block['depth'] --;
738
-            }
739
-            else
738
+        }
739
+            } else
740 740
             {
741 741
                 $Block['closed'] = true;
742 742
             }
@@ -1113,12 +1113,10 @@  discard block
 block discarded – undo
1113 1113
         if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
1114 1114
         {
1115 1115
             $emphasis = 'strong';
1116
-        }
1117
-        elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1116
+        } elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
1118 1117
         {
1119 1118
             $emphasis = 'em';
1120
-        }
1121
-        else
1119
+        } else
1122 1120
         {
1123 1121
             return;
1124 1122
         }
@@ -1201,8 +1199,7 @@  discard block
 block discarded – undo
1201 1199
             $extent += strlen($matches[0]);
1202 1200
 
1203 1201
             $remainder = substr($remainder, $extent);
1204
-        }
1205
-        else
1202
+        } else
1206 1203
         {
1207 1204
             return;
1208 1205
         }
@@ -1217,8 +1214,7 @@  discard block
 block discarded – undo
1217 1214
             }
1218 1215
 
1219 1216
             $extent += strlen($matches[0]);
1220
-        }
1221
-        else
1217
+        } else
1222 1218
         {
1223 1219
             if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
1224 1220
             {
@@ -1226,8 +1222,7 @@  discard block
 block discarded – undo
1226 1222
                 $definition = strtolower($definition);
1227 1223
 
1228 1224
                 $extent += strlen($matches[0]);
1229
-            }
1230
-            else
1225
+            } else
1231 1226
             {
1232 1227
                 $definition = strtolower($Element['text']);
1233 1228
             }
@@ -1375,8 +1370,7 @@  discard block
 block discarded – undo
1375 1370
         if ($this->breaksEnabled)
1376 1371
         {
1377 1372
             $text = preg_replace('/[ ]*\n/', "<br />\n", $text);
1378
-        }
1379
-        else
1373
+        } else
1380 1374
         {
1381 1375
             $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $text);
1382 1376
             $text = str_replace(" \n", "\n", $text);
@@ -1413,15 +1407,13 @@  discard block
 block discarded – undo
1413 1407
             if (isset($Element['handler']))
1414 1408
             {
1415 1409
                 $markup .= $this->{$Element['handler']}($Element['text']);
1416
-            }
1417
-            else
1410
+            } else
1418 1411
             {
1419 1412
                 $markup .= $Element['text'];
1420 1413
             }
1421 1414
 
1422 1415
             $markup .= '</'.$Element['name'].'>';
1423
-        }
1424
-        else
1416
+        } else
1425 1417
         {
1426 1418
             $markup .= ' />';
1427 1419
         }
Please login to merge, or discard this patch.