Skip to content

Commit

Permalink
Move content from HTML format to XML format
Browse files Browse the repository at this point in the history
In this commit, the content previously organized in HTML format has been
converted to XML format. This conversion involved updating various files
to replace the HTML-specific elements with their XML equivalents. The
changes include modifying the Makefile to handle XML files instead of
HTML, updating the chapters.sql file to adjust the structure for XML
data, and refining the CSS styling in both print.css and screen.css for
XML content presentation.

The modifications in this commit encompass changing file extensions from
.html to .xml in the .dockerignore and .gitignore files, adjusting file
paths and content structures in the Makefile and chapters.sql, and
updating CSS styling in print.css and creating a new screen.css file for
XML content representation. These changes are essential for
transitioning the project's content to XML format and ensuring
consistency across the various components of the project.
  • Loading branch information
placek committed May 6, 2024
1 parent 09261f1 commit bce2170
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 70 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.html
*.xml
*.pdf
*.zip
*.SQLite3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.html
*.xml
*.pdf
*.zip
*.SQLite3
Expand Down
32 changes: 17 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ left ?= PAU
right ?= NA28
name ?= pocket-nt

style := /app/style.css
screen:= /app/screen.css
print := /app/print.css
chapters := /app/chapters.sql
render := /app/render.sed
Expand All @@ -16,13 +16,15 @@ screen: $(left)-$(right)_screen.pdf
.PHONY: print
print: $(left)-$(right)_print.pdf

