aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/texpdf_format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v6/texpdf_format.rb')
-rw-r--r--lib/sisu/v6/texpdf_format.rb122
1 files changed, 63 insertions, 59 deletions
diff --git a/lib/sisu/v6/texpdf_format.rb b/lib/sisu/v6/texpdf_format.rb
index f7e18dc8..015a9934 100644
--- a/lib/sisu/v6/texpdf_format.rb
+++ b/lib/sisu/v6/texpdf_format.rb
@@ -219,95 +219,99 @@ module SiSU_TeX_Pdf
else ''
end
end
- def heading_major
+ def remove_footnotes(cont_ln)
+ cont_ln=if cont_ln =~/\\[Ff]ootnote/m
+ cont_ln.gsub(/\s*\\[Ff]ootnote\[\d+\]\{%\s+.+?\}\s*/m,' ').
+ gsub(/\s*\\[Ff]ootnote[A]\{[*+]+\d*\}\{%\S+.+?\}\s*/m,' ')
+ else cont_ln
+ end
+ end
+ def title_level_A
dob=@dob
- title=@md.title.full
dob.tmp=dob.tmp.strip if dob.tmp
dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').
gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')
cont_ln=dob.tmp.dup
cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').
gsub(@@tex_pattern_margin_number,'')
- clearp=(dob.lv =~/B/ && dob.obj =='Metadata') ? "\\clearpage\n" : ''
- if dob.tmp =~/\\[Ff]ootnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings!
- cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ').
- gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')
- end
+ cont_ln=remove_footnotes(cont_ln)
+ titleset=''
dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m,
- "#{clearp}\\part*{\\1}
-\\addcontentsline{toc}{section}{#{cont_ln}}
-\\markboth{#{title}}\n")
+ "#{titleset}\\part*{\\1}
+\\markboth{#{@md.title.full}}\n")
dob
end
- def level4
- dob=@dob
+ def section_heading_level(dob)
dob.tmp=dob.tmp.strip if dob.tmp
dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').
gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')
cont_ln=dob.tmp.dup
cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').
- gsub(@@tex_pattern_margin_number,'').
- gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42
- gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
- gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
- title=@md.title.full
- if dob.name =~/endnotes/
- dob.tmp=dob.tmp.gsub(/.+/m,'')
- end
- if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings!
- cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ').
- gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')
- end
- dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,"\\subsubsection*{\\1}
-\\addcontentsline{toc}{subsection}{#{cont_ln}}
-\\markright{#{title}}")
+ gsub(@@tex_pattern_margin_number,'')
+ cont_ln=remove_footnotes(cont_ln)
+ dob.tmp=dob.tmp.gsub(/^(.*)\n?$/m,
+ "\\clearpage
+\\part*{\\1}
+\\addcontentsline{toc}{part}{#{cont_ln}}
+\\markboth{#{@md.title.full}}\n")
dob
end
- def level5
- dob=@dob
- # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46
- dob.tmp=dob.tmp.strip if dob.tmp
- dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').
- gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')
- cont_ln=dob.tmp.dup
- cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').
- gsub(@@tex_pattern_margin_number,'').
- gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
- gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
- gsub(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa
- if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings!
- cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ').
- gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')
+ def heading_sublevels(dob,sublev)
+ if sublev==:lev1
+ sect='section'
+ tocadd=%{\\addcontentsline{toc}{section}}
+ pre=''
+ post=''
+ headadd=%{\n\\markright{#{@md.title.full}}}
+ elsif sublev==:lev2
+ sect='subsection'
+ tocadd=%{\\addcontentsline{toc}{subsection}}
+ pre=''
+ post=" \\\\\n"
+ headadd=''
+ elsif sublev==:lev3
+ sect='subsubsection'
+ tocadd=%{\\addcontentsline{toc}{subsubsection}}
+ pre='' #pre='~~~~'
+ post=" \\\\\n"
+ headadd=''
end
- dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,
- "\\subsubsection*{\\1}
-\\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\
-}")
- dob
- end
- def level6
- dob=@dob
- # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46
dob.tmp=dob.tmp.strip if dob.tmp
dob.tmp=dob.tmp.gsub(/\\begin\{(bfseries|itshape)\}(.+?)\\end\{\1\}/m,'\2').
gsub(/#{Mx[:url_o]}|#{Mx[:url_c]}/,'')
cont_ln=dob.tmp.dup
cont_ln=cont_ln.gsub(/\\begin\{(monosp)\}(.+?)\\end\{\1\}/m,'\2').
gsub(@@tex_pattern_margin_number,'').
+ gsub(/#{Tex[:backslash]*2}/,"#{Tex[:backslash]*4}"). # added w42
gsub(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,''). #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
gsub(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22
- if dob.tmp =~/\\footnote/ #and dob =~/^[1-6]#{Tex[:tilde]}/ # removing footnotes from headings!
- cont_ln=cont_ln.gsub(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ').
- gsub(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ')
+ if dob.name =~/endnotes/
+ dob.tmp=dob.tmp.gsub(/.+/m,'')
end
+ cont_ln=remove_footnotes(cont_ln)
dob.tmp=dob.tmp.gsub(/^(.*)?\n?$/m,
- "\\subsubsection*{\\1}
-\\addcontentsline{toc}{subsubsection}{~~~~#{cont_ln} \\\\
-}")
- #dob.tmp.gsub(/^(.*)?\n?$/m,
- # '\subsubsection*{\1}')
+ "\\#{sect}*{\\1}
+#{tocadd}{#{pre}#{cont_ln}#{post}}#{headadd}")
dob
end
+ def section_heading_level_B
+ section_heading_level(@dob)
+ end
+ def section_heading_level_C
+ section_heading_level(@dob)
+ end
+ def section_heading_level_D
+ section_heading_level(@dob)
+ end
+ def heading_level_1
+ heading_sublevels(@dob,:lev1)
+ end
+ def heading_level_2
+ heading_sublevels(@dob,:lev2)
+ end
+ def heading_level_3
+ heading_sublevels(@dob,:lev3)
+ end
def hang
case @dob.indent
when /0/