app/lib/scientific-names.tsx
15 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| italicizeOrganisms | 5 to 19 | 5 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports app/data/organisms.ts. Imported by app/routes/cv.tsx, app/routes/publications.$slug.tsx, app/routes/publications.tsx.
Source
import type { ReactNode } from "react";
import { ORGANISM_PATTERN } from "~/data/organisms";
export function italicizeOrganisms(text: string): ReactNode[] {
const nodes: ReactNode[] = [];
let cursor = 0;
// matchAll does not disturb ORGANISM_PATTERN.lastIndex.
for (const match of text.matchAll(ORGANISM_PATTERN)) {
const start = match.index ?? 0;
if (start > cursor) nodes.push(text.slice(cursor, start));
nodes.push(<em key={`${start}-${match[0]}`}>{match[0]}</em>);
cursor = start + match[0].length;
}
if (cursor < text.length) nodes.push(text.slice(cursor));
return nodes;
}