aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2008-09-15 21:52:19 -0400
committerRalph Amissah <ralph@amissah.com>2008-09-15 21:52:19 -0400
commit87a7cfcd56eed6746b1500c88df3fc3e76a81668 (patch)
tree9e653d09f0e8c130273ef5ef3e7be0daf12d6007 /lib/sisu
parentdal_idx, and concordance, letter list for navigation (diff)
various small fixes
* html segments, name more accurately * rough description of how book index markup works * clean out book index from these outputs * book markup sample, free as in freedom, start doing book index, only letter "A" done so far * texpdf, url matching, special characters * # Please enter the commit message for your changes.
Diffstat (limited to 'lib/sisu')
-rw-r--r--lib/sisu/v0/dal_idx.rb3
-rw-r--r--lib/sisu/v0/html_segments.rb26
-rw-r--r--lib/sisu/v0/manpage.rb1
-rw-r--r--lib/sisu/v0/texinfo.rb1
-rw-r--r--lib/sisu/v0/texpdf_format.rb19
5 files changed, 37 insertions, 13 deletions
diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb
index a5806d06..c2bba846 100644
--- a/lib/sisu/v0/dal_idx.rb
+++ b/lib/sisu/v0/dal_idx.rb
@@ -288,8 +288,7 @@ module SiSU_book_index
path="#{@env.path.output}/#{@md.fnb}"
Dir.mkdir(path) unless FileTest.directory?(path)
html_index_file=File.new("#{path}/#{@md.fn[:book_index]}",'w')
- puts "#{path}/#{@md.fn[:book_index]}"
- #html_file(the_idx)
+ #puts "#{path}/#{@md.fn[:book_index]}"
html_idx.each {|x| html_index_file << x }
html_index_file.close
end
diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb
index 796c3939..a280a8c8 100644
--- a/lib/sisu/v0/html_segments.rb
+++ b/lib/sisu/v0/html_segments.rb
@@ -63,18 +63,28 @@ module SiSU_HTML_seg
require "#{SiSU_lib}/html"
require "#{SiSU_lib}/html_promo"
class Seg_output
- def initialize(outputfile,seg,minitoc,type='')
- @output_seg_file,@seg,@minitoc,@type=outputfile,seg,minitoc,type
+ def initialize(md,outputfile,seg,minitoc,type='')
+ @md,@output_seg_file,@seg,@minitoc,@type=md,outputfile,seg,minitoc,type
end
def output #CONSIDER
- if @seg[:title] =~/\S/ #kludge (for exception file better.ways, how ironic) get a real ruby test, e.g. test that not array or...
+ if @seg[:title] =~/\S/
filename_seg=[]
filename_seg << @seg[:title] << @seg[:tocband_banner]
if @type =~/endnote/
-#p @seg[:headers] #FIX endnote header
+ @seg[:headers]=[]
+ format_head_seg=SiSU_HTML_Format::Head_seg.new(@md)
+ @seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator)
+ txt_obj={:txt =>'Endnotes',:ocn_display =>''}
+ format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)
+ @seg[:headers] << format_seg.title_header1
filename_seg << @seg[:header_endnotes] << @minitoc << @seg[:headers] << %{\n<div class="content">\n} << @seg[:endnote_all] << '</div>' # << '</div>'
elsif @type =~/idx/
-#p @seg[:headers] #FIX inserted index header
+ @seg[:headers]=[]
+ format_head_seg=SiSU_HTML_Format::Head_seg.new(@md)
+ @seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator)
+ txt_obj={:txt =>'Index',:ocn_display =>''}
+ format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj)
+ @seg[:headers] << format_seg.title_header1
filename_seg << @seg[:header_idx] << @minitoc << @seg[:headers] << %{\n<div class="content">\n} << @seg[:idx] << '</div>' # << '</div>'
else
filename_seg << @minitoc << @seg[:headers] << @seg[:main] << "\n</div>\n"
@@ -191,11 +201,11 @@ module SiSU_HTML_seg
segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking-1]}#{@md.fnl[:mid]}#@h_sfx#{@md.fnl[:post]}"
@output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1]
if @@seg_name_html[tracking-1] !~/endnotes|idx/
- Seg_output.new(@output_seg_file,@@seg,@minitoc).output
+ Seg_output.new(@md,@output_seg_file,@@seg,@minitoc).output
elsif @@seg_name_html[tracking-1] =~/endnotes/
- Seg_output.new(@output_seg_file,@@seg,@minitoc,'endnotes').output
+ Seg_output.new(@md,@output_seg_file,@@seg,@minitoc,'endnotes').output
elsif @@seg_name_html[tracking-1] =~/idx/
- Seg_output.new(@output_seg_file,@@seg,@minitoc,'idx').output
+ Seg_output.new(@md,@output_seg_file,@@seg,@minitoc,'idx').output
else p 'check'
end
Seg.new.reinitialise
diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb
index 597099ed..ef9f6bab 100644
--- a/lib/sisu/v0/manpage.rb
+++ b/lib/sisu/v0/manpage.rb
@@ -266,6 +266,7 @@ WOK
table_message='[table omitted, see other document formats]'
fix=[]
data.each do |para|
+ para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove
para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#@br#{table_message}")
para.gsub!(/.+?<-#>/,'') # remove dummy headings (used by html) #check
para.gsub!(/#{Mx[:gl_bullet]}\s*/,'* ') # bullet markup, marked down
diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb
index 3edf67e4..3ff5652c 100644
--- a/lib/sisu/v0/texinfo.rb
+++ b/lib/sisu/v0/texinfo.rb
@@ -267,6 +267,7 @@ module SiSU_TexInfo
@submenu,@subsubmenu={},{}
data.each do |para|
para.gsub!(/\s*<:name#example>\s*/,' ')
+ para.gsub!(/#{Mx[:id_o]}~0;0:0;x\d+#{Mx[:id_c]}/,'') # if book index? remove
if para =~ /^#{Mx[:lv_o]}[1-3]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/
txt_obj={:txt =>$1}
toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj)
diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb
index 58a057d8..5c2b7ec5 100644
--- a/lib/sisu/v0/texpdf_format.rb
+++ b/lib/sisu/v0/texpdf_format.rb
@@ -1100,16 +1100,22 @@ WOK
#string.gsub!(/<=lt>/,'\<')
#string.gsub!(/<=gt>/,'\>')
string.gsub!(/<=underscore>/,'\_')
- string.gsub!(/((?:\\href|\\url)\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text
+ while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2')
+ end
string.gsub!(/<=tilde>/,'{$\sim$}')
string.gsub!(/<=pipe>/,'{\textbar}')
string.gsub!(/<=caret>/,'{\^{~}}')
#string.gsub!(/<=caret>/,'\^{}')
string.gsub!(/<=exclaim>/,'\Verbatim{!}')
+ string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text
string.gsub!(/<=hash>/,'{\#}')
#string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')
#string.gsub!(/<=slash>/,'{\slash}')
string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005
+ while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2')
+ end
string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005
#string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')
string.gsub!(/<=slash>/,'{/}')
@@ -1202,7 +1208,8 @@ WOK
elsif string=~/#{Mx[:gr_o]}code-end#{Mx[:gr_c]}/; @@flag_code=false
end
if @@flag_code; string.gsub!(/&/,'{\\\&}')
- else string.gsub!(/(\s+&\s+)/,' and ')
+ else string.gsub!(/&/,'<=amp>')
+ #else string.gsub!(/(\s+&\s+)/,' and ')
end
string.gsub!(/§/u,'\S') #latex: space between next character not preserved? #string.gsub!(/§ /,'\S ')
string.gsub!(/£/u,'\pounds')
@@ -1271,16 +1278,22 @@ WOK
#string.gsub!(/<=lt>/,'\<')
#string.gsub!(/<=gt>/,'\>')
string.gsub!(/<=underscore>/,'\_')
- string.gsub!(/((?:\\href|\\url)?\{http:\/\/\S+?)(?:(?:<=tilde>)(\S+))+\}/,'\1\~\2}') #tildes in urls \href treated differently from text
+ while string =~/(http:\/\/\S+?)(?:<=tilde>\S+)+/ #tilde in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=tilde>(\S+))+/,'\1~\2')
+ end
string.gsub!(/<=tilde>/,'{$\sim$}')
string.gsub!(/<=pipe>/,'{\textbar}')
string.gsub!(/<=caret>/,'{\^{~}}')
#string.gsub!(/<=caret>/,'\^{}')
string.gsub!(/<=exclaim>/,'\Verbatim{!}')
+ string.gsub!(/(http:\/\/\S+?)(?:(?:<=hash>)(\S+))+/,'\1#\2') #hash in urls \href treated differently from text
string.gsub!(/<=hash>/,'{\#}')
#string.gsub!(/<=hash>/,'{\UseTextSymbol{OT1}{#}}')
#string.gsub!(/<=slash>/,'{\slash}')
string.gsub!(/<=hardspace>/,'{~}') #changed ... 2005
+ while string =~/(http:\/\/\S+?)(?:<=amp>\S+)+/ #amp in urls \href treated differently from text
+ string.gsub!(/(http:\/\/\S+?)(?:<=amp>(\S+))+/,'\1&\2')
+ end
string.gsub!(/<=amp>/,'{\\\&}') #changed ... 2005
#string.gsub!(/<=amp>/,'{\UseTextSymbol{OT1}{&}}')
string.gsub!(/<=slash>/,'{/}')