}
             end
@@ -238,33 +240,41 @@ module SiSU_XML_Docbook_Book
       def structure_build_tag_close(lc,h)
         x=[]
         case h
+        when 0
+          x << "#{space*0}#{tags.docbook(0)}>"       if (lc <= 0)
         when 1
-          x << "#{space*0}#{tags.docbook(1)}>"       if (lc <= 1)
+          x << "#{space*1}#{tags.docbook(1,@chlv)}>" if (lc <= 1)
+          x << "#{space*0}#{tags.docbook(0)}>"       if (lc <= 0)
         when 2
-          x << "#{space*1}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
-          x << "#{space*0}#{tags.docbook(1)}>"       if (lc <= 1)
+          x << "#{space*2}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+          x << "#{space*1}#{tags.docbook(1,@chlv)}>" if (lc <= 1)
+          x << "#{space*0}#{tags.docbook(0)}>"       if (lc <= 0)
         when 3
-          x << "#{space*2}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
-          x << "#{space*1}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
-          x << "#{space*0}#{tags.docbook(1)}>"       if (lc <= 1)
+          x << "#{space*3}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+          x << "#{space*2}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+          x << "#{space*1}#{tags.docbook(1,@chlv)}>" if (lc <= 1)
+          x << "#{space*0}#{tags.docbook(0)}>"       if (lc <= 0)
         when 4
-          x << "#{space*3}#{tags.docbook(4,@chlv)}>" if (lc <= 4)
-          x << "#{space*2}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
-          x << "#{space*1}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
-          x << "#{space*0}#{tags.docbook(1)}>"       if (lc <= 1)
+          x << "#{space*4}#{tags.docbook(4,@chlv)}>" if (lc <= 4)
+          x << "#{space*3}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+          x << "#{space*2}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+          x << "#{space*1}#{tags.docbook(1,@chlv)}>" if (lc <= 1)
+          x << "#{space*0}#{tags.docbook(0)}>"       if (lc <= 0)
         when 5
-          x << "#{space*4}#{tags.docbook(5)}>"       if (lc <= 5)
-          x << "#{space*3}#{tags.docbook(4,@chlv)}>" if (lc <= 4)
-          x << "#{space*2}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
-          x << "#{space*1}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
-          x << "#{space*0}#{tags.docbook(1)}>"       if (lc <= 1)
+          x << "#{space*5}#{tags.docbook(5)}>"       if (lc <= 5)
+          x << "#{space*4}#{tags.docbook(4,@chlv)}>" if (lc <= 4)
+          x << "#{space*5}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+          x << "#{space*2}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+          x << "#{space*1}#{tags.docbook(1,@chlv)}>" if (lc <= 1)
+          x << "#{space*0}#{tags.docbook(0)}>"       if (lc <= 0)
         when 6
-          x << "#{space*5}#{tags.docbook(6)}>"       if (lc <= 6)
-          x << "#{space*4}#{tags.docbook(5)}>"       if (lc <= 5)
-          x << "#{space*3}#{tags.docbook(4,@chlv)}>" if (lc <= 4)
-          x << "#{space*2}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
-          x << "#{space*1}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
-          x << "#{space*0}#{tags.docbook(1)}>"       if (lc <= 1)
+          x << "#{space*6}#{tags.docbook(6)}>"       if (lc <= 6)
+          x << "#{space*5}#{tags.docbook(5)}>"       if (lc <= 5)
+          x << "#{space*4}#{tags.docbook(4,@chlv)}>" if (lc <= 4)
+          x << "#{space*3}#{tags.docbook(3,@chlv)}>" if (lc <= 3)
+          x << "#{space*2}#{tags.docbook(2,@chlv)}>" if (lc <= 2)
+          x << "#{space*1}#{tags.docbook(1,@chlv)}>" if (lc <= 1)
+          x << "#{space*0}#{tags.docbook(0)}>"       if (lc <= 0)
         end
         x.join("\n")
       end
diff --git a/lib/sisu/v5/xml_dom.rb b/lib/sisu/v5/xml_dom.rb
index 22c711d3..c8f3d881 100644
--- a/lib/sisu/v5/xml_dom.rb
+++ b/lib/sisu/v5/xml_dom.rb
@@ -191,11 +191,10 @@ WOK
         n=n1=n2=n3=0
         if dob.is==:heading
           lv=dob.ln
-          n=dob.ln - 1
+          n=dob.ln
           n1=dob.ln
-          n2=dob.ln + 1
-          n3=dob.ln + 2
-          dob.ln - 3
+          n2=dob.ln + 2
+          n3=dob.ln + 3
         else lv=nil
         end
         tag=if defined? dob.name and dob.name=~/\S+/
@@ -374,7 +373,12 @@ WOK
                 format_scroll=SiSU_XML_Format::FormatScroll.new(@md,dob) if dob.is==:para and dob.indent ##FIX
                 x=SiSU_XML_Format::FormatSeg.new(@md,dob)
                 if dob.is==:heading
-                  if dob.ln==1
+                  if dob.ln==0
+                    type="heading_section_#{dob.ln.to_s}"
+                    xml_markup(dob)
+                    xml_structure(dob,type)
+                    dob.obj=x.heading_body0
+                  elsif dob.ln==1
                     type="heading_section_#{dob.ln.to_s}"
                     xml_markup(dob)
                     xml_structure(dob,type)
diff --git a/lib/sisu/v5/xml_fictionbook2.rb b/lib/sisu/v5/xml_fictionbook2.rb
index aeb74ef3..6549fa12 100644
--- a/lib/sisu/v5/xml_fictionbook2.rb
+++ b/lib/sisu/v5/xml_fictionbook2.rb
@@ -132,10 +132,11 @@ module SiSU_XML_Fictionbook
       def tags
         # collapsed -->
         def collapsed
