diff options
Diffstat (limited to 'lib/sisu/v0/texinfo_format.rb')
-rw-r--r-- | lib/sisu/v0/texinfo_format.rb | 133 |
1 files changed, 61 insertions, 72 deletions
diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index bb60895d..3184ee80 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -90,6 +90,8 @@ module TexInfoFormat author=@md.dc_creator if @md.dc_creator author ||='' author.gsub!(/[\*]/,'') #if author + v=SiSU_Env::Info_version.new.get_version + #(version @value{VERSION} #{v[:version]}, @value{UPDATED} #{v[:date]}) head =<<WOK \\input texinfo @c -*-texinfo-*- @comment $Id$ @@ -98,10 +100,9 @@ module TexInfoFormat @settitle #{title} @value{VERSION} @syncodeindex pg cp @comment %**end of header -@c {{{ 2 +@c %% 2 @copying -SiSU in texinfo version of #{title} -(version @value{VERSION}, @value{UPDATED}) +SiSU texinfo of #{title} Copyright @copyright{} #{year} #{author}. @@ -117,7 +118,7 @@ Copyright #{author}, generated by ``SiSU'' WOK if @md.subtitle titlepage=<<WOK -@c {{{ 3 +@c %% 3 @titlepage @title #{title} #{subtitle} @author #{author} @@ -129,7 +130,7 @@ WOK WOK else titlepage=<<WOK -@c {{{ 3 +@c %% 3 @titlepage @title #{title} @value{VERSION}, @value{UPDATED} @@ -149,7 +150,7 @@ WOK @one=@one.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") @one.gsub!(/\$/,"\\$") @one.gsub!(/[,]\s*/,' - ') - "@c {{{ 4\n" + + "@c %% 4\n" + "@ifnottex\n" + "@node Top\n" + "@top #@one\n\n" + @@ -201,7 +202,7 @@ WOK dc_coverage="Coverage: #{dc_coverage}\n\n" if dc_coverage dc_rights="Rights: #{dc_rights}\n\n" if dc_rights "@node Dublin Core\n" + - "@chapter Dublin Core\n" + + "@unnumbered Dublin Core\n" + "@cindex chapter, Dublin Core\n\n" + "#{dc_title}" + "#{dc_creator}" + @@ -225,91 +226,80 @@ WOK "\n\n" end def tail - "@c {{{ 6\n" + + "@c %% 6\n" + "@node Index\n" + "@unnumbered Index\n" + "@printindex cp\n\n" + "@bye" end + def clean(para) + para.gsub!(/<\\~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'<\1>') + para.gsub!(/\s*[,:]\s*/,' - ') + para.gsub!(/<:#>/,'') + para.strip! + para + end def menu - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - "* #@para::" + para=clean(@para) + para=para.gsub(/@footnote\{.+?\}\s+/,'') + "* #{para}::" end def level1 @para.gsub!(/[1]\\+~/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level2 @para.gsub!(/[2]\\+~/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level3 @para.gsub!(/[3]\\+\~/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,"\\1 \\3\n\\2") + #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,'\1 \3 \2') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level4 @para.gsub!(/[4]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level5 @para.gsub!(/[5]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level6 @para.gsub!(/[6]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def submenu @para=@para.join("\n") @para.gsub!(/[5]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@menu\n#@para\n@end menu\n\n" + para=clean(@para) + para="@menu\n#{para}\n@end menu\n\n" @para.gsub!(/.+/m,"#{para}") end def subsubmenu @para=@para.join("\n") @para.gsub!(/[6]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@menu\n#@para\n@menu\n\n" + para=clean(@para) + para="@menu\n#{para}\n@end menu\n\n" @para.gsub!(/.+/m,"#{para}") end def indent1 @@ -320,12 +310,15 @@ WOK end def spec_char # special characters @para.gsub!(/<EOF>/i,'') - @para.gsub!(/@/i,'@@') - @para.gsub!(/&(lt|#060);/,'\< ') - @para.gsub!(/&(gt|#062);/,' \>') - @para.gsub!(/{/,'\{ ') - @para.gsub!(/}/,'\} ') - @para.gsub!(/&#(126|152);/i,'~ ') + @para.gsub!(/©/,'(c)') + @para.gsub!(/&(lt|#060);/,'<'); @para.gsub!(/&(gt|#062);/,'>') + @para.gsub!(/{/,'{'); @para.gsub!(/}/,'}') + @para.gsub!(/&#(126|152);/i,'~') + @para.gsub!(/!/,'!') + @para.gsub!(/#/,'#') + @para.gsub!(/*/,'*') + @para.gsub!(///,'/') + @para.gsub!(/_/,'_') @para.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') @para.gsub!(/\\/,'\\backslash ') @para.gsub!(/<:pb>/,'\\newpage') @@ -337,13 +330,6 @@ WOK if @para !~ /^\s*<:image|\}:image\s/ @para.gsub!(/_/,'\_') end - @para.gsub!(/\{/,"\\{") - @para.gsub!(/\}/,"\\}") - @para.gsub!(/ /,' ') # ~ character for hardspace - @para.gsub!(/ /,' ') # ~ character for hardspace - @para.gsub!(/&(\S+?);/,'') - @para.gsub!(/(\s+&\s+)/,' and ') - @para.gsub!(/(\&)/,"\\&") @para.gsub!(/§/i,'\S') @para.gsub!(/£/i,'\pounds') @para.gsub!(/å/i,'\aa') @@ -352,7 +338,6 @@ WOK @para.gsub!(/Å/i,'\AA') @para.gsub!(/Æ/i,'\AE') @para.gsub!(/Ø/i,'\O') - @para.gsub!(/&(.+?);/i,' ') @para.gsub!(/<a href=".+?">/i,' ') @para.gsub!(/<\/a>/i,' ') @para.gsub!(/<:ee>/i,'') @@ -360,6 +345,15 @@ WOK @para.gsub!(/<b>(.+?)<\/b>/,'\*\1\*') @para.gsub!(/<i>(.+?)<\/i>/,'\/\1\/') @para.gsub!(/<u>(.+?)<\/u>/,'\_\1\_') + @para.gsub!(/@/i,'@@') + @para.gsub!(/\{/,'@{'); @para.gsub!(/\}/,'@}') + #@para.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @para.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') + @para.gsub!(/ /,' ') # ~ character for hardspace + @para.gsub!(/ /,' ') # ~ character for hardspace + @para.gsub!(/&(\S+?);/,' ') + @para.gsub!(/&/,'<=and>') + @para.gsub!(/(\s+&\s+)/,' and ') + @para.gsub!(/(\&)/,"\\&") @para.gsub!(/"(.+?)"/,"`\\1'") # open & close " @para.gsub!(/\s+"/," `") # open " @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " @@ -368,11 +362,6 @@ WOK @para.gsub!(/"(\.|,)/,"'") # close " @para.gsub!(/\s+'/," `") # open ' @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' - #if @para=~/#{@@tex_1}/ - #end - #@para.gsub!(/^([1-6-](?:#{@@tex_2}|#{@@tex_1})(?:\\~\S+)?|<.+?>)?\s*"/i,"\\1`") # open " - #@para.gsub!(/"([1-6-](?:#{@@tex_2}|#{@@tex_1})(?:\\~\S+)?|<.+?>)?\s*$/i,"'\\1") # close " - #@para.gsub!(/^([1-6-](?:#{@@tex_2}|#{@@tex_1})(?:\\~\S+)?|<.+?>)?\s*'/i,"\\1`") # open ' @para.gsub!(/(<font.*?>|<\/font>)/,'') @para.gsub!(/\s*<sup>(\S+?)<\/sup>/,'^\1') @para.gsub!(/(<sup>|<\/sup>)/,'') |