v5 v6: ao, book index related
authorRalph Amissah <ralph@amissah.com>
Wed, 20 Aug 2014 22:49:24 +0000 (18:49 -0400)
committerRalph Amissah <ralph@amissah.com>
Wed, 20 Aug 2014 22:52:45 +0000 (18:52 -0400)
data/doc/sisu/CHANGELOG_v5
data/doc/sisu/CHANGELOG_v6
lib/sisu/v5/ao_doc_str.rb
lib/sisu/v5/ao_misc_arrange.rb
lib/sisu/v6/ao_doc_str.rb
lib/sisu/v6/ao_misc_arrange.rb

index bd4cd945ae6cf2406a8fda7f352c966135823744..9c79565472bf92c5f91b5ad370dd6df6ef3c127f 100644 (file)
@@ -38,7 +38,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.6.2.orig.tar.xz
   sisu_5.6.2.orig.tar.xz
   sisu_5.6.2-1.dsc
 
-* ao_expand_insertions, blocked text match, adjust
+* ao
+  * book index related
+  * ao_expand_insertions, blocked text match, adjust
 
 * texpdf, output, copyright & license
 
index f7d7997d8be88aaf049376f93eb19bf2834f682b..a1b20529f30c73d1a3173ce9a30f83e1db7546c4 100644 (file)
@@ -28,7 +28,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.2.3.orig.tar.xz
   sisu_6.2.3.orig.tar.xz
   sisu_6.2.3-1.dsc
 
-* ao_expand_insertions, blocked text match, adjust
+* ao
+  * book index related
+  * ao_expand_insertions, blocked text match, adjust
 
 * texpdf, output, copyright & license
 
index d9a7c9f29538bb12228e4ec8cc2eee5ca868aed8..e10cc4ef3bad2198743aede9407514b669a77edd 100644 (file)
@@ -305,6 +305,18 @@ module SiSU_AO_DocumentStructureExtract
           next
         end
         t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off
+        unless t_o =~/^(?:@\S+?:|%+)\s/                  # extract book index for paragraph if any
+          idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m
+            m=$1
+            m=m.split(/[ ]*\n/).join(' ').
+              gsub(/\s+([|:;])\s+/,'\1').
+              gsub(/\s+([+]\d+)\s+/,'\1')
+            t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
+            idx_array_and_hash=construct_idx_array_and_hash(m)
+            idx_array_and_hash[:hash]
+          else nil
+          end
+        end
         if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \
         and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \
         and @@flag[:code]==:off \
@@ -314,17 +326,6 @@ module SiSU_AO_DocumentStructureExtract
         and @@flag[:alt]==:off \
         and @@flag[:box]==:off \
         and @@flag[:table]==:off
-          unless t_o =~/^(?:@\S+?:|%+)\s/                  # extract book index for paragraph if any
-            idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m; m=$1
-              m=m.split(/[ ]*\n/).join(' ').
-                gsub(/\s+([|:;])\s+/,'\1').
-                gsub(/\s+([+]\d+)\s+/,'\1')
-              t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
-              idx_array_and_hash=construct_idx_array_and_hash(m)
-              idx_array_and_hash[:hash]
-            else nil
-            end
-          end
           t_o=case t_o
           when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/                                 #metadata, header
             if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m
@@ -842,14 +843,17 @@ module SiSU_AO_DocumentStructureExtract
           if (@@flag[:code]==:curls \
           && t_o =~/^\}code/) \
           or (@@flag[:code]==:tics \
-          && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+          && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m)
             @@flag[:code]=:off
-            @tuned_code[-1].
-              gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+            if @tuned_code[-1]
+              @tuned_code[-1].
+                gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+            end
             obj=@tuned_code.join("\n")
             tags=[]
             h={
               obj: obj,
+              idx: idx,
               syntax: @@flag[:lngsyn],
               tags: tags,
               num: @num_id[:code_block],
@@ -897,6 +901,7 @@ module SiSU_AO_DocumentStructureExtract
             h={
               is_for: :poem,
               obj: '',
+              idx: idx,
               sym: :poem_close,
               num: @num_id[:poem],
             }
@@ -909,6 +914,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:box],
             }
@@ -918,6 +924,7 @@ module SiSU_AO_DocumentStructureExtract
             h={
               is_for: :box,
               obj: '',
+              idx: idx,
               sym: :box_close,
               num: @num_id[:box],
             }
@@ -930,6 +937,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:group],
             }
@@ -951,6 +959,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:block],
             }
@@ -972,6 +981,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:alt],
             }
