Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ internal class SefariaLinksImporter(
val srcSideMask = if (wasSwapped) exportedMask2 else exportedMask1
val tgtSideMask = if (wasSwapped) exportedMask1 else exportedMask2
queueSuppression(linkId, side = 0, mask = srcSideMask)
queueSuppression(linkId, side = 1, mask = tgtSideMask)
queueSuppression(linkId, side = 1, mask = commentarySideMask(storedType, tgtSideMask))
}

// Ranged sides: record the range end + per-line coverage.
Expand Down Expand Up @@ -1236,6 +1236,13 @@ internal fun computeBaseProvenance(storedSrcBook: Long, storedTgtMeta: BookMeta?
/** The reasons that make a ranged side stop covering its unit's lines. */
internal const val WHOLE_UNIT_REASONS = SuppressionReason.WHOLE_PEREK or SuppressionReason.WHOLE_PARASHA

/**
* The commentary side of a COMMENTARY link stays visible when Sefaria hid it only for citing a
* whole section (Tur Choshen Mishpat → Beit Yosef 157:1): the link resolves to the section's first line.
*/
internal fun commentarySideMask(storedType: ConnectionType, mask: Int): Int =
if (storedType == ConnectionType.COMMENTARY && mask == SuppressionReason.ANCHOR_NOT_SEGMENT) 0 else mask

/**
* A required `Suppression Mask 1/2` cell from a new-format export. Zero must be
* explicit: a blank/missing/unparsable/unknown value fails closed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class SefariaSuppressedSideTest {
row(
"Migdal Oz 5:1",
"Bava Batra 28a:1",
SuppressionReason.ANCHOR_NOT_SEGMENT,
SuppressionReason.OTHER_TOO_COARSE,
0,
type = "commentary",
),
Expand All @@ -221,6 +221,28 @@ class SefariaSuppressedSideTest {
// The dependant→base CSV row is stored base→dependant. Citation 1's
// verdict must therefore land on stored side 1, not side 0.
assertEquals(1, imported.suppressed.size)
assertEquals(
listOf(1L, SuppressionReason.OTHER_TOO_COARSE.toLong()),
imported.suppressed[0].drop(1),
)
}

@Test
fun sectionLevelCommentaryCitationStaysVisibleOnTheCommentary() {
val imported = importWith(
HEADER_WITH_MASKS,
row("Migdal Oz 5:1", "Bava Batra 28a:1", SuppressionReason.ANCHOR_NOT_SEGMENT, 0, type = "commentary"),
)
assertTrue(imported.suppressed.isEmpty(), "got ${imported.suppressed}")
}

@Test
fun sectionLevelReferenceCitationStaysHidden() {
val imported = importWith(
HEADER_WITH_MASKS,
row("Bava Batra 28a:1", "Migdal Oz 5:1", 0, SuppressionReason.ANCHOR_NOT_SEGMENT),
)
assertEquals(1, imported.suppressed.size)
assertEquals(
listOf(1L, SuppressionReason.ANCHOR_NOT_SEGMENT.toLong()),
imported.suppressed[0].drop(1),
Expand Down