Skip to content

Commit

Permalink
Fix page ordering in some epubs
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa-khaled775 committed Jul 21, 2024
1 parent 0f0c4d1 commit 567e0a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions jq/build-quran-xhtml.jq
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"\n<p class=\"basmala\">﷽</p>\n" as $basmala
| map({sura_en: .sura_name_en, sura: .sura_name_ar, text: .aya_text, num: .aya_no, sura_no,
page: (if .page | type == "string" then .page | [ scan("[0-9]+") ][0] | tonumber else .page end)})
| group_by(.page)
| sort_by(first | .page)
| [
.[]
| map({sura: .sura_name_ar, text: .aya_text, num: .aya_no, sura_no})
| reduce .[] as $ayah ("";
.
+ if $ayah.num == 1 then
if $ayah.sura_no != 1 then "\n</section>\n" else "" end
+ "<section id=\"\($ayah.sura)\" class=\"level2\">\n<h2>\($ayah.sura)</h2>\n"
+ "<section id=\"sura-\($ayah.sura_no)\" class=\"level2\">\n<h2>\($ayah.sura)</h2>\n"
else "" end
+ if $ayah.num == 1 and $ayah.sura_no != 1 and $ayah.sura_no != 9 then $basmala else "" end
+ $ayah.text
+ " "
)
]
| join("\n<div style=\"page-break-after: always;\"></div>")
| join("\n<div style=\"page-break-after: always;\"></div>\n")
3 changes: 2 additions & 1 deletion jq/build-toc-ncx.jq
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ group_by(.sura_name_ar)
| sort_by(first | .sura_no)
| reduce .[] as $sura ("";
$sura[0].sura_name_ar as $name
| $sura[0].sura_name_en as $name_en
| $sura[0].sura_no as $num
| . + "<navPoint id=\"navPoint-\($num)\"><navLabel><text>\($name)</text></navLabel><content src=\"text/quran.xhtml#\($name)\" /></navPoint>\n")
| . + "<navPoint id=\"navPoint-\($num)\"><navLabel><text>\($name)</text></navLabel><content src=\"text/quran.xhtml#sura-\($num)\" /></navPoint>\n")
3 changes: 2 additions & 1 deletion jq/build-toc-xhtml.jq
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ group_by(.sura_name_ar)
| sort_by(first | .sura_no)
| reduce .[] as $sura ("";
$sura[0].sura_name_ar as $name
| $sura[0].sura_name_en as $name_en
| $sura[0].sura_no as $num
| . + "<li id=\"toc-li-\($num)\"><a href=\"text/quran.xhtml#\($name)\">\($name)</a></li>\n")
| . + "<li id=\"toc-li-\($num)\"><a href=\"text/quran.xhtml#sura-\($num)\">\($name)</a></li>\n")

0 comments on commit 567e0a9

Please sign in to comment.