aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/dal_syntax.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/dal_syntax.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/dal_syntax.rb')
-rw-r--r--lib/sisu/v3/dal_syntax.rb65
1 files changed, 55 insertions, 10 deletions
diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb
index 73bb6a64..102e44cd 100644
--- a/lib/sisu/v3/dal_syntax.rb
+++ b/lib/sisu/v3/dal_syntax.rb
@@ -124,6 +124,9 @@ module SiSU_DAL_Syntax
@data.each do |dob|
dob=breaks(dob)
dob=if @md.sem_tag then sem(dob) else dob end #revisit
+ dob=line_actions(dob)
+ dob=paragraph_set(dob)
+ dob=substitutions(dob)
dob=wordlist_italics(dob)
dob=wordlist_bold(dob)
dob=bodymarkup(dob)
@@ -203,6 +206,57 @@ module SiSU_DAL_Syntax
gsub(/^\/_\s+(.*)?\s*$/,
"#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}")
end
+ def line_actions(dob)
+ dob.obj=if (dob.is !=:heading \
+ && dob.is !=:heading_insert \
+ && dob.is !=:comment \
+ && dob.is !=:meta) \
+ and dob.obj =~ /^!_\s+/
+ embolden(dob.obj)
+ elsif dob.obj =~ /^\/_\s+/
+ italicise(dob.obj)
+ else dob.obj
+ end
+ dob
+ end
+ def paragraph_set(dob)
+ dob.obj=if dob.is !=:meta \
+ && dob.is !=:heading \
+ && dob.is !=:heading_insert \
+ && dob.is !=:code \
+ && dob.is !=:comment \
+ && dob.is !=:table
+ dob.obj.gsub(/\n/m,' ').
+ gsub(/ \s+/m,' ')
+ else dob.obj
+ end
+ dob
+ end
+ def substitutions(dob)
+ dob=dob.dup
+ dob=if defined? @md.make.substitute[:match_and_replace] \
+ and @md.make.substitute[:match_and_replace].class == Array
+ dob=if dob.is !=:meta \
+ && dob.is !=:heading_insert \
+ && dob.is !=:code \
+ && dob.is !=:comment \
+ && dob.is !=:table
+ if dob.obj =~/#{@md.make.substitute[:matches]}/
+ @md.make.substitute[:match_and_replace].each do |x|
+ dob.obj=if x[:case_s]==:i
+ dob.obj.gsub(/#{x[:match]}/mi,x[:replace])
+ else
+ dob.obj.gsub(/#{x[:match]}/m,x[:replace])
+ end
+ end
+ end
+ dob
+ else dob
+ end
+ dob
+ else dob
+ end
+ end
def wordlist_bold(dob)
dob=dob.dup
if (defined? @md.make.bold[:str] \
@@ -239,20 +293,11 @@ module SiSU_DAL_Syntax
else dob.obj
end
else
- dob.obj=if (dob.is !=:heading \
- && dob.is !=:heading_insert \
- && dob.is !=:comment \
- && dob.is !=:meta) \
- and dob.obj =~ /^!_\s+/
- embolden(dob.obj)
- elsif dob.is==:heading \
+ dob.obj=if dob.is==:heading \
and dob.ln.to_s =~/[7-9]/
embolden(dob.obj)
else dob.obj
end
- if dob.obj =~ /\/_\s+/
- dob.obj=italicise(dob.obj)
- end
end
dob
end