Release 0.7.0
[grauphel.git] / lib / converter / html.php
index 29064e5639f2fa66b271b304dd4aee92d0d310a8..c777cadd921425e243a0d15fffdbd695ae2e1195 100644 (file)
@@ -107,7 +107,7 @@ class Html extends Base
                 }
                 break;
             case XMLReader::END_ELEMENT:
-                array_shift($nesting, $reader->name);
+                array_shift($nesting);
                 if (isset(static::$tagMap[$reader->name])) {
                     $store .= '</' . static::$tagMap[$reader->name] . '>';
                 } else if (isset(static::$styleClassMap[$reader->name])) {
@@ -134,6 +134,15 @@ class Html extends Base
                 if ($nesting[0] != 'monospace') {
                     $text = nl2br($text);
                 }
+                $text = preg_replace_callback(
+                    "#^\t+#m",
+                    function ($matches) {
+                        return str_repeat(
+                            '&#160;', strlen($matches[0]) * 8
+                        );
+                    },
+                    $text
+                );
                 $store .= $text;
                 break;
             default: