diff options
author | Ralph Amissah <ralph@amissah.com> | 2008-02-24 21:04:54 +0000 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2008-02-24 21:04:54 +0000 |
commit | db15102466e4ce006ce3a9484882972cced91fb6 (patch) | |
tree | ae42a69395d6c59d10c2fb28fe1e6fd41fb4df75 /lib | |
parent | for now strip sisu-0.66 semantic markup tags (diff) |
make possible to strip 0.66 markup in dal commit
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v0/shared_sem.rb | 72 |
1 files changed, 52 insertions, 20 deletions
diff --git a/lib/sisu/v0/shared_sem.rb b/lib/sisu/v0/shared_sem.rb index a082cfc2..b32b1324 100644 --- a/lib/sisu/v0/shared_sem.rb +++ b/lib/sisu/v0/shared_sem.rb @@ -1,3 +1,4 @@ +# coding: utf-8 =begin * Name: SiSU @@ -60,45 +61,72 @@ =end module SiSU_sem + require "#{SiSU_lib}/param" class Tags - def initialize(para) - @para=para + def initialize(para,md) + @para,@md=para,md end def rgx def exclude /^<:code>/ end def each_csc - /\b[a-z]+[:;]\{|\}[:;][a-z]+\b/m - #/\b(?:[a-z]+(?:[_.][a-z]+)+|[a-z]+)[:;]\{|\}[:;](?:[a-z]+(?:[_.][a-z]+)+|[a-z]+)\b/m + /(?:;|(?:[a-z]+(?:[_:.][a-z]+)+|[a-z]*):)\{|\}[:;][a-z]+(?:[_:.][a-z]+)*/m end def each_c - /\b[a-z]+:\{|\}:[a-z]+\b/m - #/\b(?:[a-z]+(?:[_.][a-z]+)+|[a-z]+):\{|\}:(?:[a-z]+(?:[_.][a-z]+)+|[a-z]+)\b/m + /(?:[a-z]+(?:[_:.][a-z]+)+|[a-z]*):\{|\}:[a-z]+(?:[_:.][a-z]+)*/m end def each_sc - /\b[a-z]+;\{|\};[a-z]+\b/m - #/\b(?:[a-z]+(?:[_.][a-z]+)+|[a-z]+);\{|\};(?:[a-z]+(?:[_.][a-z]+)+|[a-z]+)\b/m + /(?:[a-z]+(?:[_:.][a-z]+)+|[a-z]*);\{|\};[a-z]+(?:[_:.][a-z]+)*/m end def pair_csc - /(([a-z]+)(?::\{(.+?)\}:\2|;\{(.+?)\};\2))/m - #/(([a-z]+(?:[_.][a-z]+)+|[a-z]+)(?::\{(.+?)\}:\2|;\{(.+?)\};\2))/m + /(([a-z]+(?:[_:.][a-z]+)+|[a-z]+)(?::\{(.+?)\}:\2)|([:;])\{(.+?)\}\4[a-z]+(?:[_:.][a-z]+)*)/m end def pair_c - /(([a-z]+):\{(.+?)\}:\2)/m - #/(([a-z]+(?:[_.][a-z]+)+|[a-z]+):\{(.+?)\}:\2)/m + /(([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\2)|:\{(.+?)\}:[a-z]+(?:[_:.][a-z]+)*)/m end def pair_sc - /(([a-z]+);\{.+?\};\2)/m - #/(([a-z]+(?:[_.][a-z]+)+|[a-z]+);\{.+?\};\2)/m + /(;\{.+?\};[a-z]+(?:[_:.][a-z]+)*)/m end def whole_csc_ae - /(([a-z]+)(?::\[(.+?)\]:\2|;\[(.+?)\];\2))/m - #/(([a-z]+(?:[_.][a-z]+)+|[a-z]+)(?::\[(.+?)\]:\2|;\[(.+?)\];\2))/m + /(([a-z]+(?:[_.][a-z]+)+|[a-z]*)(?::\[(.+?)\]:\2)|;\{(.+?)\};(?:[a-z]+(?:[_:.][a-z]+)+|[a-z]+)\b)/m end def each_csc_ae - /\b[a-z]+[:;]\[|\][:;][a-z]+\b/m - #/\b(?:[a-z]+(?:[_.][a-z]+)+|[a-z]+)[:;]\[|\][:;](?:[a-z]+(?:[_.][a-z]+)+|[a-z]+)\b/m + /(?:;|(?:[a-z]+(?:[_:.][a-z]+)+)*:|[a-z]*:)\[|\][:;](?:[a-z]+(?:[_:.][a-z]+)+|[a-z]+)/m + end + self + end + def print + def scan_pair_c + if @para =~ rgx.pair_c + matched=@para.scan(rgx.pair_c).flatten + puts matched[0] unless matched[0].nil? + end + end + def scan_pair_sc + matched=@para.scan(rgx.pair_sc).flatten + puts matched[0] unless matched[0].nil? + end + def if_pair_c + if @para=~/([a-z](?:[a-z_:.]+?[a-z])?)+(?::\{(.+?)\}:\1)/m; puts "#{$1}:{ #{$2} }:#{$1}" + end + end + def if_pair_sc + if @para=~/;\{\s*(.+?)\s*\};([a-z]+(?:[_:.][a-z]+)*)/; puts ";{ #{$1} };#{$2}" + end + end + def match_pair_c + matched=[] + matched=rgx.pair_c.match(@para)[1] if @para =~ rgx.pair_c + puts matched unless matched.nil? + end + def match_pair_sc + matched=[] + matched=rgx.pair_sc.match(@para)[1] if @para =~ rgx.pair_sc + puts matched unless matched.nil? + end + def matching + scan_pair_c end self end @@ -118,8 +146,12 @@ module SiSU_sem @para end def all - sem_marker_parts - sem_marker_added_extra_parts + if @md.sem_tag + print.matching + sem_marker_parts + sem_marker_added_extra_parts + end + @para end self end |