{"id":3013,"date":"2013-10-22T12:03:15","date_gmt":"2013-10-22T18:03:15","guid":{"rendered":"http:\/\/bililite.com\/blog\/?p=3013"},"modified":"2013-10-22T12:03:15","modified_gmt":"2013-10-22T18:03:15","slug":"formatting-the-torah","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2013\/10\/22\/formatting-the-torah\/","title":{"rendered":"Formatting the Torah"},"content":{"rendered":"<p>The <a href=\"http:\/\/he.wikisource.org\/w\/index.php?title=%D7%A7%D7%95%D7%91%D7%A5:Sefer-Torah-Elihu-Shannon-2.djvu&page=6\">Torah as traditionally written<\/a> has two kinds of paragraph breaks: \"open\" and \"closed\". Open paragraphs are the same as in English typography: the next paragraph starts on the next line. Closed paragraphs start the next paragraph on the same line, after a 9-em gap. In <a href=\"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/6\/62\/Sefer-Torah-Elihu-Shannon-2.djvu\/page6-312px-Sefer-Torah-Elihu-Shannon-2.djvu.jpg\">the image on the page linked to above<\/a>, there are 3 closed paragraph breaks, 2 open, then 1 closed.<\/p>\r\n<p>I was thinking about representing this in CSS, with semantic HTML; something like <code class=\"language-html\" >&lt;p class=open&gt;First Paragraph&lt;\/p&gt;&lt;p class=closed&gt;Second paragraph&lt;\/p&gt;<\/code>. The <a href=\"http:\/\/mechon-mamre.org\/c\/ct\/cp\/cp0101.htm\">Mechon Mamre tikkun<\/a> uses a single <code class=\"language-html\" >&lt;p&gt;<\/code> for the entire portion, then has <code class=\"language-html\" >&lt;br&gt;<\/code>'s and <code class=\"language-html\" >&amp;nbsp;<\/code>'s hard-coded into the text. But there ought to be a better way.<\/p>\r\n<p>See the <a href=\"\/blog\/blogfiles\/stuma.html\">final formatting<\/a>.<\/p>\r\n<!--more-->\r\n<p>Clearly, the closed paragraphs need to be <code class=\"language-css\" >display: inline<\/code> to allow the next paragraph to stay on the same line. But an open paragraph that follows a closed one needs to be inline as well, since it has to start on the same line. Then I have to insert the paragraph-breaking characters (either the non-breaking spaces or the newline) with the <code class=\"language-css\" >::after<\/code> pseudo-element. Then I need to make the paragraphs <code class=\"language-css\" >white-space: pre-line<\/code> to make the browser respect the newlines.<\/p>\r\n<p>And as another subtlety, I want the text justified, but <code class=\"language-css\" >text-align: justify<\/code> doesn't work on inline elements. So I have to apply that to the surrounding element.<\/p>\r\n<p>In summary:<\/p>\r\n<pre><code class=\"language-css\" >body {\r\n\ttext-align: justify;\r\n}\r\np.open, p.closed{\r\n\tdisplay: inline;\r\n\twhite-space: pre-line;\r\n\ttext-align: justify;\r\n}\r\np.open::after {\r\n\tcontent: '\\a'; \/* newline *\/\r\n}\r\np.closed::after {\r\n\tcontent: '\\a0\\a0\\a0\\a0\\a0\\a0\\a0\\a0\\a0'; \/* spaces, not newline *\/\r\n}\r\n<\/code><\/pre>\r\n<p>Another issue is the layout of poetry. Poems in the Torah are arranged either with the lines divided into two phrases, the first right justified and the second left justified (remember, Hebrew is read from right to left), creating two columns of text; or alternating two-phrase lines as above with three-phrase lines, with the first word right justified, the last word left justified, and the remainder of the text centered in the line (<em>not<\/em> between the other words; centered between the margins). <code class=\"language-css\" >float<\/code> would work for the justified phrases, but the centering would be wrong, and I would have to worry about clearing the floats. So I use <code class=\"language-css\" >position: absolute<\/code> for the text at the margins and <code class=\"language-css\" >text-align: center<\/code> for the rest. The problem then is the two-phrase lines have no center text, so they have zero height and overlap the next line. So I have to add a blank with<code class=\"language-css\" >::after<\/code>:<\/p>\r\n<pre><code class=\"language-css\" >p.poem {\r\n\tposition: relative;\r\n\ttext-align: center;\r\n}\r\np.poem > span:first-child {\r\n\tposition: absolute;\r\n\tleft: 0;\r\n}\r\np.poem > span:last-child {\r\n\tposition: absolute;\r\n\tright: 0;\r\n}\r\np.poem::after {\r\n\tcontent: '\\a0';\r\n}\r\n<\/code><\/pre>\r\n\r\n\r\n<p>For the interested, the arrangement of the poems is described in <a href=\"http:\/\/he.wikisource.org\/wiki\/%D7%9E%D7%92%D7%99%D7%9C%D7%94_%D7%98%D7%96_%D7%91\">Talmud Bavli, Megillah 15a<\/a> as \u05dc\u05d1\u05d9\u05e0\u05d4 \u05e2\u05dc \u05d2\u05d1\u05d9 \u05dc\u05d1\u05d9\u05e0\u05d4, one brick on another, or \u05d0\u05e8\u05d9\u05d7 \u05e2\u05dc \u05d2\u05d1\u05d9 \u05dc\u05d1\u05d9\u05e0\u05d4, a half-brick on a full brick. Reminds me of building with Lego.<\/p>","protected":false},"excerpt":{"rendered":"The Torah as traditionally written has two kinds of paragraph breaks: \"open\" and \"closed\". Open paragraphs are the same as in English typography: the next paragraph starts on the next line. Closed paragraphs start the next paragraph on the same line, after a 9-em gap. In the image on the page linked to above, there [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,20],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/3013"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=3013"}],"version-history":[{"count":10,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/3013\/revisions"}],"predecessor-version":[{"id":3023,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/3013\/revisions\/3023"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=3013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=3013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=3013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}