@@ -990,6 +1000,7 @@ module SiSU_AO_DocumentStructureExtract
             @@flag[:quote]=:off
             h={
               is_for: :quote,
+              idx: idx,
               obj: '',
               sym: :quote_close,
               num: @num_id[:quote],
index 09842fcc4d5700edd893fc200fb293a5f42c5b72..ab61671c644c59f06091fcecb7d7899371834167 100644 (file)
@@ -98,11 +98,11 @@ module SiSU_AO_MiscArrangeText
           else
             para << block_open
           end
-        elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m \
+        elsif para =~/\A.+?\n```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(\s*=\{.+?\})?\s*\Z/m \
         and @flag==:open
           @flag=:close
           text,block_close=
-            /\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
+            /\A(.+?)\n(```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(?:\s+=\{.+?\})?)\s*\Z/m.match(para)[1,2]
           para=[]
           if not text.to_s.empty?
             para << text.to_s << block_close
index 25735de738dabc13a7a603163e9702037ed4b87c..6e7a103fb067c0e2d76f020515690705960ff354 100644 (file)
@@ -305,6 +305,18 @@ module SiSU_AO_DocumentStructureExtract
           next
         end
         t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off
+        unless t_o =~/^(?:@\S+?:|%+)\s/                  # extract book index for paragraph if any
+          idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m
+            m=$1
+            m=m.split(/[ ]*\n/).join(' ').
+              gsub(/\s+([|:;])\s+/,'\1').
+              gsub(/\s+([+]\d+)\s+/,'\1')
+            t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
+            idx_array_and_hash=construct_idx_array_and_hash(m)
+            idx_array_and_hash[:hash]
+          else nil
+          end
+        end
         if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \
         and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \
         and @@flag[:code]==:off \
@@ -314,17 +326,6 @@ module SiSU_AO_DocumentStructureExtract
         and @@flag[:alt]==:off \
         and @@flag[:box]==:off \
         and @@flag[:table]==:off
-          unless t_o =~/^(?:@\S+?:|%+)\s/                  # extract book index for paragraph if any
-            idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m; m=$1
-              m=m.split(/[ ]*\n/).join(' ').
-                gsub(/\s+([|:;])\s+/,'\1').
-                gsub(/\s+([+]\d+)\s+/,'\1')
-              t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'')
-              idx_array_and_hash=construct_idx_array_and_hash(m)
-              idx_array_and_hash[:hash]
-            else nil
-            end
-          end
           t_o=case t_o
           when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/                                 #metadata, header
             if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m
@@ -842,14 +843,17 @@ module SiSU_AO_DocumentStructureExtract
           if (@@flag[:code]==:curls \
           && t_o =~/^\}code/) \
           or (@@flag[:code]==:tics \
-          && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/)
+          && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m)
             @@flag[:code]=:off
-            @tuned_code[-1].
-              gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+            if @tuned_code[-1]
+              @tuned_code[-1].
+                gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'')
+            end
             obj=@tuned_code.join("\n")
             tags=[]
             h={
               obj: obj,
+              idx: idx,
               syntax: @@flag[:lngsyn],
               tags: tags,
               num: @num_id[:code_block],
@@ -897,6 +901,7 @@ module SiSU_AO_DocumentStructureExtract
             h={
               is_for: :poem,
               obj: '',
+              idx: idx,
               sym: :poem_close,
               num: @num_id[:poem],
             }
@@ -909,6 +914,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:box],
             }
@@ -918,6 +924,7 @@ module SiSU_AO_DocumentStructureExtract
             h={
               is_for: :box,
               obj: '',
+              idx: idx,
               sym: :box_close,
               num: @num_id[:box],
             }
@@ -930,6 +937,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:group],
             }
@@ -951,6 +959,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:block],
             }
@@ -972,6 +981,7 @@ module SiSU_AO_DocumentStructureExtract
             obj,tags=extract_tags(@tuned_block.join("\n"))
             h={
               obj: obj,
+              idx: idx,
               tags: tags,
               num: @num_id[:alt],
             }
@@ -990,6 +1000,7 @@ module SiSU_AO_DocumentStructureExtract
             @@flag[:quote]=:off
             h={
               is_for: :quote,
+              idx: idx,
               obj: '',
               sym: :quote_close,
               num: @num_id[:quote],
index 8adebfd5032a7b813d53d4cc872b39f437c9a704..f1aa1e0206f963491e51b39e1f315a37b723a1a4 100644 (file)
@@ -98,11 +98,11 @@ module SiSU_AO_MiscArrangeText
           else
             para << block_open
           end
-        elsif para =~/\A.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m \
+        elsif para =~/\A.+?\n```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(\s*=\{.+?\})?\s*\Z/m \
         and @flag==:open
           @flag=:close
           text,block_close=
-            /\A(.+?)\n(```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2]
+            /\A(.+?)\n(```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(?:\s+=\{.+?\})?)\s*\Z/m.match(para)[1,2]
           para=[]
           if not text.to_s.empty?
             para << text.to_s << block_close