Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

fix(styles): update bullet character in style sets to ensure consistency across components

Khuram Niazb52f2a3d5e11
diff --git a/__tests__/resume-pdf.spec.ts b/__tests__/resume-pdf.spec.ts
index da9a8b4..39d9837 100644
--- a/__tests__/resume-pdf.spec.ts
+++ b/__tests__/resume-pdf.spec.ts
@@ -19,9 +19,9 @@ const simpleStyleSet: HtmlStyleSet = {
bulletChar: "•",
};
-const professionalStyleSet: HtmlStyleSet = {
+const customBulletStyleSet: HtmlStyleSet = {
...simpleStyleSet,
- bulletChar: "▪",
+ bulletChar: "»",
};
describe("sanitizeFilename", () => {
@@ -125,12 +125,22 @@ describe("htmlToPdfNodes — layout style sets", () => {
expect(JSON.stringify(nodes)).toContain("•");
});
- it("uses the professional bullet char (▪) for list items", () => {
- const nodes = htmlToPdfNodes("<ul><li>Foo</li></ul>", professionalStyleSet);
- expect(JSON.stringify(nodes)).toContain("▪");
+ it("uses the style set's own bullet char for list items", () => {
+ const nodes = htmlToPdfNodes("<ul><li>Foo</li></ul>", customBulletStyleSet);
+ expect(JSON.stringify(nodes)).toContain("»");
expect(JSON.stringify(nodes)).not.toContain("•");
});
+ it("replaces unicode minus and hyphens the PDF font cannot encode", () => {
+ const nodes = htmlToPdfNodes(
+ "<p>− Observe ‐ ‑ ‒ done</p>",
+ simpleStyleSet,
+ );
+ const serialized = JSON.stringify(nodes);
+ expect(serialized).toContain("- Observe - - - done");
+ expect(serialized).not.toMatch(/[‐-‒−]/);
+ });
+
it("renders <h2> and includes its text content", () => {
const nodes = htmlToPdfNodes("<h2>Skills</h2>", simpleStyleSet);
expect(nodes).toHaveLength(1);
diff --git a/__tests__/resumeStyleBuilders.spec.ts b/__tests__/resumeStyleBuilders.spec.ts
index a223549..48b5e18 100644
--- a/__tests__/resumeStyleBuilders.spec.ts
+++ b/__tests__/resumeStyleBuilders.spec.ts
@@ -129,7 +129,7 @@ describe("buildProfessionalStyles at the defaults", () => {
it("returns an html style set with the professional bullet char", () => {
const { htmlStyles } = buildProfessionalStyles(defaultResumeExportSettings);
- expect(htmlStyles.bulletChar).toBe("▪");
+ expect(htmlStyles.bulletChar).toBe("•");
});
// Guards the regression the settings work introduced once: Professional
diff --git a/src/components/pdf-export/html-to-pdf.tsx b/src/components/pdf-export/html-to-pdf.tsx
index f3fe44e..905c045 100644
--- a/src/components/pdf-export/html-to-pdf.tsx
+++ b/src/components/pdf-export/html-to-pdf.tsx
@@ -6,6 +6,9 @@ import { HtmlStyleSet } from "./types";
const TEXT_NODE = 3;
const ELEMENT_NODE = 1;
+// The standard-14 fonts only encode WinAnsi; unicode hyphens/minus vanish
+const UNENCODABLE_HYPHENS = /[‐-‒−]/g;
+
type InheritedStyle = {
bold?: boolean;
italic?: boolean;
@@ -25,7 +28,7 @@ function walkNode(
s: HtmlStyleSet,
): React.ReactElement | string | null {
if (node.nodeType === TEXT_NODE) {
- const text = node.textContent ?? "";
+ const text = (node.textContent ?? "").replace(UNENCODABLE_HYPHENS, "-");
if (!text) return null;
const style = inlineStyle(inherited, s);
return style ? (
diff --git a/src/components/profile/resume-pdf/styles/professional.styles.ts b/src/components/profile/resume-pdf/styles/professional.styles.ts
index da90c1d..295b2bc 100644
--- a/src/components/profile/resume-pdf/styles/professional.styles.ts
+++ b/src/components/profile/resume-pdf/styles/professional.styles.ts
@@ -175,7 +175,7 @@ export function buildProfessionalStyles(settings: ResumeExportSettings) {
listRow: styles.listRow,
bullet: styles.bullet,
listText: styles.listText,
- bulletChar: "▪",
+ bulletChar: "•",
};
return { styles, htmlStyles };