aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/param.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v6/param.rb')
-rw-r--r--lib/sisu/v6/param.rb156
1 files changed, 122 insertions, 34 deletions
diff --git a/lib/sisu/v6/param.rb b/lib/sisu/v6/param.rb
index 19769027..bacee802 100644
--- a/lib/sisu/v6/param.rb
+++ b/lib/sisu/v6/param.rb
@@ -65,15 +65,34 @@ module SiSU_Param
require 'uri'
require 'pstore'
rescue LoadError
- SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('uri or pstore NOT FOUND (LoadError)')
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
+ error('uri or pstore NOT FOUND (LoadError)')
end
require_relative 'sysenv' # sysenv.rb
include SiSU_Env
require_relative 'param_make' # param_make.rb
require_relative 'param_identify_markup' # param_identify_markup.rb
@@date=SiSU_Env::InfoDate.new
- @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil
- @doc={ initialise: nil, markup: '', lnks: '', stmp: '', req: {} }
+ @@proc=
+ @@filename_txt=
+ @@filename_texinfo=
+ @@filename_lout_portrait=
+ @@filename_lout_landscape=
+ @@filename_html_scroll=
+ @@filename_html_index=
+ @@filename_html_segtoc=
+ @@filename_semantic=
+ @@filename_rss=
+ @@newfile=
+ @@drr=
+ nil
+ @doc={
+ initialise: nil,
+ markup: '',
+ lnks: '',
+ stmp: '',
+ req: {},
+ }
@@yaml=@@yamladdr=nil
@@trigger=nil
@@lv,@@flag={},{}
@@ -99,7 +118,8 @@ module SiSU_Param
# you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter
# has a path value that is different, however, f_pth is not always set!
Dir.chdir(@opt.f_pth[:pth])
- SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('-- bug alert --')
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
+ error('-- bug alert --')
p 'f_pth ' + @opt.f_pth[:pth]
p 'pwd ' + Dir.pwd
end
@@ -186,7 +206,11 @@ module SiSU_Param
STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}"
s
else
- SiSU_Screen::Ansi.new('v',"*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",@opt.fns).warn unless @opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ 'v',
+ "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped",
+ @opt.fns
+ ).warn unless @opt.act[:quiet][:set]==:on
nil
end
end
@@ -504,7 +528,10 @@ module SiSU_Param
elsif @h['text'] then @h['text']
elsif @h['main'] then @h['main']
else
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Copyright missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'WARNING Document Copyright missing; provide @rights: :copyright:'
+ ).warn unless @opt.act[:quiet][:set]==:on
''
end
l,n=Db[:col_info_note],'rights.copyright.text'
@@ -603,7 +630,10 @@ module SiSU_Param
s +='License: ' + copyright.license
end
if s.empty?
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'WARNING Document Rights information missing; provide @rights: :copyright:'
+ ).warn unless @opt.act[:quiet][:set]==:on
else
l,n=Db[:col_info_note],'rights.all'
validate_length(s,l,n)
@@ -835,8 +865,10 @@ module SiSU_Param
attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,: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,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,: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,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section
def initialize(fns_array,opt)
@env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@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=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil
- @data,@path,@fns,@fno,@opt=fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data
- @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=false,false,false,false,false,false,false
+ @data, @path, @fns, @fno, @opt=
+ fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data
+ @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=
+ false, false, false, false, false, false, false
@seg_autoname_safe=true
@daisy,@sem_tag=false,false
@authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil
@@ -1020,37 +1052,48 @@ module SiSU_Param
@lv4=(makes[:lv4]) ? (makes[:lv4]) : @lv4
@lv5=(makes[:lv5]) ? (makes[:lv5]) : @lv5
@lv6=(makes[:lv6]) ? (makes[:lv6]) : @lv6
- @num_top=(makes[:num_top]) \
+ @num_top=
+ (makes[:num_top]) \
? (makes[:num_top]) \
: @num_top
- @substitution_match_list=(makes[:substitution_match_list]) \
+ @substitution_match_list=
+ (makes[:substitution_match_list]) \
? (makes[:substitution_match_list]) \
: @substitution_match_list
- @bold_match_list=(makes[:bold_match_list]) \
+ @bold_match_list=
+ (makes[:bold_match_list]) \
? (makes[:bold_match_list]) \
: @bold_match_list
- @italics_match_list=(makes[:italics_match_list]) \
+ @italics_match_list=
+ (makes[:italics_match_list]) \
? (makes[:italics_match_list]) \
: @italics_match_list
- @emphasis_set_to=(makes[:emphasis_set_to]) \
+ @emphasis_set_to=
+ (makes[:emphasis_set_to]) \
? (makes[:emphasis_set_to]) \
: @emphasis_set_to
- @i18n=(makes[:i18n]) \
+ @i18n=
+ (makes[:i18n]) \
? (makes[:i18n]) \
: @i18n
- @man_section=(makes[:man_section]) \
+ @man_section=
+ (makes[:man_section]) \
? (makes[:man_section]) \
: @man_section
- @footer_links=(makes[:footer_links]) \
+ @footer_links=
+ (makes[:footer_links]) \
? (makes[:footer_links]) \
: @footer_links
- @home_button_links=(makes[:home_button_links]) \
+ @home_button_links=
+ (makes[:home_button_links]) \
? (makes[:home_button_links]) \
: @home_button_links
- @home_button_image=(makes[:home_button_image]) \
+ @home_button_image=
+ (makes[:home_button_image]) \
? (makes[:home_button_image]) \
: @home_button_image
- @cover_image=(makes[:cover_image]) \
+ @cover_image=
+ (makes[:cover_image]) \
? (makes[:cover_image]) \
: @cover_image
end
@@ -1117,10 +1160,14 @@ module SiSU_Param
: ''
title=@title.full.gsub(/\s*(?:<p>|<p \/>|<br>|<br \/>)\s*/,' ').
gsub(/~\{.+?\}~/,'')
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Parameters',%{#{title}#{creator}}).txt_grey if @opt.act[:verbose][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'Parameters',
+ %{#{title}#{creator}}
+ ).txt_grey if @opt.act[:verbose][:set]==:on
end
if not @book_idx \
- and para =~/^=\{(.+?)\}\s*$/
+ and para =~/^=\{(.+?)\}[\s`]*\Z/m
@book_idx=true
end
unless @code_flag
@@ -1151,11 +1198,11 @@ module SiSU_Param
elsif para =~/^1~\s+(.+)$/
t=$1
end
- unless @heading_seg_first_flag # extract first segment name
+ unless @heading_seg_first_flag # extract first segment name
@heading_seg_first=t
@heading_seg_first_flag=true
end
- if m # list all segment names
+ if m # list all segment names
@seg_names << m
@set_heading_seg=true
if m=~/^\d{1,3}/ \
@@ -1164,7 +1211,7 @@ module SiSU_Param
end
end
end
- para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image)
+ para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image)
if para !~/^%+\s/ \
and para =~@rgx_image
@ec[:image] << para.scan(@rgx_image).uniq
@@ -1178,7 +1225,11 @@ module SiSU_Param
unless @make
if (@opt.act[:verbose_plus][:set]==:on \
|| @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'@make:','header absent').warn
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ '@make:',
+ 'header absent'
+ ).warn
end
@make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make
end
@@ -1318,15 +1369,25 @@ module SiSU_Param
if @en[:note] > 0 \
and @en[:sum] > 0
if @en[:sum] > 0
- else SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}").warn unless @opt.act[:quiet][:set]==:on
+ else
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ '*WARN* both endnote styles used',
+ "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}"
+ ).warn unless @opt.act[:quiet][:set]==:on
end
end
if @en[:mark] != @en[:note] \
and @en[:note] > 0
@en[:mismatch]=@en[:note] - @en[:mark]
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'*WARN* endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn unless @opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ '*WARN* endnote number mismatch',
+ "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})"
+ ).warn unless @opt.act[:quiet][:set]==:on
footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a')
- footnote_conversion_errors << "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n"
+ footnote_conversion_errors <<
+ "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n"
end
if not @title \
or not defined? @title.main \
@@ -1335,7 +1396,11 @@ module SiSU_Param
and @opt.inspect =~/P/
#@title=Md.new('Text Insert',@opt,@env).title
else
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Title missing','please provide @title:').warn unless @opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'WARNING: Document Title missing',
+ 'please provide @title:'
+ ).warn unless @opt.act[:quiet][:set]==:on
end
end
if @author !~/[\S]/
@@ -1343,7 +1408,11 @@ module SiSU_Param
and @opt.inspect =~/P/
#@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator
else
- SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'WARNING: Document Author missing','please provide @creator: :author:').warn unless @opt.act[:quiet][:set]==:on
+ SiSU_Screen::Ansi.new(
+ @opt.act[:color_state][:set],
+ 'WARNING: Document Author missing',
+ 'please provide @creator: :author:'
+ ).warn unless @opt.act[:quiet][:set]==:on
end
end
@struct={}
@@ -1426,7 +1495,10 @@ module SiSU_Param
File.unlink(pstorefile) if FileTest.file?(pstorefile)
if (@md.opt.act[:verbose_plus][:set]==:on \
|| @md.opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set],"PStore -> #{pstorefile}").txt_grey
+ SiSU_Screen::Ansi.new(
+ @md.opt.act[:color_state][:set],
+ "PStore -> #{pstorefile}"
+ ).txt_grey
end
store=PStore.new(pstorefile)
store.transaction do
@@ -1447,10 +1519,26 @@ module SiSU_Param
class Instantiate
def param_instantiate
@@date=SiSU_Env::InfoDate.new
- @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil
+ @@proc=
+ @@filename_txt=
+ @@filename_texinfo=
+ @@filename_lout_portrait=
+ @@filename_lout_landscape=
+ @@filename_html_scroll=
+ @@filename_html_index=
+ @@filename_html_segtoc=
+ @@filename_semantic=
+ @@filename_rss=
+ @@newfile=
+ @@drr=
+ nil
@doc={
initialise: nil,
- markup: '', lnks: '', stmp: '', prefix_a: '', prefix_b: '',
+ markup: '',
+ lnks: '',
+ stmp: '',
+ prefix_a: '',
+ prefix_b: '',
req: {}
}
@@yaml=@@yamladdr=nil