# -*- tcl -*-
# $Id: varda,v 1.2 1999/10/04 08:53:05 tobotras Exp $

rename textSdataFilter textSdataFilter_varda

proc textSdataFilter { text } {
    return [textSdataFilter_varda [HebTransSubst $text]]
}

substitution HebTransSubst {
    {[Kunderdot]} {\d{K}}
    {[kunderdot]} {\d{k}}
    {[bunderdot]} {\d{b}}
    {[hSamek]} {\v{S}}
    {[beth]} {\b{b}}
    {[heth]} {\d{h}}
    {[taw]} {\b{t}}
    {[gimel]} {\={g}}
    {[tsade]} {\d{s}}
    {[hsamek]} {\v{s}}
    {[daleth]} {\b{d}}
    {[teth]} {\d{t}}
    {[kaf]} {\b{k}}
    {[patah]} {\textbf{\Large{patah}}}
    {[hsegol]} {\u{e}}
    {[hpatah]} {\textbf{\Large{hpatah}}}
    {[copy  ]} {\textcopyright{}}
    {[aacute]} {\'{a}}
}

rename definePageStyle {}

#FIXME: book name hardwired here. We might want to change this to \TEItoolsTitlePartA,
# if only title will be set up with correct transliteration symbols...

proc definePageStyle {} {
    return "\\pagestyle{empty}\n"
}

rename closeFront {}

proc closeFront {} {
    return "
\\fancyhf{}
\\fancyhead\[LE\]{\\roman{page}\\quad P\\u{E}SI\\d{K}TA D\\u{E}{--}RA\\b{B} KAH\\'{A}NA}
\\fancyhead\[RO\]{\\rightmark\\quad\\roman{page}}
\\pagestyle{fancy}
\\renewcommand{\\chaptermark}\[1\]{\\markright{#1}}
\\renewcommand{\\sectionmark}\[1\]{}
\\renewcommand{\\subsectionmark}\[1\]{}
\\renewcommand{\\subsubsectionmark}\[1\]{}
\\renewcommand{\\paragraphmark}\[1\]{}
\\thispagestyle{empty}
"
}

rename generatetoc {}

proc generatetoc {} {
    return "
\\tableofcontents

\\fancypagestyle{plain}{%
  \\renewcommand{\\headrulewidth}{0pt}%
  \\fancyhf{}%
  \\fancyfoot\[RO,LE\]{\\roman{page}}%
}

\\thispagestyle{plain}
\\clearpage
"
}

rename documentClassOptions {}

proc documentClassOptions {} {
    return "titlepage,twoside,openright"
}

rename openForeign {}
rename closeForeign {}

proc openForeign {} {
    return "\\textit\{"
}

proc closeForeign {} {
    return "\}"
}

rename openRef {}
rename closeRef {}

proc openRef {} {
    set target [attVal TARGET]
    return "\\hyperlink{$target}\{"
}

proc closeRef {} {
    return "\}"
}

rename hyperrefArgs {}

proc hyperrefArgs {} {
    return "pdftex,pdfborder={0 0 0}"
}

rename makeLabel makeLabel_varda

proc makeLabel { id } {
    return "[makeLabel_varda $id]\\hypertarget{$id}{}"
}

rename geometryArgs {}

proc geometryArgs {} {
    return "paperheight=7in, paperwidth=5in, top=0.25in, left=0.625in, textwidth=23pc, textheight=416pt"
}

rename extraPreamble extraPreamble_varda

proc extraPreamble {} {
    return "
\\usepackage\[T1\]{fontenc}
\\renewcommand{\\rmdefault}{byw}
\\renewcommand{\\sfdefault}{bbb}

\\parindent 0.1875in
\\usepackage\[splitrule,norule,stable\]{footmisc}
\\usepackage{indentfirst}
\\makeatletter

\\renewcommand\\@makefntext\[1\]{%
    \\parindent 1em%
    \\noindent
    \\hb@xt@1.8em{\\hss\\@thefnmark.~}#1}

\\makeatother

[extraPreamble_varda]"
}

rename sectionTitles {}

proc sectionTitles {} {
    return "%Section Title formatting

\\usepackage{titlesec,fancyhdr}
\\titlelabel{\\thetitle.~}
\\titleformat{\\chapter}\[hang\]{\\sffamily\\Large\\bfseries}{}{0pt}{\\vspace*{-2ex}}\[\\rule{\\textwidth}{.4pt}\\vspace*{-3ex}\]
\\titleformat{\\section}\[hang\]{\\large\\sffamily\\bfseries}{\\Roman{section}.~}{0pt}{}{}
\\titleformat{\\subsection}\[hang\]{\\normalfont\\itshape}{\\Alph{subsection}.~}{1ex}{}{}
\\titlespacing{\\subsection}{\\parindent}{0pt}{0pt}

% These are for correct rendering of references.
\\makeatletter
\\renewcommand{\\thesubsection}{\\Roman{subsection}}
\\renewcommand{\\thesubsubsection}{\\Alph{subsubsection}}
\\makeatother

"
}

rename startDivision startDivision_varda

rename endDivision endDivision_varda

proc startDivision {} {
    set theStart [startDivision_varda]

    if { "[attVal REND]" == "intro" } {
	append theStart "



"
    } 
    return $theStart
}

proc endDivision {} {
    set theEnd [endDivision_varda]

    if { "[attVal REND]" == "intro" } {
	append theEnd "

	\\mainmatter

"
    } 
    return $theEnd
}
