Skip to content

Commit 4d72acd

Browse files
authored
Merge pull request #99 from kdroidFilter/fix/maharsha-book-titles-440
fix(sefariasqlite): name the Maharsha in his Talmud commentaries' titles
2 parents 1b1cdaa + 3e74fb1 commit 4d72acd

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.github.kdroidfilter.seforimlibrary.sefariasqlite
2+
3+
/**
4+
* Author prefixes for Sefaria collections whose Hebrew title doesn't name the author,
5+
* keyed by English collective title. The app shows a commentary by its title without
6+
* " על <base book>", so "חידושי אגדות" alone doesn't tell the reader it's the Maharsha.
7+
*/
8+
private val authorPrefixesByCollectiveTitle = mapOf(
9+
"Chidushei Agadot" to "מהרש\"א",
10+
"Chidushei Halachot" to "מהרש\"א",
11+
)
12+
13+
/**
14+
* Title displayed for a Sefaria book: its Hebrew title, prefixed with the author when
15+
* its collection needs it. Only the display title changes; `heTitle` stays the natural key.
16+
*/
17+
internal fun sefariaDisplayTitle(heTitle: String, collectiveTitleEn: String?): String {
18+
val prefix = collectiveTitleEn?.let { authorPrefixesByCollectiveTitle[it] } ?: return heTitle
19+
return if (heTitle.startsWith(prefix)) heTitle else "$prefix - $heTitle"
20+
}

‎generator/sefariasqlite/src/jvmMain/kotlin/io/github/kdroidfilter/seforimlibrary/sefariasqlite/SefariaDirectImporter.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class SefariaDirectImporter(
238238
id = bookId,
239239
categoryId = catId,
240240
sourceId = sourceId,
241-
title = payload.heTitle,
241+
title = sefariaDisplayTitle(payload.heTitle, payload.collectiveTitleEn),
242242
heRef = payload.heTitle,
243243
authors = resolvedAuthors,
244244
pubPlaces = emptyList(),
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.github.kdroidfilter.seforimlibrary.sefariasqlite
2+
3+
import kotlin.test.Test
4+
import kotlin.test.assertEquals
5+
6+
/**
7+
* Regression for https://github.com/kdroidFilter/Zayit/issues/440: the Maharsha's
8+
* commentaries were listed as "חידושי הלכות" / "חידושי אגדות" without his name.
9+
*/
10+
class SefariaBookTitlesTest {
11+
@Test
12+
fun prefixesMaharshaCollections() {
13+
assertEquals(
14+
"מהרש\"א - חידושי אגדות על חולין",
15+
sefariaDisplayTitle("חידושי אגדות על חולין", "Chidushei Agadot"),
16+
)
17+
assertEquals(
18+
"מהרש\"א - חידושי הלכות על שבת",
19+
sefariaDisplayTitle("חידושי הלכות על שבת", "Chidushei Halachot"),
20+
)
21+
}
22+
23+
@Test
24+
fun keepsOtherTitles() {
25+
assertEquals("רש\"י על ברכות", sefariaDisplayTitle("רש\"י על ברכות", "Rashi"))
26+
assertEquals("ברכות", sefariaDisplayTitle("ברכות", null))
27+
}
28+
}

0 commit comments

Comments
 (0)