Skip to content

Commit

Permalink
Sanitize illegal characters
Browse files Browse the repository at this point in the history
  • Loading branch information
drik98 committed Aug 1, 2024
1 parent 34ee6a8 commit 20a0981
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cv/generate-tex-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import categories from "@/content/skill-categories.json";
import { formatDateRangeCV } from '@/util/date-time';
import { Locale, getMessages, getMultilingualContent, supportedLocales } from '@/util/i18n';

const SLASH_SEPARATOR_CHAR = "\\char`\\/";
const sanitze = (value: string) => value.replaceAll("/", SLASH_SEPARATOR_CHAR).replaceAll("&", "\\&")

const displayedSkills = skills.filter(skill => !skill.hideOnCv);

for(const locale of supportedLocales) {
Expand All @@ -31,7 +34,7 @@ async function generateTemplate(locale: Locale) {
const groupedSkills = displayedSkills.filter(otherSkill => otherSkill.groupWith === name);
return {
...skill,
label: [name,...groupedSkills.map(groupedSkill => getMultilingualContent(groupedSkill.name,locale))].join("\\char`\\/")
label: [name,...groupedSkills.map(groupedSkill => getMultilingualContent(groupedSkill.name,locale))].join("/")
}
})
}
Expand All @@ -41,7 +44,7 @@ async function generateTemplate(locale: Locale) {

const makeCustomSkills = (skillCategory: typeof firstCategory) => {
const sortedSkills = skillCategory.skills.sort((a,b) => a.level - b.level)
return String.raw`\customskills{${skillCategory.label}}{${sortedSkills.map(skill => `${skill.label}/${skill.level}`)}}{}`;
return String.raw`\customskills{${sanitze(skillCategory.label)}}{${sortedSkills.map(skill => `${sanitze(skill.label)}/${skill.level}`)}}{}`;
}


Expand Down

1 comment on commit 20a0981

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.