The son of friends and neighbors of ours wrote his own page of Talmud including Rashi and Tosfot commentaries. He wanted a way to print the page in the same way that an actual page of Talmud appears. I thought it would be easy to instruct the AI program Gemini to create such a page but it wasn’t. The three sections always appeared as 3 even columns without any wrap-around the actual text of the Talmud. So a different solution was needed.
A solution had, indeed, been created and posted on Github, Talmudifier, which seemingly does everything we wanted. From the README file it was clear, however, that a little knowledge of programming was going to be required; my friends needed help and I volunteered.
The process seemed easy enough. Download the code, install it, run it. The download was easy:git clone https://github.com/subalterngames/talmudifier.git
I used my Windows 11 laptop and cygwin to do the git clone. After doing a ‘cd’ to folder talmudifier I followed the install instructions and executedpip3 setup.py -e .
per the README instructions. Here I saw my first problem. I got the errorERROR: unknown command "setup.py" trying to install the Talmudifier Python module
Talmudifier was last modified 6 years ago. Perhaps installing Python modules via the instructions worked then but they didn’t work now. With help from Gemini (I’m no Python expert), I found out that the correct command is really pip3 install -e .
Running the actual install also didn’t work as advertised. I got this error:note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed to build 'cryptography' when installing build dependencies for cryptography
At that point I was advised to skip trying to install the application on Windows as I would need to install C and Rust compilers as well as development headers. So I switched to my Ubuntu Linux computer which I run inside of Windows as a virtual machine and started over:git clone https://github.com/subalterngames/talmudifier.git
cd talmudifier
python3 -m venv venv
source venv/bin/activate
pip install -e .
This install also failed but I knew what software was missing. Here are the packaged needed and the commands for installing them:sudo apt update
sudo apt install python3-dev build-essential python3-pip
sudo apt install texlive-xetex texlive-fonts-recommended texlive-plain-generic
sudo apt install texlive-lang-other
sudo apt install fonts-culmus
sudo apt install libhyphen-dev libhyphen0
pip install "setuptools<80.0.0"
pip install --force-reinstall pyhyphen
With these additional packages installed, the talmudifier build/install worked fine.
I ran the suggested command to confirm that everything was installed correctly as follows:python test_input_reader.pyand indeed, I got the output shown at the github site which looked pretty neat.
The next step is to install the Hebrew fonts that you want to use:
cp /usr/share/fonts/truetype/culmus/FrankRuelCLM-Bold.ttf fonts/hebrew/bold.ttf
cp /usr/share/fonts/truetype/culmus/FrankRuelCLM-Medium.ttf fonts/hebrew/regular.ttf
#Additionally, it is important to ensure that you either create a symlink for #the italic/bold-italic versions or duplicate the regular.ttf file if you do #not have dedicated variants readily available. This will maintain consistency #in your font styles across different text formats.
cp /usr/share/fonts/truetype/culmus/FrankRuelCLM-Medium.ttf fonts/hebrew/italic.ttf
cp /usr/share/fonts/truetype/culmus/FrankRuelCLM-Bold.ttf fonts/hebrew/bold_italic.ttf
If you look in folder /usr/share/fonts/truetype/culmus you will see a number of Hebrew fonts that can be used. Note that ttf and otf files can be used interchangeably. Create a recipe for this document:
cd recipes
cp default.json hebrew.json
Open file hebrew.json and update the font entries for each column (left, center, right) to point to the new Hebrew font directory so it looks like this:
{
"fonts":
{
"left":
{
"path": "fonts/hebrew",
"ligatures": "TeX",
"regular_font": "regular.otf",
"italic_font": "italic.otf",
"bold_font": "bold.otf",
"options": "Script=Hebrew",
"size": 11,
"skip": 13,
"substitutions":
{
"`=(.*)`": "\\\\marginnote{\\\\noindent\\\\justifying \\\\tiny \\1}",
"->": "\\\\flowerfont 1 \\\\leftfont"
},
"citation":
{
"path": "fonts/frankruehl",
"font": "FrankRuehlCLM-Medium.ttf",
"command": "\\leftcitation",
"font_command": "\\leftcitationfont",
"pattern": "`L(.*)`"
}
},
"center":
{
"path": "fonts/hebrew",
"ligatures": "TeX",
"regular_font": "regular.otf",
"italic_font": "italic.otf",
"options": "Script=Hebrew",
"size": 11,
"skip": 13,
"substitutions":
{
"`L(.*)`": "\\\\leftcitationfont{\\\\leftcitation \\1} \\\\centerfont ",
"`R(.*)`": "\\\\rightcitationfont{\\\\rightcitation \\1} \\\\centerfont "
}
},
"right":
{
"path": "fonts/hebrew",
"ligatures": "TeX",
"regular_font": "regular.otf",
"italic_font": "italic.otf",
"bold_font": "bold.otf",
"bold_italic_font": "bold_italic.otf",
"options": "Script=Hebrew",
"size": 11,
"skip": 13,
"substitutions":
{
"\\|": "§"
},
"citation":
{
"path": "fonts/rashi/",
"font": "Mekorot-Rashi.ttf",
"command": "\\rightcitation",
"font_command": "\\rightcitationfont",
"pattern": "`R(.*)`"
}
}
},
"character_counts":
{
"one_third":
{
"left":
{
"1": 29
},
"center":
{
"1": 24
},
"right":
{
"1": 27
}
},
"half":
{
"left":
{
"1": 47,
"4": 183
},
"right":
{
"1": 44,
"4": 174
}
},
"two_thirds":
{
"center":
{
"1": 54
},
"right":
{
"1": 60
}
}
},
"chapter":
{
"definition": "\\newcommand{\\chfont}[1]{\\centerfont{\\setRTL\\huge\\textcolor{hcolor}{#1}}}",
"command": "\\chfont",
"numbering": false
},
"colors":
{
"hcolor": "D3230C",
"rcolor": "D36F0C"
},
"misc_definitions": [
"\\newcommand{\\leftcitation}[1]{\\leftcitationfont{\\setRTL\\Large\\textcolor{hcolor}{#1}}}",
\\newcommand{\\rightcitation}[1]{\\rightcitationfont{\\setRTL\\normalsize\\textcolor{rcolor}{#1}}}",
"\\newfontfamily\\flowerfont[Path=fonts/fell_flowers/]{IMFeFlow2.otf}"
]
}
I had three files that represented the Talmud text that I wanted to display. They were called left (for Rashi), center (actual Talmud text), and right (for Tosfot). In the original sample, all three portions of the display were in one file. So I slightly modified the source file, test_input_reader.py, as follows:
import io
from talmudifier.talmudifier import Talmudifier
if __name__ == "__main__":
# Read the test page.
with io.open("ganz/rashi-1.txt", "rt", encoding="utf-8") as f:
left = f.read()
with io.open("ganz/gamliel-1.txt", "rt", encoding="utf-8") as f:
center = f.read()
with io.open("ganz/tosfos-1.txt", "rt", encoding="utf-8") as f:
right = f.read()
# Generate the PDF.
t = Talmudifier(left, center, right, recipe_filename="hebrew.json")
tex = t.get_chapter("Gemora Ganz") + "\n"
tex += t.get_tex()
doc = t.writer.write(tex, "ganz_page")
# Output the LaTeX string used to generated the PDF as a .tex file.
with io.open("Output/ganz_page.tex", "wt", encoding="utf-8") as f:
f.write(doc)
I called the updated file ganz.py. To run the program, execute:
python -W ignore ganz.py
Look in folder Output and you will see the pdf file ganz_page.pdf which, when displayed, shows a nicely formatted Talmud page with one little bug: all the text will be displayed left to right instead of right to left as Hebrew requires. It appears that Talmudifier was never written to handle non-Latin characters (or so it seems to me as I describe now how I fixed the problem).
Unfortunately, fixing the problem requires a manual step, physically modifying file Output/ganz_page.tex. Copy that file to the talmudifier folder and open it inside a text editor.
After line “\usepackage{fontspec}” insert the following lines:
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\usepackage{bidi}
\setRTL
Then search for “\newfontfamily\” and add the following lines:
\newfontfamily\hebrewfont[Path=fonts/hebrew/]{regular.otf}
\newfontfamily\hebrewfontsf[Path=fonts/hebrew/]{regular.otf}
\newfontfamily\hebrewfonttt[Path=fonts/hebrew/]{regular.otf}
Save the modified ganz_page.tex file and execute the following command:
xelatex ganz_page.tex
Open the created file ganz_page.pdf in the talmudifier folder and you will then see all the Hebrew text displayed right to left. There is one more fix that is worth doing. Typically, the first word in the Talmudic text is larger than the remaining text. In this case that word was מדוע. So open file ganz_page.pdf again and search for that word. Replace it with the following:
{\huge מדוע}
Rerun everything and now the text should look just like a real page from the Talmud.




















You must be logged in to post a comment.