Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1x 1x 1x 1x 1x 1x 1x 16x 12x 16x 9x 16x 6x 16x 3x 3x 1x 1x 1x 5x 5x 3x 3x 1x 1x 1x 11x 8x 11x 4x 4x 1x 1x 1x 4x 4x 2x 2x | /**
* Shared utilities for mapping citation keys to foundation IDs and hrefs.
* Used by both EuclidCanvas (proof panel) and CitationPopover.
*/
/** Maps a citation key like "Post.3", "Def.15", "C.N.1" to a foundation item ID. */
export function getFoundationIdForCitation(citationKey?: string | null): string | null {
if (!citationKey) return null
const defMatch = citationKey.match(/^Def\.(\d+)$/)
if (defMatch) return `def-${defMatch[1]}`
const postMatch = citationKey.match(/^Post\.(\d+)$/)
if (postMatch) return `post-${postMatch[1]}`
const cnMatch = citationKey.match(/^C\.N\.(\d+)$/)
if (cnMatch) return `cn-${cnMatch[1]}`
return null
}
/** Returns the href for the foundations page focused on this citation, or null for propositions. */
export function getFoundationHref(citationKey?: string | null): string | null {
const id = getFoundationIdForCitation(citationKey)
if (!id) return null
return `/toys/euclid?focus=${encodeURIComponent(id)}`
}
/** Returns the proposition number for I.N citations, or null for others. */
export function getPropIdForCitation(citationKey?: string | null): number | null {
if (!citationKey) return null
const propMatch = citationKey.match(/^I\.(\d+)$/)
if (!propMatch) return null
return parseInt(propMatch[1], 10)
}
/** Returns the proposition page href for I.N citations, or null for others. */
export function getPropositionHref(citationKey?: string | null): string | null {
const propId = getPropIdForCitation(citationKey)
if (propId == null) return null
return `/toys/euclid/${propId}`
}
|