From 9ccfd45405e11016bb28fc6d8ff290dff8f5c83d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 25 Aug 2013 01:20:49 -0400 Subject: v4: merge v5, syntax additions, block text related (version bump to 4.2.*) * syntax add * switch ocn off and on for a block of content, line containing only off: "--~#" (omit headings where possible) "---#" on: "--+#" * alternative open and close for blocks using line starting with "```", e.g. open code block: "``` code"; close code block: "```" start poem: "``` poem"; end poem: "```" * remove need for an empty line between opening & closing of a text block [ note further refinements will be required; use of tildes "~~" considered but more problematic, tics not used elsewhere] --- data/doc/sisu/CHANGELOG_v4 | 10 + lib/sisu/v4/dal.rb | 4 +- lib/sisu/v4/dal_doc_objects.rb | 27 +++ lib/sisu/v4/dal_doc_str.rb | 288 +++++++++++++++++------- lib/sisu/v4/dal_expand_insertions.rb | 4 +- lib/sisu/v4/dal_misc_arrange.rb | 155 +++++++++++++ lib/sisu/v4/dal_substitutions_and_insertions.rb | 145 ------------ lib/sisu/v4/dal_syntax.rb | 46 ++-- 8 files changed, 424 insertions(+), 255 deletions(-) create mode 100644 lib/sisu/v4/dal_misc_arrange.rb delete mode 100644 lib/sisu/v4/dal_substitutions_and_insertions.rb diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index fe6577d0..81b5c534 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -30,6 +30,16 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.2.0.orig.tar.xz sisu_4.2.0.orig.tar.xz sisu_4.2.0-1.dsc +* merge v5 + * syntax add + * switch ocn off and on for a block of content, line containing only + off: "--~#" (omit headings where possible) "---#" on: "--+#" + * alternative open and close for blocks using line starting with "```", e.g. + open code block: "``` code"; close code block: "```" + start poem: "``` poem"; end poem: "```" + * remove need for an empty line between opening & closing of a text block + [note use of "~~" considered but more problematic, (tics not used elsewhere)] + * css, html, epub, adjust paragraph spacing, (increase, whitespace aesthetic, review further) diff --git a/lib/sisu/v4/dal.rb b/lib/sisu/v4/dal.rb index 4a158fb6..ca2429b1 100644 --- a/lib/sisu/v4/dal.rb +++ b/lib/sisu/v4/dal.rb @@ -78,7 +78,7 @@ module SiSU_DAL require_relative 'dal_images' # dal_images.rb require_relative 'dal_metadata' # dal_metadata.rb require_relative 'dal_character_check' # dal_character_check.rb - require_relative 'dal_substitutions_and_insertions' # dal_substitutions_and_insertions.rb + require_relative 'dal_misc_arrange' # dal_misc_arrange.rb require_relative 'dal_expand_insertions' # dal_expand_insertions.rb require_relative 'prog_text_translation' # prog_text_translation.rb require_relative 'shared_sem' # shared_sem.rb @@ -479,7 +479,7 @@ module SiSU_DAL reset data=@data data=SiSU_DAL_Insertions::Insertions.new(@md,data).expand_insertions? # dal_expand_insertions.rb - data=SiSU_DAL_SubstituteAndInsert::SI.new(@md,data).substitutions_and_insertions? # dal_substitutions_and_insertions.rb + data=SiSU_DAL_MiscArrangeText::SI.new(@md,data).prepare_text # dal_misc_arrange.rb data,metadata=SiSU_DAL_DocumentStructureExtract::Build.new(@md,data).identify_parts # dal_doc_str.rb data=SiSU_DAL_Syntax::Markup.new(@md,data).songsheet # dal_syntax.rb data,endnote_array=SiSU_DAL_CharacterCheck::Check.new(data).character_check_and_oldstyle_endnote_array # dal_character_check.rb diff --git a/lib/sisu/v4/dal_doc_objects.rb b/lib/sisu/v4/dal_doc_objects.rb index 12441156..8fdd8068 100644 --- a/lib/sisu/v4/dal_doc_objects.rb +++ b/lib/sisu/v4/dal_doc_objects.rb @@ -423,6 +423,33 @@ module SiSU_DAL_DocumentStructure self end end + class ObjectFlag + attr_accessor :obj,:is,:of,:flag,:mod,:tmp + def initialize + @of=:flag + @is=@obj=@flag=@mod=@tmp=nil + end + def flag(h,o=nil) + of= @of #String, classification - group + is= :flag #String, classification - specific type + obj= nil #String, text content + flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content + mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content + tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@obj,@flag,@mod,@tmp=of,is,obj,flag,mod,tmp + self + end + def flag_ocn(h,o=nil) + of= @of #String, classification - group + is= :flag_ocn #String, classification - specific type + obj= nil #String, text content + flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content + mod= h[:mod] || ((defined? o.mod) ? o.mod : nil) #String, text content + tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@obj,@flag,@mod,@tmp=of,is,obj,flag,mod,tmp + self + end + end class ObjectLayout attr_accessor :obj,:is,:of,:from,:tmp def initialize diff --git a/lib/sisu/v4/dal_doc_str.rb b/lib/sisu/v4/dal_doc_str.rb index 1eeae2da..6c588a8a 100644 --- a/lib/sisu/v4/dal_doc_str.rb +++ b/lib/sisu/v4/dal_doc_str.rb @@ -61,15 +61,32 @@ =end module SiSU_DAL_DocumentStructureExtract class Instantiate < SiSU_Param::Parameters::Instructions - @@flag={} #Beware!! + @@flag={ + ocn: :on, + code: :off, + poem: :off, + block: :off, + group: :off, + alt: :off, + table: :off, + table_to: :off, + } def initialize - @@flag['table_to']=false @@counter=@@column=@@columns=0 @@line_mode='' end end class Build - @@flag={} #Beware!! + @@flag={ + ocn: :on, + code: :off, + poem: :off, + block: :off, + group: :off, + alt: :off, + table: :off, + table_to: :off, + } def initialize(md,data) @md,@data=md,data SiSU_DAL_DocumentStructureExtract::Instantiate.new @@ -157,14 +174,33 @@ module SiSU_DAL_DocumentStructureExtract @@counter,@verse_count=0,0 @metadata={} @data.each do |t_o| - t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") unless @@flag['code'] + if t_o =~/^--([+~-])[#]$/ + h=case $1 + when /[+]/ + @@flag[:ocn]=:on + {flag: :ocn_on} + when /[~]/ + @@flag[:ocn]=:off_headings_substantive + {flag: :ocn_off, mod: :headings_substantive} + when /[-]/ + @@flag[:ocn]=:off_headings_exclude + {flag: :ocn_off, mod: :headings_exclude} + else + @@flag[:ocn]=:on + {flag: :ocn_on} + end + t_o=SiSU_DAL_DocumentStructure::ObjectFlag.new.flag_ocn(h) + next + end + t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @@flag[:code]==:off if t_o !~/^(?:code|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ - and not @@flag['code'] \ - and not @@flag['poem'] \ - and not @@flag['group'] \ - and not @@flag['block'] \ - and not @@flag['alt'] \ - and not @@flag['table'] + and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ \ + and @@flag[:code]==:off \ + and @@flag[:poem]==:off \ + and @@flag[:group]==:off \ + and @@flag[:block]==:off \ + and @@flag[:alt]==:off \ + and @@flag[:table]==:off unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any idx=if t_o=~/^=\{(.+)\}\s*$\Z/m; m=$1 t_o=t_o.gsub(/\n=\{.+\}\s*$\Z/m,'') @@ -192,18 +228,48 @@ module SiSU_DAL_DocumentStructureExtract obj=$1 note=endnote_test?(obj) obj,tags=extract_tags(obj) + if @@flag[:ocn]==:off_headings_exclude \ + or @@flag[:ocn]==:off_headings_substantive + unless obj =~ /[~-][#]\s*$/ + if @@flag[:ocn]==:off_headings_exclude + obj << ' -#' + elsif @@flag[:ocn]==:off_headings_substantive + obj << ' ~#' + end + end + end h={ lv: lv, ln: ln, obj: obj, idx: idx, tags: tags } SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-C1-6]\~(\S+?)-\s+(.+)/m name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj) + if @@flag[:ocn]==:off_headings_exclude \ + or @@flag[:ocn]==:off_headings_substantive + unless obj =~ /[~-][#]\s*$/ + if @@flag[:ocn]==:off_headings_exclude + obj << ' -#' + elsif @@flag[:ocn]==:off_headings_substantive + obj << ' ~#' + end + end + end h={ lv: lv, name: name, obj: obj, idx: idx, autonum_: false, tags: tags} SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) elsif t_o=~/^:?[A-C1-6]\~(\S+)\s+(.+)/m name,obj=$1,$2 note=endnote_test?(obj) obj,tags=extract_tags(obj,name) + if @@flag[:ocn]==:off_headings_exclude \ + or @@flag[:ocn]==:off_headings_substantive + unless obj =~ /[~-][#]\s*$/ + if @@flag[:ocn]==:off_headings_exclude + obj << ' -#' + elsif @@flag[:ocn]==:off_headings_substantive + obj << ' ~#' + end + end + end h={ lv: lv, name: name, obj: obj, idx: idx, tags: tags } SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h) else nil @@ -221,6 +287,12 @@ module SiSU_DAL_DocumentStructureExtract note=endnote_test?(obj) obj,tags=extract_tags(obj) unless obj=~/\A\s*\Z/m + if @@flag[:ocn]==:off_headings_exclude \ + or @@flag[:ocn]==:off_headings_substantive + unless obj =~ /[~-][#]\s*$/ + obj << ' ~#' + end + end h={ bullet_: bullet, hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end @@ -238,6 +310,12 @@ module SiSU_DAL_DocumentStructureExtract note=endnote_test?(obj) obj,tags=extract_tags(obj) unless obj=~/\A\s*\Z/m + if @@flag[:ocn]==:off_headings_exclude \ + or @@flag[:ocn]==:off_headings_substantive + unless obj =~ /[~-][#]\s*$/ + obj << ' ~#' + end + end h={ hang: hang, indent: indent, obj: obj, idx: idx, note_: note, image_: image, tags: tags } SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end @@ -255,44 +333,84 @@ module SiSU_DAL_DocumentStructureExtract image=image_test(t_o) note=endnote_test?(t_o) obj,tags=extract_tags(t_o) + if @@flag[:ocn]==:off_headings_exclude \ + or @@flag[:ocn]==:off_headings_substantive + unless obj =~ /[~-][#]\s*$/ + obj << ' ~#' + end + end unless obj=~/\A\s*\Z/m h={ bullet_: false, indent: 0, hang: 0, obj: obj, idx: idx, note_: note, image_: image, tags: tags } SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end end - elsif not @@flag['code'] - if t_o =~/^code\{/ - @@flag['code']=true + elsif @@flag[:code]==:off + if t_o =~/^(?:code\{|[`]{3}\s+code)/ + @@flag[:code]=case t_o + when /^code\{/; :curls + when /^[`]{3}\s+code/; :tics + else @@flag[:code] #error + end @@counter=1 - @codeblock_numbered=(t_o =~/^code\{#/) ? true : false + @codeblock_numbered=(t_o =~/^(?:code\{#|[`]{3}\s+code\s[#])/) ? true : false h={ obj: 'code block start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) - elsif t_o =~/^poem\{/ - @@flag['poem']=true + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + elsif t_o =~/^(?:poem\{|[`]{3}\s+poem)/ + @@flag[:poem]=case t_o + when /^poem\{/; :curls + when /^[`]{3}\s+poem/; :tics + else @@flag[:poem] #error + end h={ obj: 'poem start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o - elsif t_o =~/^group\{/ - @@flag['group']=true + elsif t_o =~/^(?:group\{|[`]{3}\s+group)/ + @@flag[:group]=case t_o + when /^group\{/; :curls + when /^[`]{3}\s+group/; :tics + else @@flag[:group] #error + end h={ obj: 'group text start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o - elsif t_o =~/^block\{/ - @@flag['block']=true + elsif t_o =~/^(?:block\{|[`]{3}\s+block)/ + @@flag[:block]=case t_o + when /^block\{/; :curls + when /^[`]{3}\s+block/; :tics + else @@flag[:block] #error + end h={ obj: 'block text start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o - elsif t_o =~/^alt\{/ - @@flag['alt']=true + elsif t_o =~/^(?:alt\{|[`]{3}\s+alt)/ + @@flag[:alt]=case t_o + when /^alt\{/; :curls + when /^[`]{3}\s+alt/; :tics + else @@flag[:alt] #error + end h={ obj: 'alt text start' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) tuned_file << t_o elsif t_o =~/^(?:table\{|\{table)[ ~]/ h={ obj: 'table start' } #introduce a counter - ins=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #ins=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + ins=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) tuned_file << ins if t_o=~/^table\{(?:~h)?\s+/ - @@flag['table']=true + @@flag[:table]=:curls + @rows='' + case t_o + when /table\{~h\s+c(\d+);\s+(.+)/ + cols=$1 + col=$2.scan(/\d+/) + heading=true + when /table\{\s+c(\d+);\s+(.+)/ + cols=$1 + col=$2.scan(/\d+/) + heading=false + end + @h={ head_: heading, cols: cols, widths: col, idx: idx } + elsif t_o=~/^[`]{3}\s+table(?:~h)?\s+/ + @@flag[:table]=:tics @rows='' case t_o when /table\{~h\s+c(\d+);\s+(.+)/ @@ -361,21 +479,23 @@ module SiSU_DAL_DocumentStructureExtract end t_o end - if @@flag['table'] - if @@flag['table'] \ - and t_o =~/^\}table/ #two table representations should be consolidated as one - @@flag['table']=false + if @@flag[:table]==:curls or @@flag[:table]==:tics + if (@@flag[:table]==:curls \ + and t_o =~/^\}table/) \ + or (@@flag[:table]==:tics \ + and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @@flag[:table]=:off headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx] @h={ head_: headings, cols: columns, widths: widths, idx: idx, obj: @rows } t_o=SiSU_DAL_DocumentStructure::ObjectTable.new.table(@h) tuned_file << t_o @h,@rows=nil,'' h={ obj: 'table end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) t_o else if t_o.is_a?(String) \ - and t_o !~/^table\{/ + and t_o !~/^(?:table\{|[`]{3}\s+table)/ t_o=t_o.gsub(/^\n+/m,''). #check added for ruby 1.9.2 not needed in 1.8 series (tested in v2) gsub(/\n+/m,"#{Mx[:tc_p]}") @rows += t_o + Mx[:tc_c] @@ -383,9 +503,10 @@ module SiSU_DAL_DocumentStructureExtract t_o=nil end end - if @@flag['code'] - if t_o =~/^\}code/ - @@flag['code']=false + if @@flag[:code]==:curls or @@flag[:code]==:tics + if (@@flag[:code]==:curls and t_o =~/^\}code/) \ + or (@@flag[:code]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @@flag[:code]=:off obj=@tuned_code.join("\n") tags=[] h={ obj: obj, tags: tags, number_: @codeblock_numbered } @@ -393,66 +514,66 @@ module SiSU_DAL_DocumentStructureExtract @tuned_code=[] tuned_file << t_o h={ obj: 'code block end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) end - if @@flag['code'] \ + if (@@flag[:code]==:curls or @@flag[:code]==:tics) \ and t_o.is_a?(String) sub_array=t_o.dup + "#{Mx[:br_nl]}" - @line_mode=sub_array.scan(/.+/) @line_mode=[] sub_array.scan(/.+/) {|w| @line_mode << w if w =~/[\S]+/} - t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines('code').join + t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(:code).join @tuned_code << t_o t_o=nil end - elsif @@flag['poem'] \ - or @@flag['group'] \ - or @@flag['block'] \ - or @@flag['alt'] - if @@flag['poem'] \ - and t_o =~/^\}poem/ - @@flag['poem']=false + elsif (@@flag[:poem]==:curls or @@flag[:poem]==:tics) \ + or (@@flag[:group]==:curls or @@flag[:group]==:tics) \ + or (@@flag[:block]==:curls or @@flag[:block]==:tics) \ + or (@@flag[:alt]==:curls or @@flag[:alt]==:tics) + if (@@flag[:poem]==:curls and t_o =~/^\}poem/) \ + or (@@flag[:poem]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @@flag[:poem]=:off h={ obj: 'poem end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) - elsif ( @@flag['group'] \ - and t_o =~/^\}group/ ) - @@flag['group']=false + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + elsif (@@flag[:group]==:curls and t_o =~/^\}group/) \ + or (@@flag[:group]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @@flag[:group]=:off obj,tags=extract_tags(@tuned_block.join("\n")) h={ obj: obj, tags: tags } @tuned_block=[] t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.group(h) tuned_file << t_o h={ obj: 'group text end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) - elsif ( @@flag['block'] \ - and t_o =~/^\}block/ ) - @@flag['block']=false + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + elsif (@@flag[:block]==:curls and t_o =~/^\}block/) \ + or (@@flag[:block]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @@flag[:block]=:off obj,tags=extract_tags(@tuned_block.join("\n")) h={ obj: obj, tags: tags } @tuned_block=[] t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.block(h) tuned_file << t_o h={ obj: 'block text end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) - elsif ( @@flag['alt'] \ - and t_o =~/^\}alt/ ) - @@flag['alt']=false + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) + elsif (@@flag[:alt]==:curls and t_o =~/^\}alt/) \ + or (@@flag[:alt]==:tics and t_o =~/^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @@flag[:alt]=:off obj,tags=extract_tags(@tuned_block.join("\n")) h={ obj: obj, tags: tags } t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.alt(h) @tuned_block=[] tuned_file << t_o h={ obj: 'alt text end' } #introduce a counter - t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) #t_o=SiSU_DAL_DocumentStructure::ObjectLayout.new.insert(h) + t_o=SiSU_DAL_DocumentStructure::ObjectComment.new.comment(h) end - if @@flag['poem'] \ - or @@flag['group'] \ - or @@flag['alt'] \ + if (@@flag[:poem]==:curls or @@flag[:poem]==:tics \ + or @@flag[:group]==:curls or @@flag[:group]==:tics \ + or @@flag[:alt]==:curls or @@flag[:alt]==:tics) \ and t_o =~/\S/ \ - and t_o !~/^(?:\}(?:verse|code|alt|group|block)|(?:verse|code|alt|group|block)\{)/ # fix logic + and t_o !~/^(?:\}(?:verse|code|alt|group|block)|(?:verse|code|alt|group|block)\{)/ \ + and t_o !~/^[`]{3}\s+(?:code|poem|alt|group|block)|^[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic sub_array=t_o.dup @line_mode=sub_array.scan(/.+/) - type=if @@flag['poem'] + type=if @@flag[:poem]==:curls or @@flag[:poem]==:tics t_o=SiSU_DAL_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join poem=t_o.split(/\n\n/) poem.each do |v| @@ -462,16 +583,16 @@ module SiSU_DAL_DocumentStructureExtract t_o=SiSU_DAL_DocumentStructure::ObjectBlockTxt.new.verse(h) tuned_file << t_o end - 'poem' - else 'group' + :poem + else :group end end - @verse_count+=1 if @@flag['poem'] + @verse_count+=1 if @@flag[:poem]==:curls or @@flag[:poem]==:tics end - if not @@flag['code'] - if @@flag['poem'] \ - or @@flag['group'] \ - or @@flag['alt'] + if @@flag[:code]==:off + if @@flag[:poem]==:curls or @@flag[:poem]==:tics \ + or @@flag[:group]==:curls or @@flag[:group]==:tics \ + or @@flag[:alt]==:curls or @@flag[:alt]==:tics if t_o.is_a?(String) t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). @@ -532,16 +653,17 @@ module SiSU_DAL_DocumentStructureExtract h={ obj: str, ocn_: false } SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h) end - def build_lines(type='') + def build_lines(type=:none) lines,lines_new=@data,[] lines.each do |line| line=if line =~/\S/ \ - and line !~/^code\{|^\}code/ \ - and not line.is_a?(Hash) - @@counter+=1 if @@flag['code'] + and line !~/^(?:code\{|\}code)/ \ + and line !~/^(?:[`]{3}\s+code|[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \ + and not line.is_a?(Hash) #watch + @@counter+=1 if @@flag[:code]==:curls or @@flag[:code]==:tics line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") - line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type=='code' # REMOVE try sort for texpdf special case + line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case line=if line =~/(?:https?|file|ftp):\/\/\S+$/ line.gsub(/\s*$/," #{Mx[:br_nl]}") else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' @@ -564,7 +686,7 @@ module SiSU_DAL_DocumentStructureExtract @dob end def structure_markup #build structure where structure provided only in meta header - @dob=if @dob.is ==:para \ + @dob=if @dob.is==:para \ && (((@dob.hang !~/[1-9]/) && (@dob.indent !~/[1-9]/)) \ || (@dob.hang != @dob.indent)) \ and not @dob.bullet_ @@ -606,7 +728,7 @@ module SiSU_DAL_DocumentStructureExtract parent=node1=node2=node3=node4=node5=node6=nil data.each do |dob| h={} - if (dob.obj !~ regex_exclude_ocn_and_node || dob.is ==:code) \ + if (dob.obj !~ regex_exclude_ocn_and_node || dob.is==:code) \ && (dob.of !=:comment \ && dob.of !=:layout \ && dob.of !=:meta) \ @@ -759,8 +881,8 @@ module SiSU_DAL_DocumentStructureExtract puts "<#{@s[0]}>" end data.each_with_index do |o,i| - if o.is ==:heading \ - || o.is ==:heading_insert + if o.is==:heading \ + || o.is==:heading_insert case o.ln when 1 tuned_file << tag_close(o.ln,hs) diff --git a/lib/sisu/v4/dal_expand_insertions.rb b/lib/sisu/v4/dal_expand_insertions.rb index 52deed0a..be258417 100644 --- a/lib/sisu/v4/dal_expand_insertions.rb +++ b/lib/sisu/v4/dal_expand_insertions.rb @@ -332,9 +332,9 @@ module SiSU_DAL_Insertions tuned_file,tuned_file_tmp=[],[] codeblock_=false data.each do |para| - codeblock_=if para =~/^code\{/ + codeblock_=if para =~/^(?:code\{|[`]{3}\s+code)/ true - elsif para =~/^\}code/ + elsif para =~/^(?:\}code|[`]{3}(?:\s|$))/m false else codeblock_ end diff --git a/lib/sisu/v4/dal_misc_arrange.rb b/lib/sisu/v4/dal_misc_arrange.rb new file mode 100644 index 00000000..ab4f3ea4 --- /dev/null +++ b/lib/sisu/v4/dal_misc_arrange.rb @@ -0,0 +1,155 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013 Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Git + + + + * Ralph Amissah + + + + ** Description: system environment, resource control and configuration details + +=end +module SiSU_DAL_MiscArrangeText + class SI + def initialize(md,data) + @md,@data=md,data + end + def conditional_headings(para) + para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header + gsub(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 + if para =~/^@\S+?:/ + para=para.gsub(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). + gsub(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") + end + para + end + def code_blocks(para) + def ticks(para) + block_open,block_close,text=nil,nil,nil + if para =~/\A[`]{3}\s+.+?\n.+?\n[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + block_open,text,block_close=/\A([`]{3}\s+.+?)\n(.+?)\n([`]{3}(\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1..3] + para=[] + para << block_open << text << block_close + elsif para =~/\A[`]{3}\s+.+?\n.*?\Z/m #look at, study + block_open,text=/\A([`]{3}(?:\s+.+?))\n(.*?)\Z/m.match(para)[1,2] + para=[] + if not text.to_s.empty? + para << block_open << text + else + para << block_open + end + elsif para =~/\A.+?\n[`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + text,block_close=/\A(.+?)\n([`]{3}(?:\s+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m.match(para)[1,2] + para=[] + if not text.to_s.empty? + para << text.to_s << block_close + else + para << block_close + end + else para + end + para + end + def curly_braces(para) + block_open,block_close,text=nil,nil,nil + para=if para =~/\A(?:code|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + block_open,text,block_close=/\A((?:code|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1..3] + para=[] + para << block_open << text << block_close + elsif para =~/\A(?:code|poem|alt|group|block|table)\{ .+?\n.+?\Z/m + block_open,text=/\A((?:code|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m.match(para)[1,2] + para=[] + if not text.to_s.empty? + para << block_open << text + else + para << block_open + end + elsif para =~/\A.+?\n\}(?:code|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + text,block_close=/\A(.+?)\n(\}(?:code|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m.match(para)[1,2] + para=[] + if not text.to_s.empty? + para << text.to_s << block_close + else + para << block_close + end + else para + end + para + end + para=para =~/^```/m \ + ? ticks(para) + : para + para=(para =~/^(?:code|poem|alt|group|block|table)\{|^\}(?:code|poem|alt|group|block|table)/m) \ + ? curly_braces(para) + : para + end + def prepare_text + data=@data + data_new=[],[] + if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) + data[0]=data[0].gsub(/^#!\s*\/usr\/bin\/sisu/,''). + gsub(/^#!\s*\/usr\/bin\/env sisu/,'') + end + if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier + data[0]=data[0].gsub(/^(SiSU\s*[\d.]*)$/,'% \1'). + gsub(/^(sisu-[\d.]+)$/,'% \1') + end + data.each do |para| + para=conditional_headings(para) + data_new << code_blocks(para) + end + data_new=data_new.flatten + end + end +end +__END__ diff --git a/lib/sisu/v4/dal_substitutions_and_insertions.rb b/lib/sisu/v4/dal_substitutions_and_insertions.rb deleted file mode 100644 index 08a63c89..00000000 --- a/lib/sisu/v4/dal_substitutions_and_insertions.rb +++ /dev/null @@ -1,145 +0,0 @@ -# encoding: utf-8 -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013 Ralph Amissah, All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) Ralph Amissah - - This program is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - - - - * Download: - - - * Git - - - - * Ralph Amissah - - - - ** Description: system environment, resource control and configuration details - -=end -module SiSU_DAL_SubstituteAndInsert - class SI - def initialize(md,data) - @md,@data=md,data - end - def substitutions_and_insertions? - data=@data - data_expand=[] - if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) - data[0]=data[0].gsub(/^#!\s*\/usr\/bin\/sisu/,''). - gsub(/^#!\s*\/usr\/bin\/env sisu/,'') - end - if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier - data[0]=data[0].gsub(/^(SiSU\s*[\d.]*)$/,'% \1'). - gsub(/^(sisu-[\d.]+)$/,'% \1') - end - data.each do |para| - if para =~/<:(insert\d+)!?>/ \ - and para !~/^%\s+/ - ins=SiSU_Viz::Inserts.new - case para - when /^\s*<:(insert1)>\s*$/ - i=$1 - if defined? ins.insert1 - para=[] - ins.insert1.split(/\n\n/).each {|x| para << x } - end - when /^\s*<:(insert2)>\s*$/ - i=$1 - if defined? ins.insert2 - para=[] - ins.insert2.split(/\n\n/).each {|x| para << x } - end - when /^\s*<:(insert3)>\s*$/ - i=$1 - if defined? ins.insert3 - para=[] - ins.insert3.split(/\n\n/).each {|x| para << x << "\n"} - end - when /^\s*<:(insert4)>\s*$/ - i=$1 - if defined? ins.insert4 - para=[] - ins.insert4.split(/\n\n/).each {|x| para << x << "\n"} - end - when /^\s*<:(insert5)>\s*$/ - i=$1 - if defined? ins.insert5 - para=[] - ins.insert5.split(/\n\n/).each {|x| para << x << "\n"} - end - when /^\s*<:(insert6)>\s*$/ - i=$1 - if defined? ins.insert6 - para=[] - ins.insert6.split(/\n\n/).each {|x| para << x << "\n"} - end - when /^\s*<:(insert7)>\s*$/ - i=$1 - if defined? ins.insert7 - para=[] - ins.insert7.split(/\n\n/).each {|x| para << x << "\n"} - end - end - para.each {|x| data_expand << x } - else data_expand << para - end - data_expand=data_expand.flatten.compact - end - data_new=[] - data_expand.each do |para| - para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header - gsub(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 - if para =~/^@\S+?:/ - para=para.gsub(/^@(\S+?):(\s+|$)/,"#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). - gsub(/^@(\S+?):([+-])(\s+|$)/,"#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") - end - data_new << para - end - data_new - end - end -end -__END__ diff --git a/lib/sisu/v4/dal_syntax.rb b/lib/sisu/v4/dal_syntax.rb index ed9fa52d..eb23fd22 100644 --- a/lib/sisu/v4/dal_syntax.rb +++ b/lib/sisu/v4/dal_syntax.rb @@ -309,17 +309,17 @@ module SiSU_DAL_Syntax dob end def fontface(dob) - dob.obj=dob.obj.gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/m, + dob.obj=dob.obj.gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)\*\{(.+?)\}\*/m, "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/m, + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)!\{(.+?)\}!/m, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//m, + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\(|\>)\/\{(.+?)\}\//m, "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/m, + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)_\{(.+?)\}_/m, "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)#\{(.+?)\}#/m, + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)#\{(.+?)\}#/m, "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}"). #monospace - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/m, + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}]|\(|\>)\"\{(.+?)\}\"/m, "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite /blockquote? gsub(/(^|[^\\])\^\{(.+?)\}\^/m, "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #superscript @@ -444,7 +444,7 @@ module SiSU_DAL_Syntax "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") end dob.obj=dob.obj.gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}). gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, @@ -462,40 +462,40 @@ module SiSU_DAL_Syntax dob.obj=dob.obj.gsub(/<[:e]\s+(.+?)!?>/, "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested gsub(/(^|#{Mx[:br_nl]})\s*_\*\s*/, - "\\1#{Mx[:gl_bullet]}"). #bullets, shortcut + "\\1#{Mx[:gl_bullet]}"). #bullets, shortcut gsub(/=\{(.+?)\}/, "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}"). gsub(/^\s*_([1-9])\*\s*/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}"). #bullets, shortcut + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}"). #bullets, shortcut gsub(/^\s*_([1-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}"). #indent + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}"). #indent gsub(/^\s*_([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #indent bold + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #indent bold gsub(/^\s*__([1-9])\s+/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}"). #hang + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}"). #hang gsub(/^\s*__([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #hangdef + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #hangdef gsub(/^\s*_([0-9])_([0-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}"). #hang + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}"). #hang gsub(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} "). #hangdef - gsub(/<:hi>/,"#{Mx[:fa_hilite_o]}"). #'') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) - gsub(/<:\/hi>/,"#{Mx[:fa_hilite_c]}"). #'') + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} "). #hangdef + gsub(/<:hi>/,"#{Mx[:fa_hilite_o]}"). #''). # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) + gsub(/<:\/hi>/,"#{Mx[:fa_hilite_c]}"). #''). gsub(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n"). gsub(/[ ]+($)/,'\1'). gsub(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3"). #any remaining linked text or image + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3"). #any remaining linked text or image gsub(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image gsub(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}"). gsub(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4"). #any remaining linked text or image + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4"). #any remaining linked text or image gsub(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3"). #any remaining linked text or image, check need + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3"). #any remaining linked text or image, check need gsub(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image, check need + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image, check need gsub(/\{\s*(.+?)\s*\}(image)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image elsif dob.is==:table dob=fontface(dob) elsif dob.is ==:code -- cgit v1.2.3