Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix(resume): detect section headings set in a side column (#3521)

Santhi Prakash28d0170b05da
diff --git a/packages/pdf/src/ats-extraction.integration.test.tsx b/packages/pdf/src/ats-extraction.integration.test.tsx
index d72d4dda3..d8194c1d1 100644
--- a/packages/pdf/src/ats-extraction.integration.test.tsx
+++ b/packages/pdf/src/ats-extraction.integration.test.tsx
@@ -130,6 +130,24 @@ describe("a resume rendered by this app", () => {
expect(failed).not.toContain("HEADINGS_NOT_DISTINGUISHED");
});
+ /**
+ * Regression guard for #3519: bronzor sets each section title in a narrow column beside
+ * the section's content, and baseline clustering merges it into the first content line.
+ * The heading is a separate run in its own column, so the check has to find it there
+ * rather than report the whole resume as unsegmented.
+ */
+ it("finds the conventional sections in a bronzor export", { timeout: 60_000 }, async () => {
+ const { report } = await analyze(await renderResume(sampleResumeData, "bronzor"));
+ const failed = failedCodes(report);
+
+ expect(failed).not.toContain("NO_RECOGNIZED_HEADINGS");
+ expect(failed).not.toContain("FEW_SECTION_HEADINGS");
+ expect(failed).not.toContain("NO_EXPERIENCE_SECTION");
+ expect(failed).not.toContain("NO_EDUCATION_SECTION");
+ expect(failed).not.toContain("NO_SKILLS_SECTION");
+ expect(failed).not.toContain("NO_SUMMARY_SECTION");
+ });
+
it("warns about a two-column template's gutter without capping its score", { timeout: 60_000 }, async () => {
const { report } = await analyze(await renderResume(sampleResumeData, "gengar"));
diff --git a/packages/resume/src/ats-pdf/analyze/sections.ts b/packages/resume/src/ats-pdf/analyze/sections.ts
index 862f10a15..1eacdff08 100644
--- a/packages/resume/src/ats-pdf/analyze/sections.ts
+++ b/packages/resume/src/ats-pdf/analyze/sections.ts
@@ -1,6 +1,7 @@
import type { CustomSectionType } from "@reactive-resume/schema/resume/data";
import type { DetectedHeading, ExtractedDocument, TextLine } from "../types";
import { PDF_SECTION_HEADING_LOOKUP } from "../../ats/section-aliases";
+import { columnSegments } from "../extract";
/** Headings are short. Past this many words a line is a sentence, not a section title. */
const MAX_HEADING_WORDS = 6;
@@ -79,18 +80,22 @@ export function detectHeadings(document: ExtractedDocument): DetectedHeading[] {
const headings: DetectedHeading[] = [];
document.lines.forEach((line, lineIndex) => {
- const normalized = normalizeHeading(line.text);
- if (!looksLikeHeading(line, normalized, document)) return;
-
- headings.push({
- text: line.text.trim(),
- normalized,
- sectionType: NORMALIZED_HEADINGS.get(normalized) ?? null,
- page: line.page,
- lineIndex,
- fontSize: line.fontSize,
- distinguished: isDistinguished(line, document),
- });
+ // A heading set in its own narrow column shares a baseline with the first line of the
+ // section's content, so the line it lands on has to be read in column-separated pieces.
+ for (const segment of columnSegments(line)) {
+ const normalized = normalizeHeading(segment.text);
+ if (!looksLikeHeading(segment, normalized, document)) continue;
+
+ headings.push({
+ text: segment.text.trim(),
+ normalized,
+ sectionType: NORMALIZED_HEADINGS.get(normalized) ?? null,
+ page: segment.page,
+ lineIndex,
+ fontSize: segment.fontSize,
+ distinguished: isDistinguished(segment, document),
+ });
+ }
});
return headings;
diff --git a/packages/resume/src/ats-pdf/extract.ts b/packages/resume/src/ats-pdf/extract.ts
index e7f50153d..5a1abcdd7 100644
--- a/packages/resume/src/ats-pdf/extract.ts
+++ b/packages/resume/src/ats-pdf/extract.ts
@@ -15,6 +15,10 @@ const MIN_LINE_TOLERANCE_PT = 2;
/** Horizontal gap, as a share of font size, above which two spans need a space between them. */
const SPACE_GAP_RATIO = 0.25;
+/** Horizontal gap, as a share of font size, above which two spans sit in different columns. */
+const COLUMN_GAP_RATIO = 2.5;
+const MIN_COLUMN_GAP_PT = 20;
+
const HISTOGRAM_BIN_PT = 2;
const ROW_BIN_PT = 6;
const MIN_GUTTER_WIDTH_PT = 14;
@@ -285,6 +289,34 @@ function findGutter(spans: readonly TextSpan[], page: RawPage): ColumnGutter | n
return { x, width, coverage, splitRatio };
}
+/**
+ * Splits a clustered line at column-sized gaps between its spans.
+ *
+ * Baseline clustering joins every span that shares a baseline however far apart the spans sit,
+ * which is what a heading set in its own narrow column looks like beside the section's first
+ * content line ("Profiles GitHub"). The pieces are still analysed as one line everywhere else;
+ * this view exists for consumers that need the column-separated parts.
+ */
+export function columnSegments(line: TextLine): TextLine[] {
+ const [first, ...rest] = line.spans;
+ if (!first || rest.length === 0) return [line];
+
+ const groups: TextSpan[][] = [[first]];
+ let previous = first;
+ for (const span of rest) {
+ const gap = span.x - (previous.x + previous.width);
+ const threshold = Math.max(MIN_COLUMN_GAP_PT, COLUMN_GAP_RATIO * Math.max(previous.fontSize, span.fontSize, 1));
+
+ if (gap > threshold) groups.push([span]);
+ else groups[groups.length - 1]?.push(span);
+ previous = span;
+ }
+
+ if (groups.length === 1) return [line];
+
+ return groups.map((group) => toLine(group, line.page));
+}
+
/**
* Robust order statistic. Margins are measured at the 5th and 95th percentile rather than at the
* extremes because a single right-aligned run whose reported width overshoots by a few points
diff --git a/packages/resume/src/ats-pdf/rules.test.ts b/packages/resume/src/ats-pdf/rules.test.ts
index 8e22521ba..d6bb4a235 100644
--- a/packages/resume/src/ats-pdf/rules.test.ts
+++ b/packages/resume/src/ats-pdf/rules.test.ts
@@ -271,6 +271,42 @@ describe("section checks", () => {
expect(codesOf(thin)).toContain("VERY_SHORT_DOCUMENT");
});
+
+ /**
+ * The bronzor template sets each section title in a narrow column beside the section's
+ * content, so baseline clustering merges the heading into the first content line
+ * ("Profiles GitHub"). The heading is still a separate run in its own column and the
+ * check has to find it there.
+ */
+ it("finds headings set in a side column beside the first line of content", () => {
+ const bronzorLike = makeRawExtraction({
+ lines: [
+ { text: "Ada Lovelace", size: 18 },
+ "[email protected] · +44 20 7946 0100 · London, UK",
+ { text: "Profiles", x: 33, y: 200, size: 9, fontRef: "g_d0_f2" },
+ { text: "github.com/adalovelace", x: 201, y: 200 },
+ { text: "Experience", x: 33, y: 250, size: 9, fontRef: "g_d0_f2" },
+ { text: "Principal Engineer | Analytical Engines, London", x: 201, y: 250 },
+ { text: "Jan 2020 - Present", x: 201, y: 265 },
+ { text: "• Delivered a note-taking programme that cut calculation time by 40%.", x: 201, y: 280 },
+ { text: "Education", x: 33, y: 320, size: 9, fontRef: "g_d0_f2" },
+ { text: "University of London | Mathematics", x: 201, y: 320 },
+ { text: "Sep 2011 - Jun 2015", x: 201, y: 335 },
+ { text: "Skills", x: 33, y: 370, size: 9, fontRef: "g_d0_f2" },
+ { text: "Algorithms, numerical analysis, technical writing", x: 201, y: 370 },
+ { text: "Summary", x: 33, y: 400, size: 9, fontRef: "g_d0_f2" },
+ { text: "Analytical engineer who builds calculation systems.", x: 201, y: 400 },
+ ],
+ });
+
+ const result = report(bronzorLike);
+
+ expect(statusOf(result, "NO_RECOGNIZED_HEADINGS")).toBe("pass");
+ expect(statusOf(result, "NO_EXPERIENCE_SECTION")).toBe("pass");
+ expect(statusOf(result, "NO_EDUCATION_SECTION")).toBe("pass");
+ expect(statusOf(result, "NO_SKILLS_SECTION")).toBe("pass");
+ expect(statusOf(result, "NO_SUMMARY_SECTION")).toBe("pass");
+ });
});
describe("contact checks", () => {