-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·67 lines (55 loc) · 1.68 KB
/
build
File metadata and controls
executable file
·67 lines (55 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const MarkdownIt = require('markdown-it');
const MarkdownItEmoji = require('markdown-it-emoji');
const Twemoji = require('twemoji');
const wkhtmltopdf = require('wkhtmltopdf');
const curriculumContent = fs.readFileSync(path.join(__dirname, 'curriculum.md')).toString();
const readmeHeaderContent = fs.readFileSync(path.join(__dirname, 'readme-header.md')).toString();
function generateReadmeMd() {
fs.writeFileSync(path.join(__dirname, 'README.md'), `${readmeHeaderContent}\n${curriculumContent}`);
}
function generateCurriculumPdf() {
const twemojiOptions = {
base: `${path.dirname(require.resolve('twemoji'))}/`,
folder: 'svg',
ext: '.svg',
};
const md = new MarkdownIt({html: true});
md.use(MarkdownItEmoji);
md.renderer.rules.emoji = function (token, idx) {
return Twemoji.parse(token[idx].content, twemojiOptions);
};
const rendered = md.render(curriculumContent);
const html = `<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Currículo — Dalton Erasmo dos Santos</title>
<link href="${require.resolve('github-markdown-css/github-markdown.css')}" rel="stylesheet" type="text/css">
<style tyle="text/css">
img.emoji {
height: 1em;
width: 2em; /* Whaaaaat */
vertical-align: middle;
}
</style>
</head>
<body class="markdown-body">
${rendered}
</body>
</html>
`;
fs.writeFileSync(path.join(__dirname, 'curriculum.html'), html);
wkhtmltopdf(html, {
output: path.join(__dirname, 'curriculum.pdf'),
pageSize: 'A4',
marginTop: '15mm',
marginRight: '15mm',
marginBottom: '15mm',
marginLeft: '15mm',
});
}
generateReadmeMd();
generateCurriculumPdf();