diff options
author | Ralph Amissah <ralph@amissah.com> | 2011-06-26 14:03:16 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2011-06-26 14:09:35 -0400 |
commit | 833558063f14471bf46512ae7bf69bf4e5de49c9 (patch) | |
tree | 07d622ec451e7b3580ad67134c2a9462054d2619 /lib | |
parent | v2 v3: vim colors, added cursor line & cursor column (diff) |
v2 v3: dal_syntax, linebreak in regular text object: ' \\ ' ('<br>' depreciated)
* thanks to Jonas Stein for making me look at this (see bug: #617298 & comments
in upstream CHANGELOG_v3)
* testing required, downstream outputs affected
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v2/dal_syntax.rb | 21 | ||||
-rw-r--r-- | lib/sisu/v3/dal_syntax.rb | 21 |
2 files changed, 26 insertions, 16 deletions
diff --git a/lib/sisu/v2/dal_syntax.rb b/lib/sisu/v2/dal_syntax.rb index 76287464..35505d12 100644 --- a/lib/sisu/v2/dal_syntax.rb +++ b/lib/sisu/v2/dal_syntax.rb @@ -122,6 +122,7 @@ module SiSU_Syntax def songsheet @data.compact! @data.each do |dob| + dob=breaks(dob) dob=if @md.sem_tag then sem(dob) else dob end #revisit dob=wordlist_italics(dob) dob=wordlist_bold(dob) @@ -133,6 +134,13 @@ module SiSU_Syntax def sem(dob) #revisit dob=SiSU_sem::Tags.new(dob,@md).rm.all end + def breaks(dob) + if dob.is !~/^(?:meta|comment|code|table)/ + dob.obj.gsub!(/ \\\\(?: |$)/,"#{Mx[:br_line]}") + dob.obj.gsub!(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}") # depreciated + end + dob + end def wordlist_italics(dob) dob=dob.dup if (defined? @md.make.italics[:str] \ @@ -166,11 +174,11 @@ module SiSU_Syntax dob end def embolden(given) - given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)(<br>|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2") given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)(<br>|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") @@ -180,7 +188,7 @@ module SiSU_Syntax "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end def italicise(given) - given.gsub!(/^\/_\s*(.+?)(<br>|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given.gsub!(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") given.gsub!(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") @@ -314,7 +322,7 @@ module SiSU_Syntax dob.obj.gsub!(/\s*@title\b/," #{@md.title.full}") if defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub!(/\s+(?:@creator|@author)/,",<br />#{@md.creator.author}") + dob.obj.gsub!(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") else dob.obj.gsub!(/\s+(?:@creator|@author)/,'') end end @@ -352,7 +360,6 @@ module SiSU_Syntax dob.obj.gsub!(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}") #escaped special character dob.obj.gsub!(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}") #escaped special character dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, @@ -388,8 +395,6 @@ module SiSU_Syntax "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}") #bullets, shortcut dob.obj.gsub!(/^\s*_([1-9])\s+/, "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") #indent - dob.obj.gsub!(/(?:<:?br>|<br \/>)/, - "#{Mx[:br_line]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') dob.obj.gsub!(/<:hi>/,"#{Mx[:fa_hilite_o]}") #'<span style="background-color: rgb(255,240,196)">') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) dob.obj.gsub!(/<:\/hi>/,"#{Mx[:fa_hilite_c]}") #'</span>') dob.obj.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n") @@ -507,7 +512,7 @@ module SiSU_Syntax "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}") #bullets, shortcut line.gsub!(/^\s*_\([1-9]\)\s+/, "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") - line.gsub!(/(?:<:?br>|<br \/>)\s*_[12]\s+/, + line.gsub!(/#{Mx[:br_line]}\s*_[12]\s+/, "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') end @data diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 2f6353bc..4595d6e1 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -122,6 +122,7 @@ module SiSU_Syntax def songsheet @data.compact! @data.each do |dob| + dob=breaks(dob) dob=if @md.sem_tag then sem(dob) else dob end #revisit dob=wordlist_italics(dob) dob=wordlist_bold(dob) @@ -133,6 +134,13 @@ module SiSU_Syntax def sem(dob) #revisit dob=SiSU_sem::Tags.new(dob,@md).rm.all end + def breaks(dob) + if dob.is !~/^(?:meta|comment|code|table)/ + dob.obj.gsub!(/ \\\\(?: |$)/,"#{Mx[:br_line]}") + dob.obj.gsub!(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}") # depreciated + end + dob + end def wordlist_italics(dob) dob=dob.dup if (defined? @md.make.italics[:str] \ @@ -166,11 +174,11 @@ module SiSU_Syntax dob end def embolden(given) - given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)(<br>|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2") given.gsub!(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}") - given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)(<br>|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") given.gsub!(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") @@ -180,7 +188,7 @@ module SiSU_Syntax "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") end def italicise(given) - given.gsub!(/^\/_\s*(.+?)(<br>|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + given.gsub!(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") given.gsub!(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2") @@ -314,7 +322,7 @@ module SiSU_Syntax dob.obj.gsub!(/\s*@title\b/," #{@md.title.full}") if defined? @md.creator.author \ and @md.creator.author - dob.obj.gsub!(/\s+(?:@creator|@author)/,",<br />#{@md.creator.author}") + dob.obj.gsub!(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") else dob.obj.gsub!(/\s+(?:@creator|@author)/,'') end end @@ -358,7 +366,6 @@ module SiSU_Syntax dob.obj.gsub!(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}") #escaped special character dob.obj.gsub!(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}") #escaped special character dob.obj.gsub!(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character - dob.obj.gsub!(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m dob.obj.gsub!(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, @@ -394,8 +401,6 @@ module SiSU_Syntax "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}") #bullets, shortcut dob.obj.gsub!(/^\s*_([1-9])\s+/, "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") #indent - dob.obj.gsub!(/(?:<:?br>|<br \/>)/, - "#{Mx[:br_line]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') dob.obj.gsub!(/<:hi>/,"#{Mx[:fa_hilite_o]}") #'<span style="background-color: rgb(255,240,196)">') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) dob.obj.gsub!(/<:\/hi>/,"#{Mx[:fa_hilite_c]}") #'</span>') dob.obj.gsub!(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n") @@ -513,7 +518,7 @@ module SiSU_Syntax "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}") #bullets, shortcut line.gsub!(/^\s*_\([1-9]\)\s+/, "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}") - line.gsub!(/(?:<:?br>|<br \/>)\s*_[12]\s+/, + line.gsub!(/#{Mx[:br_line]}\s*_[12]\s+/, "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') end @data |