aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/sst_identify_markup.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-10-15 19:27:16 +0100
committerRalph Amissah <ralph@amissah.com>2007-10-15 19:27:16 +0100
commite1ec4bd2dad2bd22ad97cea398ae1cfcfae183a2 (patch)
tree6ffe3ae1b2453578a032ce053934a31f980645e9 /lib/sisu/v0/sst_identify_markup.rb
parentregex matching of images, (and rearrangement of conditionals) (diff)
mostly the arrangement of conditionals
Diffstat (limited to 'lib/sisu/v0/sst_identify_markup.rb')
-rw-r--r--lib/sisu/v0/sst_identify_markup.rb35
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/sisu/v0/sst_identify_markup.rb b/lib/sisu/v0/sst_identify_markup.rb
index 19601c13..7fac34d5 100644
--- a/lib/sisu/v0/sst_identify_markup.rb
+++ b/lib/sisu/v0/sst_identify_markup.rb
@@ -93,34 +93,40 @@ WOK
end
def identify
f=@opt.fns
- if f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])$/ and File.exist?(f)
+ if f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])$/ \
+ and File.exist?(f)
file=File.open(f,'r')
cont=file.readlines
file.close
links,oldlinks='',''
markup=nil
@declared_type,@declared_markup='[text?]',''
- if cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/
+ if cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \
+ or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/
@declared_type,@declared_markup=$1,$2
#puts "SiSU #@declared_markup (declared markup version)"
#else puts 'markup version not declared'
- elsif cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/
+ elsif cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \
+ or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/
@declared_markup=$1
end
@flag_57,@flag_38=false,false
cont.each_with_index do |y,i|
- if y =~/^(?:0\{?~links?|@links?:)\s/ and f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])/
+ if y =~/^(?:0\{?~links?|@links?:)\s/ \
+ and f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])/
links=unless y =~/\{.+?\}\S+/; oldlinks=' (pre 0.20.4 header links)'
else ' (post 0.20.4 header links)'
end
end
- if @flag_57 or y =~/^:?A~\?? @title/
+ if @flag_57 \
+ or y =~/^:?A~\?? @title/
version='0.57'
markup=Markup_inform.new(version,'0.57' + oldlinks,@declared_markup,@declared_type)
@flag_57=true
break
end
- if @flag_38 or (y =~/^:?A~/ and f =~/(?:\.sst|\.ssm|\.ssi)/)
+ if @flag_38 \
+ or (y =~/^:?A~/ and f =~/(?:\.sst|\.ssm|\.ssi)/)
version='0.38'
markup=Markup_inform.new(version,'0.38' + oldlinks,@declared_markup,@declared_type)
@flag_38=true
@@ -131,12 +137,15 @@ WOK
break
end
end
- if (y =~/^1~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) and not @flag_38
+ if (y =~/^1~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) \
+ and not @flag_38
version='0.37'
markup=Markup_inform.new(version,'0.37 is substantially 0.16 - 0.36 markup with new file-extension' + oldlinks,@declared_markup,@declared_type)
break
end
- if y =~/^1~/ and f =~/\.([rs])([123])/ and not @flag_38
+ if y =~/^1~/ \
+ and f =~/\.([rs])([123])/ \
+ and not @flag_38
t,n=$1,$2
version='0.16'
instruct=if t =~/r/
@@ -146,12 +155,14 @@ WOK
markup=Markup_inform.new(version,'0.16 - 0.36' + instruct + links,@declared_markup,@declared_type)
break
end
- if y =~/^0\{~/ and not @flag_38
+ if y =~/^0\{~/ \
+ and not @flag_38
version='0.1'
markup=Markup_inform.new(version,'0.1 - 0.15',@declared_markup,@declared_type)
break
end
- if y =~/^0\{{3}/ and not @flag_38
+ if y =~/^0\{{3}/ \
+ and not @flag_38
markup=Markup_inform.new('circa. 1997','old, check date',@declared_markup,@declared_type)
break
end
@@ -162,7 +173,9 @@ WOK
end
end
def determine_markup_version
- if @opt.fns.nil? or @opt.fns.empty?; Markup_history.new(@opt).help_identify
+ if @opt.fns.nil? \
+ or @opt.fns.empty?
+ Markup_history.new(@opt).help_identify
end
if File.exist?(@opt.fns)
if @opt.fns =~/\.(?:sst|ssm|ssi|s[123i]|r[123])/