瀏覽代碼

dokuwiki-exporter:
- reduce number of ’\n’ in output of exporter
_ unsupported block are exported like source

Travis 9 年之前
父節點
當前提交
a8d86b9a0b
共有 1 個文件被更改,包括 21 次插入22 次删除
  1. 21 22
      src/dokuwiki/lib/plugins/asciidoc/renderer.php

+ 21 - 22
src/dokuwiki/lib/plugins/asciidoc/renderer.php

@@ -180,11 +180,11 @@ class renderer_plugin_asciidoc extends Doku_Renderer {
 
     function p_close() {
         $this->_closeTags($this, __FUNCTION__);
-        $this->doc .= DOKU_LF.DOKU_LF;
+        if ($this->doc[-1] != DOKU_LF) $this->doc .= DOKU_LF;
     }
 
     function linebreak() {
-        $this->doc .= '+'.DOKU_LF;
+        $this->doc .= '+';
     }
 
     function hr() {
@@ -320,34 +320,33 @@ class renderer_plugin_asciidoc extends Doku_Renderer {
         $this->doc .= '+++';
     }
 
+    function unsupportedblock($text, $kind) {
+        fwrite(STDERR, "unsupportedblock:'". $kind ."' text: '". var_export($text, TRUE) ."'\n");
+        $this->code($text, $kind);
+    }
+
     function php($text) {
-        $this->doc .= '<php>';
-        $this->doc .= $this->_xmlEntities($text);
-        $this->doc .= '</php>';
+        $this->unsupportedblock($text, 'php');
     }
 
     function phpblock($text) {
-        $this->doc .= '<phpblock>';
-        $this->doc .= $this->_xmlEntities($text);
-        $this->doc .= '</phpblock>'.DOKU_LF;
+        $this->unsupportedblock($text, 'phpblock');
     }
 
     function html($text) {
-        $this->doc .= '<html>';
-        $this->doc .= $this->_xmlEntities($text);
-        $this->doc .= '</html>';
+        $this->unsupportedblock($text, 'html');
     }
 
     function htmlblock($text) {
-        $this->doc .= '<htmlblock>';
-        $this->doc .= $this->_xmlEntities($text);
-        $this->doc .= '</htmlblock>'.DOKU_LF;
+        $this->unsupportedblock($text, 'htmlblock');
     }
 
     function preformatted($text) {
-      $this->doc .= DOKU_LF.'....'.DOKU_LF;
+      if ($this->doc[-1] != DOKU_LF) $this->doc .= DOKU_LF;
+      $this->doc .= '....'.DOKU_LF;
       $this->doc .= $text;
-      $this->doc .= DOKU_LF.'....'.DOKU_LF;
+      if ($text[-1] != DOKU_LF) $this->doc .= DOKU_LF;
+      $this->doc .= '....'.DOKU_LF;
     }
 
     function quote_open() {
@@ -357,24 +356,24 @@ class renderer_plugin_asciidoc extends Doku_Renderer {
 
     function quote_close() {
         $this->_closeTags($this, __FUNCTION__);
-        $this->doc .= DOKU_LF.'____'.DOKU_LF;
+        if ($this->doc[-1] != DOKU_LF) $this->doc .= DOKU_LF;
+        $this->doc .= '____'.DOKU_LF;
     }
 
     function code($text, $lang = null, $file = null) {
-      $this->doc .= DOKU_LF.'[source';
+      if ($this->doc[-1] != DOKU_LF) $this->doc .= DOKU_LF;
+      $this->doc .= '[source';
       if ($lang != null) $this->doc .= ',' . $lang;
       $this->doc .= ']';
       if ($file != null) $this->doc .= DOKU_LF.'.' . $file;
       $this->doc .= DOKU_LF.'----'.DOKU_LF;
       $this->doc .= $text;
-      $this->doc .= DOKU_LF.'----'.DOKU_LF;
+      if ($text[-1] != DOKU_LF) $this->doc .= DOKU_LF;
+      $this->doc .= '----'.DOKU_LF;
     }
 
     function file($text, $lang = null, $file = null) {
       $this->code($text, $lang, $file);
-        // $this->doc .= '<file lang="' . $lang . '" file="' . $file . '">';
-        // $this->doc .= $this->_xmlEntities($text);
-        // $this->doc .= '</file>'.DOKU_LF;
     }
 
     function acronym($acronym) {