Skip to content

Commit

Permalink
PDF - rendering indexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptabor committed Sep 25, 2024
1 parent 0e4e034 commit c20154f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
3 changes: 3 additions & 0 deletions render_pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ fi

# Run pdflatex three times to recalculate longtables and toc
TEXINPUTS=.:${__dir}/src/latex: pdflatex -jobname=${JOB} -output-directory "${tex_dir}" "${tex_file}"
(cd ${tex_dir}; makeindex -o "${JOB}.aind" "${JOB}.aadx")
(cd ${tex_dir}; makeindex -o "${JOB}.gind" "${JOB}.gadx")
(cd ${tex_dir}; makeindex -o "${JOB}.wind" "${JOB}.wadx")
TEXINPUTS=.:${__dir}/src/latex: pdflatex -jobname=${JOB} -output-directory "${tex_dir}" "${tex_file}"
TEXINPUTS=.:${__dir}/src/latex: pdflatex -jobname=${JOB} -output-directory "${tex_dir}" "${tex_file}"
6 changes: 6 additions & 0 deletions src/formats/single_p.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
\renewcommand{\familydefault}{\sfdefault}
\usepackage{helvet}

\usepackage{index}

\newindex{wyk}{wadx}{wind}{Indeks wykonawców}
\newindex{aliases}{aadx}{aind}{Indeks tytułów}
\newindex{genre}{gadx}{gind}{Indeks gatunków}

\geometry{scale={0.95,0.85},pdftex,top={3ex}}
\addtolength{\headheight}{5ex}

Expand Down
10 changes: 10 additions & 0 deletions src/formats/songbook_p.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
\usepackage{graphicx}
\usepackage{dcolumn}
\usepackage{qrcode}
\usepackage{index}

\newindex{wyk}{wadx}{wind}{Indeks wykonawców}
\newindex{aliases}{aadx}{aind}{Indeks tytułów}
\newindex{genre}{gadx}{gind}{Indeks gatunków}


\usepackage{hyperref}
\hypersetup{
Expand Down Expand Up @@ -73,3 +79,7 @@
\rightline{\qrcode{:url:}}

\cleardoublepage


%\printindex[aliases]
%\cleardoublepage
4 changes: 4 additions & 0 deletions src/formats/songbook_s.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
\fancyhead[LE]{SPIS TREŚCI}
\fancyhead[RO]{SPIS TREŚCI}
\tableofcontents

\printindex[wyk]
\printindex[genre]
\printindex[aliases]
\end{document}
8 changes: 6 additions & 2 deletions src/latex/song2tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ def parseDOM(root, linked=False):


class Song:
def __init__(self, title='', text_author='', composer='', artist='', blocks=[], barre=None, metre=None):
def __init__(self, title='', text_author='', composer='', artist='', blocks=[], barre=None, metre=None, genre=None, alias=None):
self.title = tex_escape(title) if title else ''
self.text_author = tex_escape(text_author) if text_author else ''
self.composer = tex_escape(composer) if composer else ''
self.artist = tex_escape(artist) if artist else ''
self.blocks = blocks
self.barre = barre if barre != '' and barre != '0' and barre != 0 else None
self.metre = metre
self.genre = genre
self.alias = alias

@staticmethod
def parseDOM(root):
Expand All @@ -165,12 +167,14 @@ def parseDOM(root):

return Song(
title=root.get('title'),
alias=get_text(root.find('{*}alias')),
text_author=get_text(root.find('{*}text_author')),
composer=get_text(root.find('{*}composer')),
artist=get_text(root.find('{*}artist')),
blocks=blocks,
barre=get_attrib(root.xpath("./s:music/s:guitar/@barre", namespaces={"s": "http://21wdh.staszic.waw.pl"})),
metre=get_attrib(root.xpath("./s:music/@metre", namespaces={"s": "http://21wdh.staszic.waw.pl"}))
metre=get_attrib(root.xpath("./s:music/@metre", namespaces={"s": "http://21wdh.staszic.waw.pl"})),
genre=get_text(root.find('{*}genre'))
)


Expand Down
2 changes: 1 addition & 1 deletion src/latex/song_template.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\begin{song}{\VAR{song.title}}{\VAR{song.text_author}}{\VAR{song.composer}}{\VAR{song.artist}}{\VAR{song.barre or ''}}{\VAR{song.metre or ''}}
\begin{song}{\VAR{song.title}}{\VAR{song.text_author}}{\VAR{song.composer}}{\VAR{song.artist}}{\VAR{song.barre or ''}}{\VAR{song.metre or ''}}{\VAR{song.genre or ''}}{\VAR{song.alias or ''}}
\begin{longtable}[l]{l V{6em} l l@{}}
&\ldots \endfoot \endlastfoot
\BLOCK{ for block in song.blocks }
Expand Down
7 changes: 6 additions & 1 deletion src/latex/songbook21wdh.sty
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
}%


\newenvironment{song}[6]{
\newenvironment{song}[8]{
\clearpage%
\fancyhead[LE]{#1}%
\fancyhead[RO]{#1}%
Expand All @@ -130,7 +130,12 @@
\renewcommand{\theSongLyricist}{#2}%
\renewcommand{\theSongComposer}{#3}%
\renewcommand{\theSongArtist}{#4}%
% #7 - alias #8- genre
\addtocounter{SongCnt}{1}%
\index[wyk]{#4!#1}
\index[aliases]{#1}
\index[aliases]{#8!#1}
\index[genre]{#7!#1}
\addcontentsline{toc}{section}{\theSongCnt{}. #1}%
% \addcontentsline{toc}{section}{alias title}
\STitle{\theSongTitle}%
Expand Down

0 comments on commit c20154f

Please sign in to comment.