ソースを参照

dokuwiki-exporter: use a map to fix the headers levelling issue in source

Travis 9 年 前
コミット
fde5eca2b2
1 ファイル変更12 行追加5 行削除
  1. 12 5
      src/dokuwiki/lib/plugins/asciidoc/renderer.php

+ 12 - 5
src/dokuwiki/lib/plugins/asciidoc/renderer.php

@@ -39,6 +39,8 @@ class renderer_plugin_asciidoc extends Doku_Renderer {
         $this->listKindStack      = array();
         $this->quoteStack      = array();
         $this->relfileprefix = '';
+        $this->levelMap = array();
+        $this->levelMaxReached = 1;
 
         $this->smiley_to_emoticon = array(
           '>:(' => 'angry', '>:-(' => 'angry',
@@ -134,12 +136,17 @@ class renderer_plugin_asciidoc extends Doku_Renderer {
     }
 
     function header($text, $level, $pos) {
-      //echo "header :" . $level . " // " . $this->sectionlevel . "\n";
         if (!$text) return; //skip empty headlines
         if ($level == 1 && empty($this->doctitle)) {
-            $this->doctitle = $text;
+          $this->doctitle = $text;
         } else {
-            $this->doc .= DOKU_LF . DOKU_LF . str_repeat("=", $level) . ' ' . $text. DOKU_LF;
+          $l = $this->levelMap[$level];
+          if (!$l) {
+            $this->levelMaxReached += 1;
+            $l = $this->levelMaxReached;
+            $this->levelMap[$level] = $l;
+          }
+          $this->doc .= DOKU_LF . DOKU_LF . str_repeat("=", $l) . ' ' . $text. DOKU_LF;
         }
     }
 
@@ -625,7 +632,7 @@ class renderer_plugin_asciidoc extends Doku_Renderer {
         } else {
             $url = $src;
         }
-        
+
         //$out = 'image:' . $url. '['. $name . ',with="'. $width .'",height="'. $height . '",align="' . $align . '", link="'. $linking .'"]';
         if (stripos($url, '.mp4') !== false || stripos($url, '.webm') !== false || stripos($url, '.ogv') !== false) {
           $out = DOKU_LF.'video::' . $url . '[]'.DOKU_LF;
@@ -676,7 +683,7 @@ class renderer_plugin_asciidoc extends Doku_Renderer {
                               $img['height'],
                               $img['cache']);
     }
-    
+
     function _openTag($class, $func, $data=null) {
         $this->tagStack[] = array($class, $func, $data);
     }