aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/dal.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-10-08 12:23:05 +0100
committerRalph Amissah <ralph@amissah.com>2007-10-08 12:23:05 +0100
commit37f81bc4aa6579f269021dfdb3ab84b51f531634 (patch)
treed0254472d94909d6dcba44baf981ef3e8d9adb7b /lib/sisu/v0/dal.rb
parentsisu-0.60.1 + md5s (diff)
dal, shortcut for available outputs, present as grouped text object
this makes more sense for search results - matches all available versions of a document [affects document objects and numbering where used, hence version number bump]
Diffstat (limited to 'lib/sisu/v0/dal.rb')
-rw-r--r--lib/sisu/v0/dal.rb90
1 files changed, 54 insertions, 36 deletions
diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb
index 15d1c55c..95208e2f 100644
--- a/lib/sisu/v0/dal.rb
+++ b/lib/sisu/v0/dal.rb
@@ -188,6 +188,7 @@ module SiSU_DAL
@metafile="#{@env.path.dal}/#{@md.fns}.meta"
my_make_source_file=SiSU_Env::Create_file.new(@md.cmd,@md.fns)
data=data.join.split("\n\n")
+ data=expand_insertions?(data)
data=SiSU_document_structure::Code.new(@md,data).code
data_new=[]
data.each do |x|
@@ -354,41 +355,30 @@ module SiSU_DAL
end
file_type_names=file_type_names.flatten
end
- def substitutions_and_insertions?(data)
- tuned_file=[]
- if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content preceeds it)
- data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'')
- data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'')
- end
- if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier
- data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1')
- data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1')
- end
+ def expand_insertions?(data)
+ tuned_file,tuned_file_tmp=[],[]
data.each do |para|
- para=if @md.markup_version.to_f >= 0.38
- SiSU_document_structure::Structure.new(@md,para).structure_markup_normalize
- else para
- end
- #para.gsub!(/<url:(\S+?)>/,'\1') #consider, would permit use of text hyperlinks if desired, dal_syntax more appropriate?
- para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12
- if para =~/^@\S+?:/
- para.gsub!(/^@(\S+?):\s+/,'0~\1 ')
- para.gsub!(/^@(\S+?):([+-])\s+/,'0~\1\2 ')
- end
if para !~/^%+\s/ and
- para =~/^(?:_\*\s+)?\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.(?:sst|ssm)\b)(?:\s+~\{.+?\}~)?(?:\s+\*~\S+)*\s*$/
+ para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.(?:sst|ssm)\b)(?:\s+~\{.+?\}~)?(?:\s+\*~\S+)*\s*$/
+ #para =~/^(?:_\*\s+)?\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.(?:sst|ssm)\b)(?:\s+~\{.+?\}~)?(?:\s+\*~\S+)*\s*$/
txt,cmd,source,url_dir,note,manifest=nil,nil,nil,nil,nil,nil
url_and_stub=SiSU_Env::Info_env.new.url
if defined? url_and_stub.remote
@output_url="#{url_and_stub.remote}"
- if para =~/\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm])(\s+~\{.+?\}~)?/
+ if para =~/(.+?)\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm])(\s+~\{.+?\}~)?/m
+ #syntax e.g.: { "Sphinx or Robot", Leena Krohn [3sS]}sphinx_or_robot.leena_krohn.1996.sst
+ pre,txt,cmd,source,url_dir,note="#{$1.strip} ",$2,$3,$4,$5,$6
+ elsif para =~/(.+?)\{(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+~\{.+?\}~)?/m
+ #syntax e.g.: { "Sphinx or Robot", Leena Krohn [3sS]}../sphinx_or_robot.leena_krohn.1996/
+ pre,txt,cmd,url_dir,note="#{$1.strip} ",$2,$3,$4,$5
+ elsif para =~/\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm])(\s+~\{.+?\}~)?/
#syntax e.g.: { "Sphinx or Robot", Leena Krohn [3sS]}sphinx_or_robot.leena_krohn.1996.sst
- txt,cmd,source,url_dir,note=$1,$2,$3,$4,$5
+ pre,txt,cmd,source,url_dir,note='',$1,$2,$3,$4,$5
elsif para =~/\{(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+~\{.+?\}~)?/
#syntax e.g.: { "Sphinx or Robot", Leena Krohn [3sS]}../sphinx_or_robot.leena_krohn.1996/
- txt,cmd,url_dir,note=$1,$2,$3,$4
+ pre,txt,cmd,url_dir,note='',$1,$2,$3,$4
end
- manifest="{#{txt} }#@output_url/#{url_dir}/toc.html#{note}\n\n"
+ manifest="#{pre}{#{txt} }#@output_url/#{url_dir}/toc.html#{note}\n\n"
else
puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}"
if para =~/\{(?:~\^\s+)?(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+~\{.+?\}~)?/
@@ -396,7 +386,7 @@ module SiSU_DAL
manifest="{ #{txt} }../#{url_dir}/toc.html#{note}\n\n"
end
end
- tuned_file << manifest
+ tuned_file_tmp << manifest
output_filetypes_in_cmd(cmd,source).each do |o_f|
describe = case o_f
when /sisu_manifest.html/; '~^ document manifest'
@@ -419,13 +409,41 @@ module SiSU_DAL
end
if describe
if @output_url
- tuned_file << "_1 {#{describe} }#@output_url/#{url_dir}/#{o_f}\n\n" if describe
+ tuned_file_tmp << "<:br>&nbsp;&nbsp;&nbsp;&nbsp; {#{describe} }#@output_url/#{url_dir}/#{o_f}\n\n" if describe
else
- tuned_file << "_1 { #{describe} }../#{url_dir}/#{o_f}\n\n"
+ tuned_file_tmp << "<:br>&nbsp;&nbsp;&nbsp;&nbsp; { #{describe} }../#{url_dir}/#{o_f}\n\n"
end
end
end
- elsif para =~/<:insert\d+!?>/ and para !~/^%\s+/
+ tuned_file << 'group{' << tuned_file_tmp.join("\n").strip << '}group'
+ tuned_file_tmp=[]
+ else tuned_file << para
+ end
+ end
+ tuned_file
+ end
+ def substitutions_and_insertions?(data)
+ tuned_file=[]
+ if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content preceeds it)
+ data[0].gsub!(/^#!\s*\/usr\/bin\/sisu/,'')
+ data[0].gsub!(/^#!\s*\/usr\/bin\/env sisu/,'')
+ end
+ if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier
+ data[0].gsub!(/^(SiSU\s*[\d.]*)$/,'% \1')
+ data[0].gsub!(/^(sisu-[\d.]+)$/,'% \1')
+ end
+ data.each do |para|
+ para=if @md.markup_version.to_f >= 0.38
+ SiSU_document_structure::Structure.new(@md,para).structure_markup_normalize
+ else para
+ end
+ #para.gsub!(/<url:(\S+?)>/,'\1') #consider, would permit use of text hyperlinks if desired, dal_syntax more appropriate?
+ para.gsub!(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12
+ if para =~/^@\S+?:/
+ para.gsub!(/^@(\S+?):\s+/,'0~\1 ')
+ para.gsub!(/^@(\S+?):([+-])\s+/,'0~\1\2 ')
+ end
+ if para =~/<:insert\d+!?>/ and para !~/^%\s+/
@skin.select
ins=SiSU_Viz::Inserts.new
case para
@@ -781,13 +799,13 @@ module SiSU_DAL
# auto-numbered endnotes <!e!> <!e_!> -->
when /~\{\s+.+?\}~|~\[[*+]\s+.+?\]~/
para.gsub!(/\s*(\}~|\]~)/,' \1') # required 2003w31
- word_mode=para.scan(/\S+/)
+ word_mode=para.scan(/<:group>\n|\n<:group-end>|\S+/m)
word_mode=endnote_call_number(word_mode)
para=word_mode.join(' ')
endnote_ref+=1
when /~\^(?:\s|$)|<:e>/
#%Note inserts endnotes previously gathered from /^(<!e[:_]!>|[-~]\{{3})/ (in earlier loop)
- word_mode=para.scan(/\S+/)
+ word_mode=para.scan(/<:group>\n|\n<:group-end>|\S+/m)
word_mode=endnote_call_number(word_mode)
para=word_mode.join(' ')
endnote_ref+=1
@@ -985,12 +1003,12 @@ module SiSU_DAL
digest_strip=hash_class.hexdigest(stripped)
unless para =~/<:code>/
case para
- when /~\{[\d*+]+\s+.+?\}~|~\[[*+]\d+\s+.+?\]~/
+ when /~\{[\d*+]+\s+.+?\}~|~\[[*+]\d+\s+.+?\]~/m
en_and_para,en_and_para_digest=[],[]
- para.gsub!(/\s*(\}~|\]~)/,' \1') #watch
- para_plus_en=para.scan(/.*?~\{.+?\}~|.*?~\[.+?\]~/)
- para_tail=if para =~/(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+([\s\S]+)/
- /(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+(.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+>)/.match(para)[1]
+ para.gsub!(/\s*(\}~|\]~)/m,' \1') #watch
+ para_plus_en=para.scan(/.*?~\{.+?\}~|.*?~\[.+?\]~/m)
+ para_tail=if para =~/(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+([\s\S]+)/m
+ /(?:.*?~\{.+?\}~|.*?~\[.+?\]~)+(.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+>)/m.match(para)[1]
else ''
end
para_plus_en << para_tail