From 0fda4e964a07556aa2de453b841eba46524b84b5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 20 Aug 2014 18:45:06 -0400 Subject: v5 v6: ao_expand_insertions, blocked text match, adjust --- lib/sisu/v5/ao_expand_insertions.rb | 35 +++++++++++++++++++++++++++++------ lib/sisu/v6/ao_expand_insertions.rb | 35 +++++++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/ao_expand_insertions.rb b/lib/sisu/v5/ao_expand_insertions.rb index be326a7a..483e9fdb 100644 --- a/lib/sisu/v5/ao_expand_insertions.rb +++ b/lib/sisu/v5/ao_expand_insertions.rb @@ -356,16 +356,39 @@ module SiSU_AO_Insertions def expand_insertions? data=@data tuned_file,tuned_file_tmp=[],[] - codeblock_=false + codeblock_={ + status: :false, + type: :na, + } data.each do |para| - codeblock_=if para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ - true - elsif para =~/^(?:\}code|```(?:\s|$))/m - false + codeblock_=if para =~/^code(?:\.[a-z][0-9a-z_]+)?\{/ \ + and codeblock_[:status]==:false + { + status: :true, + type: :curl, + } + elsif para =~/^```[ ]+code(?:\.[a-z][0-9a-z_]+)?/ \ + and codeblock_[:status]==:false + { + status: :true, + type: :tics, + } + elsif codeblock_[:type]==:curl \ + and para =~/^\}code/m + { + status: :false, + type: :na, + } + elsif codeblock_[:type]==:tics \ + and para =~/^```(?:\s|$)/m + { + status: :false, + type: :na, + } else codeblock_ end if para !~/^%+\s/ \ - and not codeblock_ \ + and codeblock_[:status] != :true \ and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ @u=SiSU_Env::InfoEnv.new.url m_cmd='' diff --git a/lib/sisu/v6/ao_expand_insertions.rb b/lib/sisu/v6/ao_expand_insertions.rb index 63cdc942..8eb0e5c4 100644 --- a/lib/sisu/v6/ao_expand_insertions.rb +++ b/lib/sisu/v6/ao_expand_insertions.rb @@ -356,16 +356,39 @@ module SiSU_AO_Insertions def expand_insertions? data=@data tuned_file,tuned_file_tmp=[],[] - codeblock_=false + codeblock_={ + status: :false, + type: :na, + } data.each do |para| - codeblock_=if para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ - true - elsif para =~/^(?:\}code|```(?:\s|$))/m - false + codeblock_=if para =~/^code(?:\.[a-z][0-9a-z_]+)?\{/ \ + and codeblock_[:status]==:false + { + status: :true, + type: :curl, + } + elsif para =~/^```[ ]+code(?:\.[a-z][0-9a-z_]+)?/ \ + and codeblock_[:status]==:false + { + status: :true, + type: :tics, + } + elsif codeblock_[:type]==:curl \ + and para =~/^\}code/m + { + status: :false, + type: :na, + } + elsif codeblock_[:type]==:tics \ + and para =~/^```(?:\s|$)/m + { + status: :false, + type: :na, + } else codeblock_ end if para !~/^%+\s/ \ - and not codeblock_ \ + and codeblock_[:status] != :true \ and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ @u=SiSU_Env::InfoEnv.new.url m_cmd='' -- cgit v1.2.3