aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/param.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2012-04-15 00:26:26 -0400
committerRalph Amissah <ralph@amissah.com>2012-04-15 00:32:15 -0400
commit0013ec9d66de5341a419585909d722009fc33381 (patch)
tree2c2802282f2733f0912e59379e107c2fc7bfd8d4 /lib/sisu/v3/param.rb
parentv3: 3.2.3 version & changelog "opened" (diff)
v3: param, dal_syntax, document header (simple regex) substitution list
* $ and curly braces are escaped (within sisu) to allow the following: @make:\n :substitute: /${linux-distro}/,'Debian' /${stable}/,'Squeeze' \ /${testing}/,'Wheezy' * changes are not made within text object types: code-blocks, tables or metadata (document headers). Marked up document remains self-referential. * Note: the substitution list must be written on a single line, without line-breaks. * [Substitutions possibility requested by Debian-live, live-manual (Ben Armstrong & Daniel Baumann)]
Diffstat (limited to 'lib/sisu/v3/param.rb')
-rw-r--r--lib/sisu/v3/param.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb
index 5563f780..60f5345b 100644
--- a/lib/sisu/v3/param.rb
+++ b/lib/sisu/v3/param.rb
@@ -803,6 +803,26 @@ module SiSU_Param
else nil
end
end
+ def substitute
+ m=@h['substitute']
+ z=if m
+ w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/)
+ arr_hash=[]
+ matches=''
+ w.each do |x|
+ c=(x[1] =~/[i],/) ? :i : :s
+ matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|'
+ arr_hash << {
+ match: x[0].gsub(/([${}])/,'\\\\\1'),
+ replace: x[2],
+ case_s: c
+ }
+ end
+ matches.chop!
+ { match_and_replace: arr_hash, matches: matches }
+ else nil
+ end
+ end
def plaintext_wrap
if @h['plaintext_wrap'].to_s =~/\d\d+/ \
and @h['plaintext_wrap'].to_i > 19 \