aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v5/ao_composite.rb159
-rw-r--r--lib/sisu/v5/ao_numbering.rb14
-rw-r--r--lib/sisu/v5/src_shared.rb114
-rw-r--r--lib/sisu/v5/src_sisupod_make.rb15
-rw-r--r--lib/sisu/v6/ao_composite.rb159
-rw-r--r--lib/sisu/v6/ao_numbering.rb14
-rw-r--r--lib/sisu/v6/src_shared.rb114
-rw-r--r--lib/sisu/v6/src_sisupod_make.rb15
8 files changed, 372 insertions, 232 deletions
diff --git a/lib/sisu/v5/ao_composite.rb b/lib/sisu/v5/ao_composite.rb
index a7d0e48c..5cdfaa81 100644
--- a/lib/sisu/v5/ao_composite.rb
+++ b/lib/sisu/v5/ao_composite.rb
@@ -101,9 +101,17 @@ module SiSU_Assemble
begin
pwd=Dir.pwd
Dir.chdir(@opt.f_pth[:pth])
- fns_array=IO.readlines(@opt.fno,'')
- assembled=insertions?(fns_array)
- write(assembled)
+ if @opt.fno =~/\S+?\.ssm$/
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Composite Document',
+ "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}",
+ ).grey_title_hi unless @opt.act[:quiet][:set]==:on
+ assembled=loadfile(@opt.fno)
+ #assembled=insertions?(fns_array)
+ write(assembled)
+ write(assembled)
+ end
Dir.chdir(pwd)
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do
@@ -112,6 +120,73 @@ module SiSU_Assemble
ensure
end
end
+ def insert?(para)
+ if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest
+ url($1.strip)
+ elsif para =~/^<<\s+(\S+?\.ss[it])$/
+ loadfilename=$1.strip
+ insert_array=loadfile(loadfilename)
+ file=insertion(loadfilename,insert_array)
+ file[:prepared]
+ else para
+ end
+ end
+ def loadfile(loadfilename)
+ tuned_file=[]
+ begin
+ if FileTest.file?(loadfilename)
+ insert_array=IO.readlines(loadfilename,'')
+ if loadfilename =~/\S+?\.ss[im]$/
+ if (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'loading:',
+ loadfilename,
+ ).txt_grey
+ end
+ insert_array.each do |para|
+ tuned_file << insert?(para)
+ end
+ elsif loadfilename =~/\S+?\.sst$/
+ insert_array.each do |para|
+ tuned_file << para
+ end
+ end
+ end
+ tuned_file=tuned_file.flatten.compact
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
+ ensure
+ end
+ end
+ def url(loadfilename)
+ if loadfilename =~ /((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest
+ loadfilename=$1
+ imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/.
+ match(loadfilename).captures.join +
+ '/_sisu/image' #watch
+ begin
+ require 'uri'
+ require 'open-uri'
+ require 'pp'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
+ error('uri, open-uri or pp NOT FOUND (LoadError)')
+ end
+ image_uri=URI.parse(imagedir)
+ insert=open(loadfilename)
+ insert_array=insert.dup
+ insert.close
+ file=insertion(loadfilename,insert_array)
+ @@imager[image_uri] ||=[]
+ @@imager[image_uri] << file[:images]
+ file[:prepared]
+ end
+ end
def write(assembled)
assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+')
assembled.each {|a| assembled_file << a }
@@ -165,68 +240,6 @@ module SiSU_Assemble
end
file
end
- def insertions?(fns_array)
- tuned_file,imagedir=[],[]
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Composite Document',
- "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}",
- ).grey_title_hi unless @opt.act[:quiet][:set]==:on
- fns_array.each do |para|
- if para =~/^<<\s+(\S+?\.ss[it])$/
- loadfile=$1.strip
- if (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'loading:',
- loadfile,
- ).txt_grey
- end
- tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest
- imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/.
- match(loadfile).captures.join +
- '/_sisu/image' #watch
- begin
- require 'uri'
- require 'open-uri'
- require 'pp'
- rescue LoadError
- SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
- error('uri, open-uri or pp NOT FOUND (LoadError)')
- end
- image_uri=URI.parse(imagedir)
- insert=open(loadfile)
- insert_array=insert.dup
- insert.close
- file=insertion(loadfile,insert_array)
- @@imager[image_uri] ||=[]
- @@imager[image_uri] << file[:images]
- file[:prepared]
- elsif loadfile =~ /\.ss[it]$/ \
- and FileTest.file?(loadfile)
- insert_array=IO.readlines(loadfile,'')
- file=insertion(loadfile,insert_array)
- file[:prepared]
- else
- STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"}
- $process_document = :skip; break #remove this line to continue processing documents that have missing include files
- para
- end
- else tuned_file << para
- end
- tuned_file=tuned_file.flatten.compact
- end
- if @@imager.length >0
- @@imager.each do |d,i|
- i=i.flatten.uniq
- image_info=d + i
- download_images(image_info.flatten)
- end
- end
- tuned_file
- end
end
class CompositeFileList
@@imager={}
@@ -256,23 +269,23 @@ module SiSU_Assemble
@ssm=[@opt.fns]
fns_array.each do |para|
if para =~/^<<\s+(\S+?\.ss[it])$/
- loadfile=$1.strip
+ loadfilename=$1.strip
if (@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'loading:',
- loadfile,
+ loadfilename,
).txt_grey
end
- tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/
- @ssm << loadfile
- elsif loadfile =~ /\.ss[it]$/ \
- and FileTest.file?(loadfile)
- @ssm << loadfile
+ tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/
+ @ssm << loadfilename
+ elsif loadfilename =~ /\.ss[it]$/ \
+ and FileTest.file?(loadfilename)
+ @ssm << loadfilename
else
- STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"}
+ STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"}
$process_document = :skip; break #remove this line to continue processing documents that have missing include files
para
end
diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb
index 278ea514..dc6ec4dd 100644
--- a/lib/sisu/v5/ao_numbering.rb
+++ b/lib/sisu/v5/ao_numbering.rb
@@ -67,6 +67,7 @@ module SiSU_AO_Numbering
def initialize(md,data)
@md,@data=md,data
@obj=@type=@ocn=@lv=@name=@index=@comment=nil
+ @chosen_seg_names=[]
end
def number_of_segments?
if @@segments_count==0
@@ -323,16 +324,23 @@ module SiSU_AO_Numbering
possible_seg_name=possible_seg_name.
gsub(/\.$/,'')
end
- if possible_seg_name =~/^[0-9]+$/m \
+ chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \
and possible_seg_name.to_i <= heading_num_is.to_i
prefix + leading_zeros_fixed_width_number(possible_seg_name)
- elsif possible_seg_name =~/^[\d.,:-]+$/m
+ elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m
possible_seg_name=possible_seg_name.
gsub(/(?:[:,-]|\W)/,'.').
gsub(/\.$/,'')
prefix + possible_seg_name
else prefix + possible_seg_name.to_s
end
+ @chosen_seg_names << chosen_seg_name
+ if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique
+ chosen_seg_name
+ else
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{chosen_seg_name}; manually name level 1 segments '1~given_name'")
+ exit
+ end
end
def name_para_seg_filename(data) #segment naming, remaining
# paragraph name/numbering rules
@@ -369,7 +377,7 @@ module SiSU_AO_Numbering
@md.set_heading_seg=true
end
if dob.name !~/^\S+/ \
- and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name
+ and dob.obj =~/^\s*(?:\S+\s+)?([0-9][0-9.,:-]*)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name
possible_seg_name=$1
possible_seg_name=
auto_seg_name(possible_seg_name,heading_num_is,:extract)
diff --git a/lib/sisu/v5/src_shared.rb b/lib/sisu/v5/src_shared.rb
index 5338a18c..a4b3a974 100644
--- a/lib/sisu/v5/src_shared.rb
+++ b/lib/sisu/v5/src_shared.rb
@@ -80,12 +80,13 @@ module SiSU_Source
processing_sisupod.make
path_pod=processing_sisupod.paths[:sisupod]
path_pod_fnb=processing_sisupod.paths[:fnb]
+ @doc_import_list=[]
FileUtils::mkdir_p(path_pod) unless FileTest.directory?(path_pod)
@path_pod={
fnb: path_pod_fnb,
pod: path_pod,
doc: path_pod + '/' + Gt[:doc] + '/' + opt.lng,
- po: path_pod + '/' + Gt[:po] + '/' + opt.lng,
+ po: path_pod + '/' + Gt[:po] + '/' + opt.lng,
pot: path_pod + '/' + Gt[:pot],
conf: path_pod + '/' + Gt[:conf],
image: path_pod + '/' + Gt[:image],
@@ -98,17 +99,22 @@ module SiSU_Source
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble SiSU source',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue
+ ? SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Assemble SiSU source',
+ "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").
+ green_hi_blue
: ''
end
unless @opt.fns.empty?
directories
- pod_source_build #this needs to be built in case of multi-lingual for all of them, before single pass tar
+ file_array=IO.readlines(@opt.fno,'')
+ doc_import_list=pod_source_build(file_array) #this needs to be built in case of multi-lingual for all of them, before single pass tar
+ doc_import_list=[@opt.fno, doc_import_list].flatten
+ image_extraction(doc_import_list)
+ language_versions
end
end
- def directories
- SiSU_Env::InfoEnv.new.sisupod_v4(@opt)
- end
def images_extract(f,images) # consider using param info
rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m
if f !~/^%+\s/ \
@@ -117,31 +123,17 @@ module SiSU_Source
end
images.flatten
end
- def pod_source_build
- @pwd=Dir.pwd
+ def image_extraction(doc_import_list)
@rgx_rb_image=/["']\S*?([a-zA-Z0-9_-]+?\.(?:png|jpg|gif))["']/
@rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/
- @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/
- file_array=IO.readlines(@opt.fno,'')
- images,doc_import=[],[]
doc_import_dir=@opt.sub_location
- file_array.each do |f| #% work area
- if f !~/^%+\s/
- f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image)
- if f !~/^%+\s/ \
- and f =~@rgx_image
- images=images_extract(f,images)
- end
- if @opt.fno =~/\.ssm$/
- doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import
- end
- end
- end
- if doc_import.length > 0
- doc_import=doc_import.uniq.flatten
- doc_import.each do |fn|
+ images=[]
+ if doc_import_list.length > 0
+ doc_import_list=doc_import_list.uniq.flatten
+ doc_import_list.each do |fn|
file_array=IO.readlines(fn,'')
- file_array.each do |f| #% work area
+ file_array.each do |f| #% work area
+ f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image)
if f !~/^%+\s/ \
and f =~@rgx_image
images=images_extract(f,images)
@@ -153,7 +145,8 @@ module SiSU_Source
unless FileTest.file?("#{@path_pod[:conf]}/#{gi.makefile_name}")
if gi.makefile \
&& FileTest.file?(gi.makefile)
- FileUtils::mkdir_p(@path_pod[:conf]) unless FileTest.directory?(@path_pod[:conf])
+ FileUtils::mkdir_p(@path_pod[:conf]) \
+ unless FileTest.directory?(@path_pod[:conf])
FileUtils::cp(gi.makefile,"#{@path_pod[:conf]}/#{gi.makefile_name}")
end
#get images from makefile, consider placing in param
@@ -181,22 +174,31 @@ module SiSU_Source
images.each do |i|
if FileTest.file?("#{images_pwd}/#{i}")
FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}")
- else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]}
end
end
- else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]}
end
end
- if doc_import.length > 0 \
+ if doc_import_list.length > 0 \
and @opt.fno =~/\.ssm$/
- doc_import.each do |f|
+ doc_import_list.each do |f|
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f}")
FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}")
- else STDERR.puts %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]}
end
end
end
+ end
+ def language_versions
x=@env.document_language_versions_found #check multiple document language versions (param not used)
+ doc_import_dir=@opt.sub_location
if x[:f] \
and x[:f].length > 0 #store multiple document language versions, sisupod
x[:f].each do |f|
@@ -208,7 +210,9 @@ module SiSU_Source
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}")
FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
else
if FileTest.file?("#{@opt.base_path}/#{f[:f]}")
@@ -225,7 +229,9 @@ module SiSU_Source
FileUtils::cp("#{@opt.base_path}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
end
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
end
end
@@ -234,7 +240,9 @@ module SiSU_Source
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}")
FileUtils::cp_r("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
else
if FileTest.file?("#{@opt.base_path}/#{f[:f]}")
@@ -251,13 +259,45 @@ module SiSU_Source
FileUtils::cp("#{@opt.base_path}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
end
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
end
end
end
end #NB not all possibilies met, revisit, also in case of composite file may wish to add README
end
+ def directories
+ SiSU_Env::InfoEnv.new.sisupod_v4(@opt)
+ end
+ def ssm_doc_import_list(f)
+ if @opt.fno =~/\.ssm$/
+ doc_import_list=[]
+ doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import
+ doc_import_list.flatten.each do |i|
+ if i =~/.ssi/
+ file_array=IO.readlines(i,'')
+ pod_source_build(file_array)
+ end
+ end
+ end
+ doc_import_list.uniq.flatten
+ end
+ def pod_source_build(file_array)
+ @pwd=Dir.pwd
+ @rgx_doc_import_list=/^<<\s*(\S+?\.ss[ti])/
+ doc_import_list=[]
+ file_array.each do |f| #% work area
+ if f !~/^%+\s/
+ if @opt.fno =~/\.ssm$/
+ @doc_import_list << ssm_doc_import_list(f)
+ doc_import_list=@doc_import_list.flatten.uniq
+ end
+ end
+ end
+ doc_import_list
+ end
end
end
__END__
diff --git a/lib/sisu/v5/src_sisupod_make.rb b/lib/sisu/v5/src_sisupod_make.rb
index 5ae7313f..4e9c83ba 100644
--- a/lib/sisu/v5/src_sisupod_make.rb
+++ b/lib/sisu/v5/src_sisupod_make.rb
@@ -75,13 +75,22 @@ module SiSU_Doc
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',"#{@opt.fns} -> file://#{pthinfo}").cyan_hi_blue
- : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',pthinfo).cyan_title_hi
+ ? SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Assemble source for sisu document',
+ "#{@opt.fns} -> file://#{pthinfo}").
+ cyan_hi_blue
+ : SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Assemble source for sisu document',
+ pthinfo).
+ cyan_title_hi
end
end
def sisupod_tar_xz
begin
- FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir)
+ FileUtils::mkdir_p(@file.output_path.sisupod.dir) \
+ unless FileTest.directory?(@file.output_path.sisupod.dir)
tree=((@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
diff --git a/lib/sisu/v6/ao_composite.rb b/lib/sisu/v6/ao_composite.rb
index 2f864228..078e8ece 100644
--- a/lib/sisu/v6/ao_composite.rb
+++ b/lib/sisu/v6/ao_composite.rb
@@ -101,9 +101,17 @@ module SiSU_Assemble
begin
pwd=Dir.pwd
Dir.chdir(@opt.f_pth[:pth])
- fns_array=IO.readlines(@opt.fno,'')
- assembled=insertions?(fns_array)
- write(assembled)
+ if @opt.fno =~/\S+?\.ssm$/
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Composite Document',
+ "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}",
+ ).grey_title_hi unless @opt.act[:quiet][:set]==:on
+ assembled=loadfile(@opt.fno)
+ #assembled=insertions?(fns_array)
+ write(assembled)
+ write(assembled)
+ end
Dir.chdir(pwd)
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do
@@ -112,6 +120,73 @@ module SiSU_Assemble
ensure
end
end
+ def insert?(para)
+ if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest
+ url($1.strip)
+ elsif para =~/^<<\s+(\S+?\.ss[it])$/
+ loadfilename=$1.strip
+ insert_array=loadfile(loadfilename)
+ file=insertion(loadfilename,insert_array)
+ file[:prepared]
+ else para
+ end
+ end
+ def loadfile(loadfilename)
+ tuned_file=[]
+ begin
+ if FileTest.file?(loadfilename)
+ insert_array=IO.readlines(loadfilename,'')
+ if loadfilename =~/\S+?\.ss[im]$/
+ if (@opt.act[:verbose][:set]==:on \
+ || @opt.act[:verbose_plus][:set]==:on \
+ || @opt.act[:maintenance][:set]==:on)
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'loading:',
+ loadfilename,
+ ).txt_grey
+ end
+ insert_array.each do |para|
+ tuned_file << insert?(para)
+ end
+ elsif loadfilename =~/\S+?\.sst$/
+ insert_array.each do |para|
+ tuned_file << para
+ end
+ end
+ end
+ tuned_file=tuned_file.flatten.compact
+ rescue
+ SiSU_Errors::Rescued.new($!,$@,@opt.cmd,@opt.fns).location do
+ __LINE__.to_s + ':' + __FILE__
+ end
+ ensure
+ end
+ end
+ def url(loadfilename)
+ if loadfilename =~ /((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest
+ loadfilename=$1
+ imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/.
+ match(loadfilename).captures.join +
+ '/_sisu/image' #watch
+ begin
+ require 'uri'
+ require 'open-uri'
+ require 'pp'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
+ error('uri, open-uri or pp NOT FOUND (LoadError)')
+ end
+ image_uri=URI.parse(imagedir)
+ insert=open(loadfilename)
+ insert_array=insert.dup
+ insert.close
+ file=insertion(loadfilename,insert_array)
+ @@imager[image_uri] ||=[]
+ @@imager[image_uri] << file[:images]
+ file[:prepared]
+ end
+ end
def write(assembled)
assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+')
assembled.each {|a| assembled_file << a }
@@ -165,68 +240,6 @@ module SiSU_Assemble
end
file
end
- def insertions?(fns_array)
- tuned_file,imagedir=[],[]
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Composite Document',
- "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}",
- ).grey_title_hi unless @opt.act[:quiet][:set]==:on
- fns_array.each do |para|
- if para =~/^<<\s+(\S+?\.ss[it])$/
- loadfile=$1.strip
- if (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'loading:',
- loadfile,
- ).txt_grey
- end
- tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ # and NetTest
- imagedir = /((?:https?|file):\/\/\S+?)\/[^\/]+?\.ss[it]$/.
- match(loadfile).captures.join +
- '/_sisu/image' #watch
- begin
- require 'uri'
- require 'open-uri'
- require 'pp'
- rescue LoadError
- SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
- error('uri, open-uri or pp NOT FOUND (LoadError)')
- end
- image_uri=URI.parse(imagedir)
- insert=open(loadfile)
- insert_array=insert.dup
- insert.close
- file=insertion(loadfile,insert_array)
- @@imager[image_uri] ||=[]
- @@imager[image_uri] << file[:images]
- file[:prepared]
- elsif loadfile =~ /\.ss[it]$/ \
- and FileTest.file?(loadfile)
- insert_array=IO.readlines(loadfile,'')
- file=insertion(loadfile,insert_array)
- file[:prepared]
- else
- STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"}
- $process_document = :skip; break #remove this line to continue processing documents that have missing include files
- para
- end
- else tuned_file << para
- end
- tuned_file=tuned_file.flatten.compact
- end
- if @@imager.length >0
- @@imager.each do |d,i|
- i=i.flatten.uniq
- image_info=d + i
- download_images(image_info.flatten)
- end
- end
- tuned_file
- end
end
class CompositeFileList
@@imager={}
@@ -256,23 +269,23 @@ module SiSU_Assemble
@ssm=[@opt.fns]
fns_array.each do |para|
if para =~/^<<\s+(\S+?\.ss[it])$/
- loadfile=$1.strip
+ loadfilename=$1.strip
if (@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
SiSU_Screen::Ansi.new(
@opt.act[:color_state][:set],
'loading:',
- loadfile,
+ loadfilename,
).txt_grey
end
- tuned_file << if loadfile =~ /(?:https?|file):\/\/\S+?\.ss[it]$/
- @ssm << loadfile
- elsif loadfile =~ /\.ss[it]$/ \
- and FileTest.file?(loadfile)
- @ssm << loadfile
+ tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/
+ @ssm << loadfilename
+ elsif loadfilename =~ /\.ss[it]$/ \
+ and FileTest.file?(loadfilename)
+ @ssm << loadfilename
else
- STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfile}"}
+ STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"}
$process_document = :skip; break #remove this line to continue processing documents that have missing include files
para
end
diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb
index ffafbf9c..5b2137e7 100644
--- a/lib/sisu/v6/ao_numbering.rb
+++ b/lib/sisu/v6/ao_numbering.rb
@@ -67,6 +67,7 @@ module SiSU_AO_Numbering
def initialize(md,data)
@md,@data=md,data
@obj=@type=@ocn=@lv=@name=@index=@comment=nil
+ @chosen_seg_names=[]
end
def number_of_segments?
if @@segments_count==0
@@ -323,16 +324,23 @@ module SiSU_AO_Numbering
possible_seg_name=possible_seg_name.
gsub(/\.$/,'')
end
- if possible_seg_name =~/^[0-9]+$/m \
+ chosen_seg_name=if possible_seg_name =~/^[0-9]+$/m \
and possible_seg_name.to_i <= heading_num_is.to_i
prefix + leading_zeros_fixed_width_number(possible_seg_name)
- elsif possible_seg_name =~/^[\d.,:-]+$/m
+ elsif possible_seg_name =~/^[0-9][\d.,:-]*$/m
possible_seg_name=possible_seg_name.
gsub(/(?:[:,-]|\W)/,'.').
gsub(/\.$/,'')
prefix + possible_seg_name
else prefix + possible_seg_name.to_s
end
+ @chosen_seg_names << chosen_seg_name
+ if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique
+ chosen_seg_name
+ else
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).mark("duplicated auto segment name: #{chosen_seg_name}; manually name level 1 segments '1~given_name'")
+ exit
+ end
end
def name_para_seg_filename(data) #segment naming, remaining
# paragraph name/numbering rules
@@ -369,7 +377,7 @@ module SiSU_AO_Numbering
@md.set_heading_seg=true
end
if dob.name !~/^\S+/ \
- and dob.obj =~/^\s*(?:\S+\s+)?([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name
+ and dob.obj =~/^\s*(?:\S+\s+)?([0-9][0-9.,:-]*)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name
possible_seg_name=$1
possible_seg_name=
auto_seg_name(possible_seg_name,heading_num_is,:extract)
diff --git a/lib/sisu/v6/src_shared.rb b/lib/sisu/v6/src_shared.rb
index 4ce34473..cee7e1c5 100644
--- a/lib/sisu/v6/src_shared.rb
+++ b/lib/sisu/v6/src_shared.rb
@@ -80,12 +80,13 @@ module SiSU_Source
processing_sisupod.make
path_pod=processing_sisupod.paths[:sisupod]
path_pod_fnb=processing_sisupod.paths[:fnb]
+ @doc_import_list=[]
FileUtils::mkdir_p(path_pod) unless FileTest.directory?(path_pod)
@path_pod={
fnb: path_pod_fnb,
pod: path_pod,
doc: path_pod + '/' + Gt[:doc] + '/' + opt.lng,
- po: path_pod + '/' + Gt[:po] + '/' + opt.lng,
+ po: path_pod + '/' + Gt[:po] + '/' + opt.lng,
pot: path_pod + '/' + Gt[:pot],
conf: path_pod + '/' + Gt[:conf],
image: path_pod + '/' + Gt[:image],
@@ -98,17 +99,22 @@ module SiSU_Source
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble SiSU source',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").green_hi_blue
+ ? SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Assemble SiSU source',
+ "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").
+ green_hi_blue
: ''
end
unless @opt.fns.empty?
directories
- pod_source_build #this needs to be built in case of multi-lingual for all of them, before single pass tar
+ file_array=IO.readlines(@opt.fno,'')
+ doc_import_list=pod_source_build(file_array) #this needs to be built in case of multi-lingual for all of them, before single pass tar
+ doc_import_list=[@opt.fno, doc_import_list].flatten
+ image_extraction(doc_import_list)
+ language_versions
end
end
- def directories
- SiSU_Env::InfoEnv.new.sisupod_v4(@opt)
- end
def images_extract(f,images) # consider using param info
rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m
if f !~/^%+\s/ \
@@ -117,31 +123,17 @@ module SiSU_Source
end
images.flatten
end
- def pod_source_build
- @pwd=Dir.pwd
+ def image_extraction(doc_import_list)
@rgx_rb_image=/["']\S*?([a-zA-Z0-9_-]+?\.(?:png|jpg|gif))["']/
@rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/
- @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/
- file_array=IO.readlines(@opt.fno,'')
- images,doc_import=[],[]
doc_import_dir=@opt.sub_location
- file_array.each do |f| #% work area
- if f !~/^%+\s/
- f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image)
- if f !~/^%+\s/ \
- and f =~@rgx_image
- images=images_extract(f,images)
- end
- if @opt.fno =~/\.ssm$/
- doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import
- end
- end
- end
- if doc_import.length > 0
- doc_import=doc_import.uniq.flatten
- doc_import.each do |fn|
+ images=[]
+ if doc_import_list.length > 0
+ doc_import_list=doc_import_list.uniq.flatten
+ doc_import_list.each do |fn|
file_array=IO.readlines(fn,'')
- file_array.each do |f| #% work area
+ file_array.each do |f| #% work area
+ f=f.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image)
if f !~/^%+\s/ \
and f =~@rgx_image
images=images_extract(f,images)
@@ -153,7 +145,8 @@ module SiSU_Source
unless FileTest.file?("#{@path_pod[:conf]}/#{gi.makefile_name}")
if gi.makefile \
&& FileTest.file?(gi.makefile)
- FileUtils::mkdir_p(@path_pod[:conf]) unless FileTest.directory?(@path_pod[:conf])
+ FileUtils::mkdir_p(@path_pod[:conf]) \
+ unless FileTest.directory?(@path_pod[:conf])
FileUtils::cp(gi.makefile,"#{@path_pod[:conf]}/#{gi.makefile_name}")
end
#get images from makefile, consider placing in param
@@ -181,22 +174,31 @@ module SiSU_Source
images.each do |i|
if FileTest.file?("#{images_pwd}/#{i}")
FileUtils::cp("#{images_pwd}/#{i}","#{@path_pod[:image]}/#{i}")
- else STDERR.puts %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find image - "#{images_pwd}/#{i}" [#{__FILE__}:#{__LINE__}]}
end
end
- else STDERR.puts %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - #{images_pwd} #{@path_pod[:image]} [#{__FILE__}:#{__LINE__}]}
end
end
- if doc_import.length > 0 \
+ if doc_import_list.length > 0 \
and @opt.fno =~/\.ssm$/
- doc_import.each do |f|
+ doc_import_list.each do |f|
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f}")
FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f}","#{@path_pod[:doc]}/#{f}")
- else STDERR.puts %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find image - "#{@opt.base_path}#{doc_import_dir}/#{f}" [#{__FILE__}:#{__LINE__}]}
end
end
end
+ end
+ def language_versions
x=@env.document_language_versions_found #check multiple document language versions (param not used)
+ doc_import_dir=@opt.sub_location
if x[:f] \
and x[:f].length > 0 #store multiple document language versions, sisupod
x[:f].each do |f|
@@ -208,7 +210,9 @@ module SiSU_Source
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}")
FileUtils::cp("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
else
if FileTest.file?("#{@opt.base_path}/#{f[:f]}")
@@ -225,7 +229,9 @@ module SiSU_Source
FileUtils::cp("#{@opt.base_path}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
end
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
end
end
@@ -234,7 +240,9 @@ module SiSU_Source
if FileTest.file?("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}")
FileUtils::cp_r("#{@opt.base_path}#{doc_import_dir}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}#{doc_import_dir}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
else
if FileTest.file?("#{@opt.base_path}/#{f[:f]}")
@@ -251,13 +259,45 @@ module SiSU_Source
FileUtils::cp("#{@opt.base_path}/#{f[:f]}",
"#{@path_pod[:doc]}/#{f[:n]}")
end
- else STDERR.puts %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
+ else
+ STDERR.puts \
+ %{\t*WARN* did not find - "#{@opt.base_path}/#{f[:f]}" [#{__FILE__}:#{__LINE__}]}
end
end
end
end
end #NB not all possibilies met, revisit, also in case of composite file may wish to add README
end
+ def directories
+ SiSU_Env::InfoEnv.new.sisupod_v4(@opt)
+ end
+ def ssm_doc_import_list(f)
+ if @opt.fno =~/\.ssm$/
+ doc_import_list=[]
+ doc_import_list << f.scan(@rgx_doc_import) if f =~@rgx_doc_import
+ doc_import_list.flatten.each do |i|
+ if i =~/.ssi/
+ file_array=IO.readlines(i,'')
+ pod_source_build(file_array)
+ end
+ end
+ end
+ doc_import_list.uniq.flatten
+ end
+ def pod_source_build(file_array)
+ @pwd=Dir.pwd
+ @rgx_doc_import_list=/^<<\s*(\S+?\.ss[ti])/
+ doc_import_list=[]
+ file_array.each do |f| #% work area
+ if f !~/^%+\s/
+ if @opt.fno =~/\.ssm$/
+ @doc_import_list << ssm_doc_import_list(f)
+ doc_import_list=@doc_import_list.flatten.uniq
+ end
+ end
+ end
+ doc_import_list
+ end
end
end
__END__
diff --git a/lib/sisu/v6/src_sisupod_make.rb b/lib/sisu/v6/src_sisupod_make.rb
index ad58453d..ccac91f8 100644
--- a/lib/sisu/v6/src_sisupod_make.rb
+++ b/lib/sisu/v6/src_sisupod_make.rb
@@ -75,13 +75,22 @@ module SiSU_Doc
(@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \
- ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',"#{@opt.fns} -> file://#{pthinfo}").cyan_hi_blue
- : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Assemble source for sisu document',pthinfo).cyan_title_hi
+ ? SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Assemble source for sisu document',
+ "#{@opt.fns} -> file://#{pthinfo}").
+ cyan_hi_blue
+ : SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Assemble source for sisu document',
+ pthinfo).
+ cyan_title_hi
end
end
def sisupod_tar_xz
begin
- FileUtils::mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir)
+ FileUtils::mkdir_p(@file.output_path.sisupod.dir) \
+ unless FileTest.directory?(@file.output_path.sisupod.dir)
tree=((@opt.act[:verbose][:set]==:on \
|| @opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on) \