diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v0/param.rb | 240 |
1 files changed, 128 insertions, 112 deletions
diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index 2829abe1..0d2095dd 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -118,7 +118,7 @@ module SiSU_Param @doc={ :lv=>[] } @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' @@publisher='SiSU scribe' - attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec,:opt,:sem_tag,:book_idx,:topic_register,:original_publication_details + attr_accessor :cmd,:mod,:env,:fn,:fns,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:sfx,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:site_skin,:sisu,:sisu_version,:ruby_version,:title,:dc_title,:html_title,:subtitle,:subtitle_tex,:creator_home,:dc_creator,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:dc_subject,:dc_description,:dc_publisher,:dc_contributor,:dc_date,:dc_date_created,:dc_date_issued,:dc_date_available,:dc_date_valid,:dc_date_modified,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:dc_type,:dc_format,:dc_identifier,:dc_source,:dc_language,:language_original,:dc_relation,:dc_coverage,:dc_rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:pagenew,:pagebreak,:num_top,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:flag_auto_heading_num,:markup,:markup_instruction,:markup_version,:markup_declared,:make_bold,:make_italic,:flag_tables,:vocabulary,:doc_skin,:doc_css,:yaml,:lnk,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:file_size,:user,:home,:hostname,:pwd,:firstseg,:programs,:creator_copymark,:lang,:en,:dgst,:dgst_skin,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:man_section,:man_name,:man_synopsis,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original_publication_details def initialize(fns_array,opt) @env=@fn=@fns=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@sfx=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@site_skin=@sisu=@sisu_version=@ruby_version=@title=@dc_title=@html_title=@subtitle=@subtitle_tex=@creator_home=@dc_creator=@translator=@illustrator=@prepared_by=@digitized_by=@dc_subject=@dc_description=@dc_publisher=@dc_contributor=@dc_date=@dc_date_created=@dc_date_issued=@dc_date_available=@dc_date_valid=@dc_date_modified=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@dc_type=@dc_format=@dc_identifier=@dc_source=@dc_language=@language_original=@dc_relation=@dc_coverage=@dc_rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@num_top=@toc_lev_limit=@flag_auto_heading_num=@make_bold=@make_italic=@flag_tables=@vocabulary=@doc_skin=@doc_css=@yaml=@lnk=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@file_size=@firstseg=@programs=@creator_copymark=@lang=@en=@dgst=@dgst_skin=@generated=@heading_seg_first=@base_program=@man_synopsis=@topic_register=@original_publication_details=nil @man_section=1 @@ -131,8 +131,7 @@ module SiSU_Param @markup=@markup_instruction #use @markup_instruction @doc,@fn,@make_italic,@make_bold,@tag_hash,@ec={},{},{},{},{},{},{} @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} - @authors=[] - @papersize_array=[] + @authors,@topic_register_array,@papersize_array=[],[],[] @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg @@ -152,6 +151,42 @@ module SiSU_Param else 'A4' end end + def name_format(name) + name.strip! + @name_a_h=[] + authors=name.scan(/[^;]+/) + authors.each do |a| + if a =~/"(.+?)"/ + @name_a_h << { :the => $1 } + else #if a =~/,/ + x=a.scan(/[^,]+/) + if x.length == 1 + @name_a_h << { :the => x[0].strip } + elsif x.length == 2 + @name_a_h << { :the => x[0].strip, :others => x[1].strip } + else #p x.length + end + end + end + l = @name_a_h.length + name_str='' + @name_a_h.each_with_index do |a,i| + name_str += if a[:others] + if (l - i) > 1 + "#{a[:others].strip} #{a[:the].strip}, " + else + "#{a[:others].strip} #{a[:the].strip}" + end + else + if (l - i) > 2 + "#{a[:the].strip}, " + else + "#{a[:the].strip}" + end + end + end + {:name_a_h =>@name_a_h,:name_str =>name_str} + end def extract @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] @programs,@wc,@dc_language,@language_original={},{},{},{} @@ -267,12 +302,12 @@ module SiSU_Param when /^\}code\s*$/; false else @code_flag end - regx_header=/^(?:0~|@\S+?:[+-]?\s)/ + regx_header=/^(?:@\S+?:[+-]?\s|0~\S+)/ if para =~regx_header \ and not @code_flag #or para=~/^(?:1|:?A)~/ case para - when /^(?:0~ocn|@ocn:)\s+(.+?)$/m; @ocn=$1 #% processing - when /^(?:0~title|@title:)\s+(.+?)$/m #% metainfo DC + when /^(?:@ocn:|0~ocn)\s+(.+?)$/m; @ocn=$1 #% processing + when /^(?:@title:|0~title)\s+(.+?)$/m #% metainfo DC @title=$1.strip @dc_title=@title.dup @html_title=@title.gsub(/(<p>|<p \/>|<br>|<br \/>)/,'') @@ -281,66 +316,37 @@ module SiSU_Param @html_title.chomp!(' ') tell=SiSU_Screen::Ansi.new(@cmd,'Parameters',@html_title) tell.txt_grey unless @cmd =~/q/ - when /^(?:0~subtitle|@subtitle:)\s+(.+?)$/m #% metainfo + when /^(?:@subtitle:|0~subtitle)\s+(.+?)$/m #% metainfo @subtitle=$1.strip @dc_title="#{@title} - #{@subtitle}" @subtitle_tex=@subtitle - when /^(?:0~(creator|author)-?|@(creator|author)-?:)\s+/ #% metainfo DC - if para[/(?:0~|@)(?:creator|author):?\s+((?:https?|ftp)\S+)\s+(.+?)$/m] - @creator_home, @dc_creator=$1,$2 - else @dc_creator=/(?:0~|@)(?:creator|author)-?:?\s+(.+?)$/m.match(para)[1] - end - @dc_creator.strip! - authors=@dc_creator.scan(/[^;]+/) - authors.each do |a| - if a =~/"(.+?)"/ - @authors << { :the => $1 } - else #if a =~/,/ - x=a.scan(/[^,]+/) - if x.length == 1 - @authors << { :the => x[0].strip } - elsif x.length == 2 - @authors << { :the => x[0].strip, :others => x[1].strip } - else #p x.length - end - end - end - l = @authors.length - authorship='' - @authors.each_with_index do |a,i| - authorship += if a[:others] - if (l - i) > 1 - "#{a[:others].strip} #{a[:the].strip}, " - else - "#{a[:others].strip} #{a[:the].strip}" - end - else - if (l - i) > 2 - "#{a[:the].strip}, " - else - "#{a[:the].strip}" - end - end - end - @authorship=@dc_creator=authorship - when /^(?:0~(?:translator|translated_by)|@(?:translator|translated_by):)\s+(.+?)$/m #% metainfo - @translator=$1 - when /^(?:0~(?:illustrator|illustrated_by)|@(?:illustrator|illustrated_by):)\s+(.+?)$/m #% metainfo - @illustrator=$1 - when /^(?:0~prepared_by|@prepared_by:)\s+(.+?)$/m #% metainfo - @prepared_by=$1 - when /^(?:0~digitized_by|@digitized_by:)\s+(.+?)$/m #% metainfo DC - @digitized_by=$1 - when /^(?:0~subject|@subject:)\s+(.+?)$/m #% metainfo DC + when /^(?:@(?:creator|author)-?:|0~(?:creator|author)-?)\s+(.+?)$/ #% metainfo DC + names=name_format($1) + @authorship=@dc_creator=names[:name_str] + @authors=names[:name_a_h] + when /^(?:@(?:translator|translated_by):|0~(?:translator|translated_by))\s+(.+?)$/m #% metainfo + names=name_format($1) + @translator=names[:name_str] + when /^(?:@(?:illustrator|illustrated_by):|0~(?:illustrator|illustrated_by))\s+(.+?)$/m #% metainfo + names=name_format($1) + @illustrator=names[:name_str] + when /^(?:@prepared_by:|0~prepared_by)\s+(.+?)$/m #% metainfo + names=name_format($1) + @prepared_by=names[:name_str] + when /^(?:@digitized_by:|0~digitized_by)\s+(.+?)$/m #% metainfo DC + names=name_format($1) + @digitized_by=names[:name_str] + when /^(?:@subject:|0~subject)\s+(.+?)$/m #% metainfo DC @dc_subject=$1 - when /^(?:0~description|@description:)\s+(.+?)$/m #% metainfo DC & rss feed + when /^(?:@description:|0~description)\s+(.+?)$/m #% metainfo DC & rss feed @dc_description=$1 - when /^(?:0~contributor|@contributor:)\s+(.+?)$/m #% metainfo DC - @dc_contributor=$1 - when /^(?:0~publisher|@publisher:)\s+(.+?)$/m #% metainfo DC + when /^(?:@contributor:|0~contributor)\s+(.+?)$/m #% metainfo DC + names=name_format($1) + @dc_contributor=names[:name_str] + when /^(?:@publisher:|0~publisher)\s+(.+?)$/m #% metainfo DC @dc_publisher=$1 - when /^(?:0~|@)date.+?$/m #% metainfo DC - if para =~/(?:0~date|@date:)\s+(.+?)$/m + when /^(?:@|0~)date.+?$/m #% metainfo DC + if para =~/(?:@date:|0~date)\s+(.+?)$/m @dc_date=$1.strip if @dc_date !~regx_date \ and not @dc_date.empty? @@ -349,7 +355,7 @@ module SiSU_Param end @date_scheme='scheme="ISO-8601"' if @dc_date =~/\d{4}-\d{2}-\d{2}/ end - if para =~/(?:0~date\.created|@date\.created:)\s*(.+?)$/m + if para =~/(?:@date\.created:|0~date\.created)\s*(.+?)$/m date=$1.strip if date !~regx_date \ and not date.empty? @@ -359,7 +365,7 @@ module SiSU_Param @dc_date_created=date @date_created_scheme='scheme="ISO-8601"' if date =~/\d{4}-\d{2}-\d{2}/ end - if para =~/(?:0~date\.issued|@date\.issued:)\s*(.+?)$/m + if para =~/(?:@date\.issued:|0~date\.issued)\s*(.+?)$/m date=$1.strip if date !~regx_date \ and not date.empty? @@ -369,7 +375,7 @@ module SiSU_Param @dc_date_issued=date @date_issued_scheme='scheme="ISO-8601"' if date =~/\d{4}-\d{2}-\d{2}/ end - if para =~/(?:0~date\.available|@date\.available:)\s*(.+?)$/m + if para =~/(?:@date\.available:|0~date\.available)\s*(.+?)$/m date=$1.strip if date !~regx_date \ and not date.empty? @@ -379,7 +385,7 @@ module SiSU_Param @dc_date_available=date @date_available_scheme='scheme="ISO-8601"' if date =~/\d{4}-\d{2}-\d{2}/ end - if para =~/^(?:0~date\.valid|@date\.valid:)\s*(.+?)$/m + if para =~/^(?:@date\.valid:|0~date\.valid)\s*(.+?)$/m date=$1.strip if date !~regx_date \ and not date.empty? @@ -389,7 +395,7 @@ module SiSU_Param @dc_date_valid=date @date_valid_scheme='scheme="ISO-8601"' if date =~/\d{4}-\d{2}-\d{2}/ end - if para =~/^(?:0~date\.modified|@date\.modified:)\s*(.+?)$/m #% of interest rss feed & sitemap + if para =~/^(?:@date\.modified:|0~date\.modified)\s*(.+?)$/m #% of interest rss feed & sitemap date=$1.strip if date !~regx_date \ and not date.empty? @@ -399,33 +405,33 @@ module SiSU_Param @dc_date_modified=date @date_modified_scheme='scheme="ISO-8601"' if date =~/\d{4}-\d{2}-\d{2}/ end - when /^(?:0~type|@type:)\s+(.+?)$/m; @dc_type=$1 #% metainfo DC - when /^(?:0~format|@format:)\s+(.+?)$/m; @dc_format=$1 #% metainfo DC - #when /^(?:0~identifier|@identifier:)\s+(.+?)$/m; @dc_identifier=$1 #% metainfo DC - when /^(?:0~source|@source:)\s+(.+?)$/m; @dc_source=$1 #% metainfo DC - when /^(?:0~language(?:\.document)?|@language(?:\.document)?:)\s+(.+?)$/m #% metainfo DC + when /^(?:@type:|0~type)\s+(.+?)$/m; @dc_type=$1 #% metainfo DC + when /^(?:@format:|0~format)\s+(.+?)$/m; @dc_format=$1 #% metainfo DC + #when /^(?:@identifier:|0~identifier)\s+(.+?)$/m; @dc_identifier=$1 #% metainfo DC + when /^(?:@source:|0~source)\s+(.+?)$/m; @dc_source=$1 #% metainfo DC + when /^(?:@language(?:\.document)?:|0~language(?:\.document)?)\s+(.+?)$/m #% metainfo DC x=$1.strip lang=SiSU_Env::Standardise_language.new(x.dup) @dc_language[:code]=lang.code @dc_language[:name]=lang.title - when /^(?:0~language\.original|@language\.original:)\s+(.+?)$/m #% metainfo DC + when /^(?:@language\.original:|0~language\.original)\s+(.+?)$/m #% metainfo DC x=$1.strip lang=SiSU_Env::Standardise_language.new(x.dup) @language_original[:name]=lang.title - when /^(?:0~relation|@relation:)\s+(.+?)$/m; @dc_relation=$1 #% metainfo DC - when /^(?:0~coverage|@coverage:)\s+(.+?)$/m; @dc_coverage=$1 #% metainfo DC - when /^(?:0~rights|@rights:)\s+(.+?)$/m; @dc_rights=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC copyright, public domain, copyleft, creative commons, etc. - when /^(?:0~papersize|@papersize:)\s+(.+?)$/m #% metainfo DC + when /^(?:@relation:|0~relation)\s+(.+?)$/m; @dc_relation=$1 #% metainfo DC + when /^(?:@coverage:|0~coverage)\s+(.+?)$/m; @dc_coverage=$1 #% metainfo DC + when /^(?:@rights:|0~rights)\s+(.+?)$/m; @dc_rights=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC copyright, public domain, copyleft, creative commons, etc. + when /^(?:@papersize:|0~papersize)\s+(.+?)$/m #% metainfo DC l=$1 if @mod.inspect !~/--papersize[=-]\S+/ l=determine_papersize(l.dup) @papersize=l end - when /^(?:0~keywords?|@keywords?:?)\s+(.+?)$/m; @keywords=$1 #% metainfo DC - when /^(?:0~comments?|@comments?:?)\s+(.+?)$/m; @comments=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC - when /^(?:0~abstract|@abstract)\s+(.+?)$/m; @abstract=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC - when /^(?:0~tags?|@tags?:)\s+\S/m #% metainfo - tags=para.match(/^(?:0~tags?|@tags?:)\s+(.+)\Z/m)[1] + when /^(?:@keywords?:|0~keywords?)\s+(.+?)$/m; @keywords=$1 #% metainfo DC + when /^(?:@comments?:|0~comments?)\s+(.+?)$/m; @comments=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC + when /^(?:@abstract:|0~abstract)\s+(.+?)$/m; @abstract=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC + when /^(?:@tags?:|0~tags?)\s+\S/m #% metainfo + tags=para.match(/^(?:@tags?:|0~tags?)\s+(.+)\Z/m)[1] tags.split(/,|$/).each do |tag| tag.strip! @tags << tag @@ -434,18 +440,18 @@ module SiSU_Param tag_a=tag_a.split(/:/).join('][') @tag_a << tag_a end - when /^(?:0~catalogue|@catalogue:)\s+(.+)?$/m #% metainfo + when /^(?:@catalogue:|0~catalogue)\s+(.+)?$/m #% metainfo m=$1 @cls_pg=m.match(/pg=(\S+)/)[1] if m =~/pg=/ @cls_isbn=m.match(/isbn=(\S+)/)[1] if m =~/isbn=/ @cls_dewey=m.match(/dewey=(\S+)/)[1] if m =~/dewey=/ @cls_loc=m.match(/loc=(\S+)/)[1] if m =~/loc=/ - when /^(?:0~class(?:ify)?_loc|@class(?:ify)?_loc:)\s+(.+?)$/m; @cls_loc=$1 #% metainfo - when /^(?:0~class(?:ify)?_dewey|@class(?:ify)?_dewey:)\s+(.+?)$/m; @cls_dewey=$1 #% metainfo - when /^(?:0~class(?:ify)?_pg|@class(?:ify)?_pg)\s+(.+?)$/m; @cls_pg=$1 #% metainfo - when /^(?:0~(?:class(?:ify)?_)?isbn|@(?:class(?:ify)?_)?isbn)\s+(\S+?)$/m; @cls_isbn=$1 #% metainfo - when /^(?:0~images?|@images?:)\s+(.+?)$/m; @image=$1 #% processing - when /^(?:0~(?:toc|structure)|@(?:toc|structure):)\s+(.+?)\Z/m #% processing + when /^(?:@class(?:ify)?_loc:|0~class(?:ify)?_loc)\s+(.+?)$/m; @cls_loc=$1 #% metainfo + when /^(?:@class(?:ify)?_dewey:|0~class(?:ify)?_dewey)\s+(.+?)$/m; @cls_dewey=$1 #% metainfo + when /^(?:@class(?:ify)?_pg:|0~class(?:ify)?_pg)\s+(.+?)$/m; @cls_pg=$1 #% metainfo + when /^(?:@(?:class(?:ify)?_)?isbn:|0~(?:class(?:ify)?_)?isbn)\s+(\S+?)$/m; @cls_isbn=$1 #% metainfo + when /^(?:@images?:|0~images?)\s+(.+?)$/m; @image=$1 #% processing + when /^(?:@(?:toc|structure):|0~(?:toc|structure))\s+(.+?)\Z/m #% processing doc_toc_str=$1 @toc=doc_toc_str.split(/;\s*/) @toc=[ @toc ] if @toc == String @@ -462,8 +468,8 @@ module SiSU_Param @lv5=/^#{lv5}/ lv6=@toc[5] ||='6~ ' @lv6=/^#{lv6}/ - when /^(?:0~(?:level|page|markup)|@(?:level|page|markup):)\s+(.+?)$/m #% processing revisit..., use syntax 0~level new=1,2,3; break=4 - if para =~/(?:0~|@)(?:markup|level|page):?\s+(.+?)\Z/m + when /^(?:@(?:level|page|markup):|0~(?:level|page|markup))\s+(.+?)$/m #% processing revisit..., use syntax 0~level new=1,2,3; break=4 + if para =~/(?:@|0~)(?:markup|level|page):?\s+(.+?)\Z/m page_break_str=$1 pagebreaks=page_break_str.split(/;\s*/) #pagebreaks=[ pagebreaks ] if pagebreaks == String @@ -480,11 +486,11 @@ module SiSU_Param @toc_lev_limit=toc_lev_limit if toc_lev_limit @flag_auto_heading_num=true if para =~/num_top/ end - if para =~/^(?:0~markup|@markup:)\s+(.+?)$/m #%use of markup depreciated for num_top + if para =~/^(?:@markup:|0~markup)\s+(.+?)$/m #%use of markup depreciated for num_top @markup=$1 @flag_auto_heading_num=true if para =~/num_top/ end - when /^(?:0~bold|@bold:)\s+(.+?)$/m #% processing + when /^(?:@bold:|0~bold)\s+(.+?)$/m #% processing m=$1.strip x=case m when /\/i$/; 'i' @@ -498,7 +504,7 @@ module SiSU_Param else /#{rgx}/ end @make_bold - when /^(?:0~(?:italics?|itali[sz]e)|@(?:italics?|itali[sz]e):)\s+(.+?)$/m #% processing Dublin Core - dublin core within + when /^(?:@(?:italics?|itali[sz]e):|0~(?:italics?|itali[sz]e))\s+(.+?)$/m #% processing Dublin Core - dublin core within m=$1.strip x=case m when /\/i$/; 'i' @@ -512,11 +518,11 @@ module SiSU_Param else /#{rgx}/ end @make_italic - when /^(?:0~(?:vocabulary|wordlist)|@(?:vocabulary|wordlist):)\s+(.+?)$/m #% processing + when /^(?:@(?:vocabulary|wordlist):|0~(?:vocabulary|wordlist))\s+(.+?)$/m #% processing @vocabulary=$1 #not actually used by concordance - when /^(?:0~skin|@skin:)\s+(.+?)$/; @doc_skin=$1.strip #% processing - when /^(?:0~(?:css|stylesheet)|@(?:css|stylesheet):)\s+(.+?)$/; @doc_css=$1.strip #% processing - when /^(?:0~links|@links:)\s+(.+?)\Z/m #% processing + when /^(?:@skin:|0~skin)\s+(.+?)$/; @doc_skin=$1.strip #% processing + when /^(?:@(?:css|stylesheet):|0~(?:css|stylesheet))\s+(.+?)$/; @doc_css=$1.strip #% processing + when /^(?:@links:|0~links)\s+(.+?)\Z/m #% processing doc_links_str=$1 @lnk=[] if doc_links_str=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ @@ -540,40 +546,50 @@ module SiSU_Param end end end - when /^(?:0~prefix(?:_[ab])?|@prefix(?:_[ab])?:)\s/ #% metainfo + when /^(?:@prefix(?:_[ab])?:|0~prefix(?:_[ab])?)\s/ #% metainfo if para =~/prefix_a:?\s+/ - @prefix_a=para[/(?:0~prefix_a|@prefix_a:)\s+(.+?)$/im,1] + @prefix_a=para[/(?:@prefix_a:|0~prefix_a)\s+(.+?)$/im,1] end if para =~/prefix(?:_b)?:?\s+/ - @prefix_b=para[/(?:0~prefix(?:_b)?|@prefix(?:_b)?:)\s+(.+?)$/im,1] + @prefix_b=para[/(?:@prefix(?:_b)?:|0~prefix(?:_b)?)\s+(.+?)$/im,1] + end + when /^(?:@suffix:|0~suffix)\s+(.+?)$/m; @suffix=$1 #% metainfo + when /^(?:@information:|0~information)\s+(.+?)$/m; @information=$1 #% metainfo + when /^(?:@topic_register:|0~topic_register)\s+(.+?)$/m; @topic_register=$1 #% metainfo, similar syntax to book index, leave out the ={} i.e. use equivalent of ={(.+?)} + u=@topic_register.scan(/[^;]+/) + v=[] + u.each do |l| + v << l.scan(/[^:]+/) + end + v.each do |m| + m[-1]=m[-1].scan(/[^|]+/) if m[-1] =~/[|]/ + @topic_register_array << m end - when /^(?:0~suffix|@suffix:)\s+(.+?)$/m; @suffix=$1 #% metainfo - when /^(?:0~information|@information:)\s+(.+?)$/m; @information=$1 #% metainfo - when /^(?:0~topic_register|@topic_register:)\s+(.+?)$/m; @topic_register=$1 #% metainfo, similar syntax to book index, leave out the ={} i.e. use equivalent of ={(.+?)} - when /^(?:0~contact|@contact:)\s+(.+?)$/m; @contact=$1 #% metainfo - when /^(?:0~original_publication|@original_publication:)\s+(.+?)$/m; @original_publication=$1 #% details of original publication - when /^(?:0~icon|@icon:)\s+(.+?)$/m; @icon=$1 #% processing - when /^(?:0~promo|@promo:)\s+(.+?)$/m + @topic_register_array.sort! + when /^(?:@contact:|0~contact)\s+(.+?)$/m; @contact=$1 #% metainfo + when /^(?:@original_publication:|0~original_publication)\s+(.+?)$/m; @original_publication=$1 #% details of original publication + when /^(?:@icon:|0~icon)\s+(.+?)$/m; @icon=$1 #% processing + when /^(?:@promo:|0~promo)\s+(.+?)$/m @flag_promo=true @promo=$1.split(/[,;]\s*/) - when /^(?:0~ad|@ad:)\s+(\S+)?\s+(\S+\.png)?\s+(.+?!)\s+(\d+)\s*$/m #% processing + when /^(?:@ad:|0~ad)\s+(\S+)?\s+(\S+\.png)?\s+(.+?!)\s+(\d+)\s*$/m #% processing @ad_url,@ad_png,@ad_alt,@ad_began=$1,$2,$3,$4 when /0~ad\.home\s+(.+)?\s*$/m #% processing ad_home_str=$1 @ad_home=ad_home_str.split(/\s+!/) - when /^(?:0~sta?mp(?:ed)?|@sta?mp(?:ed)?:)\s+(.+?)$/m; @stmp= $1.downcase! #% processing - when /^(?:0~(?:rcs|cvs)|@(?:rcs|cvs):)\+?\s+/ #% processing - m=/(?:0~(?:rcs|cvs)|@(?:rcs|cvs):)\+?\s+/ #note the + sign to turn on use of rcs or cvs id + when /^(?:@sta?mp(?:ed)?:|0~sta?mp(?:ed)?)\s+(.+?)$/m; @stmp= $1.downcase! #% processing + when /^(?:@(?:rcs|cvs):|0~(?:rcs|cvs))\+?\s+/ #% processing + m=/(?:@(?:rcs|cvs):|0~(?:rcs|cvs))\+?\s+/ #note the + sign to turn on use of rcs or cvs id ver=para[/#{m}(.+)/,1] #RCS or CVS ID tag # eg. # $Id$ contains=/[\$]Id:\s+(\S+),v\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+Exp\s+(?:\S+\s+)?[\$]/ # reason for [$] which is apparently unnecessary is that rcs or cvs will otherwise expand id! if contains.match(ver) filename,vnumber,date,time,operator=contains.match(ver).captures @sc_filename,@sc_number,@sc_date,@sc_time=filename,vnumber,date,time end - @sc_info=true if para[/(?:0~(?:rcs|cvs)|@(?:rcs|cvs):)\+/] + @sc_info=true if para[/(?:@(?:rcs|cvs):|0~(?:rcs|cvs))\+/] when /^@base_program:\s+(.+?)$/; @base_program=$1 #% processing #% break - break, not necessary to process headers further :-) but necessary to extract endnotes etc. ;-( - when /^(?:0~man|@man:)\s+(.+?)\Z/m #% man pages + when /^(?:@man:|0~man)\s+(.+?)\Z/m #% man pages maninfo_str=$1 maninfo=maninfo_str.split(/;\s*/m) maninfo.each do |x| |