-          %w[ 0 1 2 3 4 5 6 ]
+          %w[ 0 1 2 3 4 5 ]
         end
         def fictionbook
-          [ 'section',
+          [
+            'section',
             'section',
             'section',
             'section',
@@ -313,7 +314,7 @@ module SiSU_XML_Fictionbook
             h=o.lc
           elsif  o.is ==:heading_insert \
           and o.obj =~/Endnotes/ \
-          and o.ln == 2
+          and o.ln == 1
             break
           elsif (o.of ==:para or o.of ==:block)
             filename_fictionbook.puts SiSU_TextUtils::Wrap.new("#{o.obj}#{ocn}
",80,6).line_wrap
@@ -327,26 +328,33 @@ module SiSU_XML_Fictionbook
       def structure_build_tag_close(lc,h)
         x=[]
         case h
+        when 0
+          x << "#{space*0}#{tags.fictionbook[0]}>" if (lc <= 0)
         when 1
           x << "#{space*1}#{tags.fictionbook[1]}>" if (lc <= 1)
+          x << "#{space*0}#{tags.fictionbook[0]}>" if (lc <= 0)
         when 2
           x << "#{space*2}#{tags.fictionbook[2]}>" if (lc <= 2)
           x << "#{space*1}#{tags.fictionbook[1]}>" if (lc <= 1)
+          x << "#{space*0}#{tags.fictionbook[0]}>" if (lc <= 0)
         when 3
           x << "#{space*3}#{tags.fictionbook[3]}>" if (lc <= 3)
           x << "#{space*2}#{tags.fictionbook[2]}>" if (lc <= 2)
           x << "#{space*1}#{tags.fictionbook[1]}>" if (lc <= 1)
+          x << "#{space*0}#{tags.fictionbook[0]}>" if (lc <= 0)
         when 4
           x << "#{space*4}#{tags.fictionbook[4]}>" if (lc <= 4)
           x << "#{space*3}#{tags.fictionbook[3]}>" if (lc <= 3)
           x << "#{space*2}#{tags.fictionbook[2]}>" if (lc <= 2)
           x << "#{space*1}#{tags.fictionbook[1]}>" if (lc <= 1)
+          x << "#{space*0}#{tags.fictionbook[0]}>" if (lc <= 0)
         when 5
           x << "#{space*5}#{tags.fictionbook[5]}>" if (lc <= 5)
           x << "#{space*4}#{tags.fictionbook[4]}>" if (lc <= 4)
           x << "#{space*3}#{tags.fictionbook[3]}>" if (lc <= 3)
           x << "#{space*2}#{tags.fictionbook[2]}>" if (lc <= 2)
           x << "#{space*1}#{tags.fictionbook[1]}>" if (lc <= 1)
+          x << "#{space*0}#{tags.fictionbook[0]}>" if (lc <= 0)
         when 6
           x << "#{space*6}#{tags.fictionbook[6]}>" if (lc <= 6)
           x << "#{space*5}#{tags.fictionbook[5]}>" if (lc <= 5)
@@ -354,6 +362,7 @@ module SiSU_XML_Fictionbook
           x << "#{space*3}#{tags.fictionbook[3]}>" if (lc <= 3)
           x << "#{space*2}#{tags.fictionbook[2]}>" if (lc <= 2)
           x << "#{space*1}#{tags.fictionbook[1]}>" if (lc <= 1)
+          x << "#{space*0}#{tags.fictionbook[0]}>" if (lc <= 0)
         end
         x.join("\n")
       end
diff --git a/lib/sisu/v5/xml_format.rb b/lib/sisu/v5/xml_format.rb
index ada32a39..7694f56b 100644
--- a/lib/sisu/v5/xml_format.rb
+++ b/lib/sisu/v5/xml_format.rb
@@ -298,30 +298,34 @@ WOK
       %{#{@p_num.name}#{@headname}#{@dob.obj} 
} +
       %{  #{@dob.ocn}
\n}
     end
-    def heading_body1
+    def heading_body0
       %{#{@p_num.name}#{@headname}#{@dob.obj}
} +
       %{  #{@dob.ocn}
\n}
     end
-    def heading_body2
+    def heading_body1
       %{#{@p_num.name}#{@headname}#{@dob.obj}
} +
       %{  #{@dob.ocn}
\n}
     end
-    def heading_body3
+    def heading_body2
       %{#{@p_num.name}#{@headname}#{@dob.obj}
} +
       %{  #{@dob.ocn}
\n}
     end
-    def heading_body4
+    def heading_body3
       %{#{@p_num.name}#{@headname}#{@dob.obj}
} +
       %{  #{@dob.ocn}
\n}
     end
-    def heading_body5
+    def heading_body4
       %{#{@p_num.name}#{@headname}#{@dob.obj}
} +
       %{  #{@dob.ocn}
\n}
     end
-    def heading_body6
+    def heading_body5
       %{#{@p_num.name}#{@headname}#{@dob.obj}
} +
       %{  #{@dob.ocn}
\n}
     end
+    def heading_body6
+      %{#{@p_num.name}#{@headname}#{@dob.obj}} +
+      %{  #{@dob.ocn}
\n}
+    end
   end
   class ParagraphNumber
     def initialize(md,ocn)
@@ -1090,6 +1094,9 @@ WOK
     def heading_body
       heading_normal('p','norm')
     end
+    def heading_body0
+      heading_normal('h1','norm')
+    end
     def heading_body1
       heading_normal('h1','norm')
     end
-- 
cgit v1.2.3