$(left)-$(right).html: info-$(left).html info-$(right).html cross_references.SQLite3
$(left)-$(right).xml: info-$(left).xml info-$(right).xml cross_references.SQLite3
mv "$(left).SQLite3" left.db; mv "$(right).SQLite3" right.db; \
{ echo "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" href=\"$(style)\"></head><body><info><name>$(name)</name>"; \
cat "info-$(left).html" "info-$(right).html"; \
{ echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; \
echo "<nt>"; \
echo "<info>"; \
echo "<name>$(name)</name>$$(cat 'info-$(left).xml' 'info-$(right).xml')"; \
echo "</info>"; \
sed 's/<RATE>/$(rate)/' $(chapters) | sqlite3 | sed -rf $(render); \
echo "</body></html>"; \
cat $(chapters) | sqlite3 | sed -rf $(render); \
echo "</nt>"; \
} > "$@"

%.zip:
Expand All @@ -44,21 +46,21 @@ cross_references.SQLite3: cross_references.csv
%.SQLite3: %.zip
unzip -j "$<"

%_screen.pdf: %.html
prince --verbose --pdf-title="pocket-nt" --no-network --page-size=$(size) --media=screen --output="/data/$@" "/data/$<"
%_screen.pdf: %.xml
prince --verbose --pdf-title="$(name)" --no-network --page-size=$(size) --media=screen --style=$(screen) --output="/data/$@" "/data/$<"

%_print_raw.pdf: %.html
prince --verbose --pdf-title="pocket-nt" --no-network --page-size=$(size) --media=print --style=$(print) --output="/data/$@" "/data/$<"
%_print_raw.pdf: %.xml
prince --verbose --pdf-title="$(name)" --no-network --page-size=$(size) --media=print --style=$(print) --output="/data/$@" "/data/$<"

%_print.pdf: %_print_raw.pdf
gs -dPDFX -dBATCH -dNOPAUSE -dNOOUTERSAVE -dNoOutputFonts -sDEVICE=pdfwrite -sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dHaveTransparency=false -sOutputFile="$@" "$<"

info-%.html: %.SQLite3
{ echo "<column><description>"; \
sqlite3 "$<" "SELECT value FROM info WHERE name = 'description'" | sed "s/,/<br>/g"; \
echo "</description></column>"; \
info-%.xml: %.SQLite3
{ echo "<description>"; \
sqlite3 "$<" "SELECT value FROM info WHERE name = 'description'"; \
echo "</description>"; \
} > "$@"

.PHONY: clean
clean:
rm -f *.html *.pdf *.db *.txt *.csv *.SQLite3
rm -f *.xml *.pdf *.db *.txt *.csv *.SQLite3
12 changes: 6 additions & 6 deletions chapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ ATTACH DATABASE 'cross_references.SQLite3' AS cr;
WITH
CrossReferences AS (
SELECT c.book_number, chapter, verse, b2,
GROUP_CONCAT('{{reference data-rate="' || rate || '"}}' ||
GROUP_CONCAT('{{reference rate="' || rate || '"}}' ||
CASE
WHEN b2 = '' THEN b.short_name || '&nbsp;' || c1 || ',' || v1
ELSE b.short_name || '&nbsp;' || c1 || ',' || v1 || '-' || c2 || ',' || v2
WHEN b2 = '' THEN b.short_name || ' ' || c1 || ',' || v1
ELSE b.short_name || ' ' || c1 || ',' || v1 || '-' || c2 || ',' || v2
END || '{{/reference}}'
, ' '
) AS refs
Expand All @@ -35,9 +35,9 @@ WITH
GROUP_CONCAT(
CASE
WHEN book_number IS NOT NULL THEN
'{{verse data-verse="' || verse || '"}}' || text || IFNULL(refs, '') || '{{/verse}}'
'{{verse number="' || verse || '"}}' || text || IFNULL(refs, '') || '{{/verse}}'
ELSE
'{{verse data-verse="' || verse || '"}}' || text || '{{/verse}}'
'{{verse number="' || verse || '"}}' || text || '{{/verse}}'
END, ''
) AS verses
FROM AllVersesD1 LEFT JOIN CrossReferences
Expand All @@ -46,7 +46,7 @@ WITH
),
AllChaptersD2 AS (
SELECT book_number, book, chapter,
GROUP_CONCAT('{{verse data-verse="' || verse || '"}}' || text || '{{/verse}}', '') AS verses
GROUP_CONCAT('{{verse number="' || verse || '"}}' || text || '{{/verse}}', '') AS verses
FROM AllVersesD2
GROUP BY book_number, chapter
)
Expand Down
46 changes: 45 additions & 1 deletion print.css
Original file line number Diff line number Diff line change
@@ -1 +1,45 @@
@page { marks: crop cross; bleed: 5mm; -prince-trim: 5mm; }
:root { --size: 2vh; }

@font-face { font-family: greek; src: url(fonts/newathu.ttf); }
@font-face { font-family: mono; src: url(fonts/mono.ttf); }
@font-face { font-family: f1; src: url(fonts/freeserif.ttf); }
@font-face { font-family: f2; src: url(fonts/freesans.ttf); }

@page { margin: 1.6em .8em .8em .8em; marks: crop cross; bleed: 5mm; -prince-trim: 5mm; }
@page book:left { @top-left { content: string(book); font-family: mono; font-weight: 600; font-size: var(--size); } }
@page book:right { @top-right { content: string(chapter); font-family: mono; font-weight: 600; font-size: var(--size); } }
@page book:blank { @top-left { content: ""; } @top-right { content: ""; } }

* { margin: 0; padding: 0; }
body { font-size: var(--size); text-align: justify; font-family: greek, mono, f1, f2; line-height: 1.2; font-variant-ligatures: historical-ligatures; }

info { display: flex; width: 100%; justify-content: space-between; }
info name { font-family: mono; font-weight: 600; font-size: 6vh; margin: 46vh 0; padding: 0; text-align: center; display: block; }

book { string-set: book attr(data-book); display: block; break-before: left; page: book; -prince-bookmark-level: 1; -prince-bookmark-label: attr(data-book); }

column { display: block; padding: 0 .5em; hyphens: auto; }

chapter { string-set: chapter attr(data-chapter); display: flex; -prince-bookmark-level: 2; -prince-bookmark-label: attr(data-chapter); }
chapter:before { content: attr(data-chapter); font-family: mono; font-weight: 600; }
chapter[data-chapter="1"]:before { display: none; }
chapter[data-chapter="1"] verse[data-verse="1"] { padding-top: 1em; }
chapter[data-chapter="1"] verse[data-verse="1"]::first-letter { font-size: 2.2em; float: left; line-height: 0.5em; }

verse { display: inline; }
verse[data-verse="1"] { display: inline-block; }
verse[data-verse="1"]:before { display: none; }
verse:before { content: attr(data-verse); font-family: mono; font-weight: 600; font-size: .6em; margin: 0 .5em; vertical-align: super; }

reference { font-family: mono; font-size: .6em; margin: 0 .5em; vertical-align: baseline; display: inline; }

reference[data-rate="1"],
reference[data-rate="2"],
reference[data-rate="3"],
reference[data-rate="4"],
reference[data-rate="5"],
reference[data-rate="6"],
reference[data-rate="7"],
reference[data-rate="8"],
reference[data-rate="9"]
{ display: none; }
6 changes: 3 additions & 3 deletions render.sed
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ s/\s+/ /g # remove extra whitespaces
s/\s+([,\.\?:;!\]\)\}»])/\1/g # remove whitespaces before punctuation and closing brackets
s/([\(\{\[«])\s+/\1/g # remove whitespaces after opening brackets

s/^[0-9]*\|([^|]*)\|1\|([^|]*)\|([^|]*)$/<\/book><book data-book="\1"><chapter data-chapter="1"><column class="left">\2<\/column><column class="right">\3<\/column><\/chapter>/
s/^[0-9]*\|[^|]*\|([^|]*)\|([^|]*)\|([^|]*)$/<chapter data-chapter="\1"><column class="left">\2<\/column><column class="right">\3<\/column><\/chapter>/
s/^[0-9]*\|([^|]*)\|1\|([^|]*)\|([^|]*)$/<\/book><book name="\1"><number>1<\/number><chapter><left>\2<\/left><right>\3<\/right><\/chapter>/
s/^[0-9]*\|[^|]*\|([^|]*)\|([^|]*)\|([^|]*)$/<number>\1<\/number><chapter><left>\2<\/left><right>\3<\/right><\/chapter>/
s/\{\{/</g
s/\}\}/>/g
s/\b(z|do|na|przy|bez|dla|nad|pod|przed|po|w|o|u|ku|za|a|i|oraz|ale|lecz|czy|czyli|więc|bo|się|ci|mu|mi|jej|jemu|mnie|tobie|sobie|kto|co|który|która|które|jak|gdzie) /\1\&nbsp;/gI
s/\b(z|do|na|przy|bez|dla|nad|pod|przed|po|w|o|u|ku|za|a|i|oraz|ale|lecz|czy|czyli|więc|bo|się|ci|mu|mi|jej|jemu|mnie|tobie|sobie|kto|co|który|która|które|jak|gdzie) /\1\ /gI

1s/<\/book>//
$a</book>
51 changes: 51 additions & 0 deletions screen.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
:root { --size: 2.1vh; }

@font-face { font-family: greek; src: url(fonts/newathu.ttf); }
@font-face { font-family: mono; src: url(fonts/mono.ttf); }
@font-face { font-family: f1; src: url(fonts/freeserif.ttf); }
@font-face { font-family: f2; src: url(fonts/freesans.ttf); }

@page { margin: 7vh 5vh 5vh 5vh; }
@page book:left { @top-left { content: string(book); font-family: mono; font-weight: 600; font-size: var(--size); } }
@page book:right { @top-right-corner { content: string(chapter); font-family: mono; font-weight: 600; font-size: var(--size); } }
@page book:blank { @top-left { content: ""; } @top-right { content: ""; } }

* { margin: 0; padding: 0; }
nt { font-size: var(--size); text-align: justify; font-family: greek, mono, f1, f2; line-height: 1.2; font-variant-ligatures: historical-ligatures; }

info { width: 100%; justify-content: space-between; }
info name { font-family: mono; font-weight: 600; font-size: 6vh; margin: 47vh 0; padding: 0; text-align: center; display: block; }

book { string-set: book attr(name); display: block; break-before: left; page: book; -prince-bookmark-level: 1; -prince-bookmark-label: attr(name); }

column, left, right { display: block; padding: 0 .5em; hyphens: auto; min-width: 45%; }

chapter { display: flex; }
chapter[number="1"] verse[number="1"] { padding-top: 1em; }

number { string-set: chapter content(); -prince-bookmark-level: 2; -prince-bookmark-label: string(chapter); font-family: mono; font-weight: 600; -prince-float: outside; -prince-margin-outside: -1em; break-after: avoid; }
chapter[number="1"] number { display: none; }

book chapter:first-of-type verse[number="1"] { display: block; }
book chapter:first-of-type verse[number="1"]::first-letter { font-size: 2.2em; float: left; line-height: 0.5em; }
book chapter:first-of-type verse[number="1"]:before { display: none; }
verse { display: inline; }
verse:before { content: attr(number); font-family: mono; font-weight: 600; font-size: .6em; margin: 0 .5em; vertical-align: super; }

reference { font-family: mono; font-size: .6em; margin: 0 .5em; vertical-align: baseline; display: inline; }

reference[rate="1"],
reference[rate="2"],
reference[rate="3"],
reference[rate="4"],
reference[rate="5"],
reference[rate="6"],
reference[rate="7"],
reference[rate="8"],
reference[rate="9"],
reference[rate="10"],
reference[rate="11"],
reference[rate="12"],
reference[rate="13"],
reference[rate="14"]
{ display: none; }
45 changes: 0 additions & 45 deletions style.css

This file was deleted.

0 comments on commit bce2170

Please sign in to comment.