update resume & portfolio
This commit is contained in:
+41
-2
@@ -13,7 +13,7 @@ if (!inputArg) {
|
||||
const inputPath = resolve(inputArg);
|
||||
const outputPath = resolve(process.argv[3] ?? `dist/${basename(inputPath, extname(inputPath))}.pdf`);
|
||||
const htmlPath = outputPath.replace(/\.pdf$/i, ".html");
|
||||
const cssPath = resolve("resume.css");
|
||||
const cssPath = resolve(process.env.PDF_CSS ?? "resume.css");
|
||||
const markdown = readFileSync(inputPath, "utf8");
|
||||
const css = readFileSync(cssPath, "utf8");
|
||||
|
||||
@@ -67,7 +67,16 @@ async function printPdfWithChrome(sourceHtmlPath, targetPdfPath) {
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
chromeProcess.kill("SIGTERM");
|
||||
rmSync(userDataDir, { recursive: true, force: true });
|
||||
if (chromeProcess.exitCode === null) {
|
||||
await new Promise((resolveExit) => chromeProcess.once("exit", resolveExit));
|
||||
}
|
||||
try {
|
||||
rmSync(userDataDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
|
||||
} catch (error) {
|
||||
if (error?.code !== "ENOTEMPTY" && error?.code !== "EBUSY") {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (process.exitCode) {
|
||||
@@ -222,6 +231,23 @@ function renderMarkdown(source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^\`\`\`/.test(line.trim())) {
|
||||
const fence = line.trim();
|
||||
const language = fence.slice(3).trim();
|
||||
const codeLines = [];
|
||||
index += 1;
|
||||
while (index < lines.length && !/^\`\`\`/.test(lines[index].trim())) {
|
||||
codeLines.push(lines[index]);
|
||||
index += 1;
|
||||
}
|
||||
if (index < lines.length) {
|
||||
index += 1;
|
||||
}
|
||||
const languageClass = language ? ` class="language-${escapeHtml(language)}"` : "";
|
||||
blocks.push(`<pre><code${languageClass}>${escapeHtml(codeLines.join("\n"))}</code></pre>`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isTableStart(lines, index)) {
|
||||
const rows = [];
|
||||
rows.push(parseTableRow(lines[index]));
|
||||
@@ -254,14 +280,26 @@ function renderMarkdown(source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (/^\d+\.\s+/.test(line)) {
|
||||
const items = [];
|
||||
while (index < lines.length && /^\d+\.\s+/.test(lines[index])) {
|
||||
items.push(lines[index].replace(/^\d+\.\s+/, ""));
|
||||
index += 1;
|
||||
}
|
||||
blocks.push(`<ol>${items.map((item) => `<li>${inline(item)}</li>`).join("")}</ol>`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const paragraph = [];
|
||||
while (
|
||||
index < lines.length &&
|
||||
lines[index].trim() &&
|
||||
!/^(#{1,3})\s+/.test(lines[index]) &&
|
||||
!/^---+$/.test(lines[index].trim()) &&
|
||||
!/^\`\`\`/.test(lines[index].trim()) &&
|
||||
!lines[index].startsWith(">") &&
|
||||
!/^- /.test(lines[index]) &&
|
||||
!/^\d+\.\s+/.test(lines[index]) &&
|
||||
!isTableStart(lines, index)
|
||||
) {
|
||||
paragraph.push(lines[index].trim());
|
||||
@@ -286,6 +324,7 @@ function groupProjectSections(blocks) {
|
||||
const section = [];
|
||||
while (
|
||||
index < blocks.length &&
|
||||
!blocks[index].startsWith("<h1>") &&
|
||||
!blocks[index].startsWith("<h2>") &&
|
||||
(section.length === 0 || !blocks[index].startsWith("<h3>"))
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user