From 72180b72ce9c1b0d25e7c22188c443f1f7836b3f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 29 Apr 2010 14:15:49 -0400 Subject: markup for *{emphasis}* configurable as being either bold or italics * the default is that emphasis output is in bold so there is no change at present unless sisurc.yml is configured (markup: emphasis: 'italics') [requested] --- lib/sisu/v2/dal_syntax.rb | 30 +++++++++++++++++++----------- lib/sisu/v2/sysenv.rb | 7 +++++++ 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v2/dal_syntax.rb b/lib/sisu/v2/dal_syntax.rb index b7b9ec4b..dd83ef3b 100644 --- a/lib/sisu/v2/dal_syntax.rb +++ b/lib/sisu/v2/dal_syntax.rb @@ -69,8 +69,14 @@ module SiSU_Syntax @data_new=[] url_and_stub=SiSU_Env::Info_env.new.url @output_url="#{url_and_stub.remote}" + @env=SiSU_Env::Info_env.new + @emph=(@env.markup_emphasis =~/italics/) \ + ? ({:o =>Mx[:fa_italics_o], :c =>Mx[:fa_italics_c] }) \ + : ({:o =>Mx[:fa_bold_o], :c =>Mx[:fa_bold_c] }) @http_m=%r{\{.+?\}https?://\S+|https?:\S+|\.\.\/\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} - @manmkp_ital='[i/]\\{.+?\\}[i/]' + @manmkp_ital=(@env.markup_emphasis =~/italics/) \ + ? '[i/*]\\{.+?\\}[i/*]' \ + : '[i/]\\{.+?\\}[i/]' tail_m_ital=%q{(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$)} tail_m_bold=%{(?:(?:#{Mx[:fa_italics_c]})?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?} bold_line=%{^!_\s.+?(?:#{Mx[:br_line]}|\n|$)} @@ -83,7 +89,9 @@ module SiSU_Syntax elsif defined? @vz.markup_make_italic[:str] /#{@http_m}|#{bold_line}|#{@manmkp_ital}#{tail_m_ital}|#{@vz.markup_make_italic[:str]}#{tail_m_ital}|\S+|\n/ end - @manmkp_bold='^!_\s.+?(?:\n|$)|[*!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[*!]' + @manmkp_bold=(@env.markup_emphasis =~/italics/) \ + ? '^!_\s.+?(?:\n|$)|[!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[!]' \ + : '^!_\s.+?(?:\n|$)|[*!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[*!]' @line_scan_bold=if (defined? @md.make.bold[:str] \ and @md.make.bold[:str]) \ and (defined? @vz.markup_make_bold[:str] \ @@ -332,14 +340,14 @@ module SiSU_Syntax %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) end dob.obj.gsub!(/<:?p([nb])>/,"#{Mx[:fa_o]}p\\1#{Mx[:fa_c]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') - 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]}|[\(\[\{]|\>)!\{(.+?)\}!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis 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]}|[\(\[\{]|\>)\*\{(.+?)\}\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis + 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]}|[\(\[\{]|\>)!\{(.+?)\}!/, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - 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]}|[\(\[\{]|\>)_\{(.+?)\}_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore 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]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + 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]}|[\(\[\{]|\>)_\{(.+?)\}_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? dob.obj.gsub!(/(^|[^\\])\^\{(.+?)\}\^/, @@ -359,7 +367,7 @@ module SiSU_Syntax dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #deleted text dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch + "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasise single word, watch dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/, @@ -429,7 +437,7 @@ module SiSU_Syntax puts 'tech' @data.each do |line| line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/, @@ -439,9 +447,9 @@ module SiSU_Syntax line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/, "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis - line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/, "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, @@ -465,7 +473,7 @@ module SiSU_Syntax line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch + "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasise single word, watch line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch line.gsub!(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/, diff --git a/lib/sisu/v2/sysenv.rb b/lib/sisu/v2/sysenv.rb index ed0fe136..c5bc63c2 100644 --- a/lib/sisu/v2/sysenv.rb +++ b/lib/sisu/v2/sysenv.rb @@ -875,6 +875,13 @@ module SiSU_Env ? @rc['processing']['concord_max'] \ : (defaults[:concord_max]) end + def markup_emphasis + ((defined? @rc['markup']['emphasis']) \ + && @rc['markup']['emphasis'] \ + && (@rc['markup']['emphasis']=~/italic/)) \ + ? 'italics' \ + : 'bold' + end def current_document @@current_document||=Dir.pwd @@current_document -- cgit v1.2.3