Render one identity entry into `lines`.
(
lines: string[],
ce: ReturnType<typeof createEngine>,
headDesc: Map<string, string>,
{ e, u }: Resolved
)
| 277 | |
| 278 | /** Render one identity entry into `lines`. */ |
| 279 | function renderEntry( |
| 280 | lines: string[], |
| 281 | ce: ReturnType<typeof createEngine>, |
| 282 | headDesc: Map<string, string>, |
| 283 | { e, u }: Resolved |
| 284 | ): number { |
| 285 | let boxFailures = 0; |
| 286 | |
| 287 | const latex = mathjsonToLatex(ce, e, e.formula); |
| 288 | if (latex === null) { |
| 289 | boxFailures++; |
| 290 | lines.push('```json', JSON.stringify(e.formula), '```'); |
| 291 | } else { |
| 292 | lines.push(`$$${latex}$$`); |
| 293 | } |
| 294 | lines.push(''); |
| 295 | |
| 296 | // OPTION-B hook: render Fungrim's prose description once the corpus carries |
| 297 | // it (dormant until a re-translation adds a per-entry `description` field). |
| 298 | const desc = (e as any).description; |
| 299 | if (typeof desc === 'string' && desc.trim()) { |
| 300 | lines.push(desc.trim(), ''); |
| 301 | } |
| 302 | |
| 303 | const conds: string[] = []; |
| 304 | if (e.assumptions) { |
| 305 | const a = mathjsonToLatex(ce, e, e.assumptions); |
| 306 | if (a) conds.push(`$${a}$`); |
| 307 | } |
| 308 | for (const alt of ((e as any).assumptionAlternatives ?? []) as unknown[]) { |
| 309 | const a = mathjsonToLatex(ce, e, alt); |
| 310 | if (a) conds.push(`$${a}$`); |
| 311 | } |
| 312 | if (conds.length === 1) lines.push(`**Holds when** ${conds[0]}.`); |
| 313 | else if (conds.length > 1) |
| 314 | lines.push(`**Holds when** ${conds.join(' _or_ ')}.`); |
| 315 | |
| 316 | const syms = (e.heads ?? []) |
| 317 | .filter((h) => headDesc.has(h)) |
| 318 | .map((h) => `**${h}** — ${headDesc.get(h)}`); |
| 319 | if (syms.length) lines.push(`**Symbols:** ${syms.join('; ')}.`); |
| 320 | |
| 321 | const usageStr = usageSentence(u); |
| 322 | if (usageStr) lines.push(usageStr); |
| 323 | |
| 324 | // Curated (non-hex) entries carry an internal provenance note in |
| 325 | // `references`, not a citation — suppress it. |
| 326 | const refs = isHexId(e.id) ? referencesOf(e) : []; |
| 327 | if (refs.length === 1) lines.push(`**Reference:** ${renderReference(refs[0])}`); |
| 328 | else if (refs.length > 1) { |
| 329 | lines.push('**References:**'); |
| 330 | for (const r of refs) lines.push(`- ${renderReference(r)}`); |
| 331 | } |
| 332 | |
| 333 | lines.push( |
| 334 | isHexId(e.id) |
| 335 | ? `[\`${e.id}\` · Fungrim entry ↗](${FUNGRIM_ENTRY(e.id)})` |
| 336 | : `\`${e.id}\` · _curated identity (not in the upstream Fungrim corpus)_` |
no test coverage detected