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(parser): preserve all text in fused column rows (#3644)

Santhi Prakash4e6c0f9f5b2f
diff --git a/apps/web/src/features/resume/editor/check/parser-view.test.tsx b/apps/web/src/features/resume/editor/check/parser-view.test.tsx
index eba89ad32..8d8e56162 100644
--- a/apps/web/src/features/resume/editor/check/parser-view.test.tsx
+++ b/apps/web/src/features/resume/editor/check/parser-view.test.tsx
@@ -7,18 +7,26 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useEditorStore } from "../store";
import { ParserView } from "./parser-view";
-const mocks = vi.hoisted(() => ({ resumeId: "A", extract: vi.fn(async (file: File) => file.text()) }));
+const mocks = vi.hoisted(() => ({
+ resumeId: "A",
+ extract: vi.fn(async (file: File) => file.text()),
+ headings: [] as { lineIndex: number; text: string }[],
+}));
vi.mock("@/features/resume/builder/draft", () => ({
useCurrentBuilderResumeSelector: (select: (resume: { id: string }) => unknown) => select({ id: mocks.resumeId }),
}));
vi.mock("./use-check", () => ({ useCheck: () => null }));
vi.mock("@/features/ats-checker/extract-client", () => ({ extractPdf: mocks.extract }));
vi.mock("@reactive-resume/resume/ats-pdf", () => ({
- buildExtractedDocument: (text: string) => ({ pages: [], lines: [{ text }], charCount: text.length }),
+ buildExtractedDocument: (text: string) => ({
+ pages: [],
+ lines: text.split("\n").map((text) => ({ text })),
+ charCount: text.length,
+ }),
buildResumeSemantics: () => ({
contact: { nameLine: "", locationLine: "", emails: [], phones: [], textUrls: [], annotationUrls: [] },
dates: [],
- headings: [],
+ headings: mocks.headings,
}),
}));
@@ -55,3 +63,46 @@ it("extracts each document and each reopened render independently", async () =>
client.clear();
});
});
+
+// The display receives fused lines from extraction; it must never replace their text with one heading.
+it("preserves fused heading/content rows and their continuations in reading order", async () => {
+ i18n.loadAndActivate({ locale: "en", messages: {} });
+ const lines = [
+ "Experience",
+ "Unity Engine Unreal Engine Programming Languages",
+ "Expert Advanced Expert",
+ "Left column continuation",
+ "Certifications March 2022",
+ "Education",
+ "University of Example",
+ ];
+ mocks.headings = [
+ { lineIndex: 0, text: "Experience" },
+ { lineIndex: 1, text: "Unity Engine" },
+ { lineIndex: 1, text: "Unreal Engine" },
+ { lineIndex: 1, text: "Programming Languages" },
+ { lineIndex: 4, text: "Certifications" },
+ { lineIndex: 5, text: "Education" },
+ ];
+ mocks.resumeId = "columns";
+ useEditorStore.getState().reset();
+ useEditorStore.getState().setRendered({ pageCount: 2, pageMap: undefined, file: new Blob([lines.join("\n")]) });
+ const client = new QueryClient();
+ const view = render(
+ <QueryClientProvider client={client}>
+ <I18nProvider i18n={i18n}>
+ <ParserView />
+ </I18nProvider>
+ </QueryClientProvider>,
+ );
+ await screen.findByText("University of Example");
+ expect([...view.container.querySelectorAll("section h3, section p")].map((element) => element.textContent)).toEqual([
+ "▸ EXPERIENCE",
+ ...lines.slice(1, 5),
+ "▸ EDUCATION",
+ "University of Example",
+ ]);
+ view.unmount();
+ await act(async () => client.clear());
+ mocks.headings = [];
+});
diff --git a/apps/web/src/features/resume/editor/check/parser-view.tsx b/apps/web/src/features/resume/editor/check/parser-view.tsx
index 9ecfd197f..df38e7294 100644
--- a/apps/web/src/features/resume/editor/check/parser-view.tsx
+++ b/apps/web/src/features/resume/editor/check/parser-view.tsx
@@ -129,12 +129,13 @@ function ParsedText({ parsed, issues }: { parsed: Parsed; issues: readonly Check
},
];
- // Lines grouped under the headings a parser recognised, in the order it reads them.
+ // Only standalone headings replace a text line; fused columns must retain the full line in reading order.
const headingAt = new Map(semantics.headings.map((heading) => [heading.lineIndex, heading.text]));
const groups: { heading: string | null; lines: string[] }[] = [{ heading: null, lines: [] }];
doc.lines.forEach((line, index) => {
const heading = headingAt.get(index);
- if (heading !== undefined) groups.push({ heading, lines: [] });
+ if (heading === line.text.trim()) groups.push({ heading, lines: [] });
+ else if (heading !== undefined) groups.push({ heading: null, lines: [line.text] });
else groups.at(-1)?.lines.push(line.text);
});