Skip to content

Commit

Permalink
Use chrome instead of weasyprint
Browse files Browse the repository at this point in the history
This major update changes how PDFs are built. Instead of requiring
weasyprint we use Google Chrome (or Chromium). Weasyprint turns out to
be non-trivial to install (especially on Windows and Apple Silicon).

This change is made by adding functionality to launch Chrome in headless
mode to resume.py. This requires lots of special cases and options to
get things to work on all the platforms I've tested.

resume.py is now a "real" command line program with --no-html,
--no-pdf, --quiet and --chrome-path options.

The script uses Chromium if it is available, falling back to the evil version if
Chromium is not found. It searches likely paths for the Chromium/Chrome
executable, but you can specify the path with the --chrome-path option.

This commit also adds a GitHub action to build HTML and PDF on Linux,
Windows and macOS. Inspection of the build artifacts is useful for
testing. It is related to mikepqr#1, but is probably not ready for use by
regular users.

Closes mikepqr#4, mikepqr#6, mikepqr#8
  • Loading branch information
mikepqr committed Mar 16, 2021
1 parent e33fe04 commit 206a6cb
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 71 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: build

on:
workflow_dispatch:
pull_request:
push:
branches:
main

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Install markdown
run: pip3 install markdown
- name: Make resume
run: python3 resume.py
- name: Rename output
if: ${{ matrix.os != 'windows-latest' }}
run: |
mv resume.pdf resume_$RUNNER_OS.pdf
mv resume.html resume_$RUNNER_OS.html
- name: Rename output (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
mv resume.pdf resume_windows.pdf
mv resume.html resume_windows.html
- name: Archive resume.html and resume.pdf
uses: actions/upload-artifact@v2
with:
path: |
*.pdf
*.html
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

53 changes: 16 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,34 @@

![Resume](resume.png)


Write your resume in
[Markdown](https://raw.githubusercontent.com/mikepqr/resume.md/main/resume.md),
style it with [CSS](resume.css), output to [HTML](resume.html) and
[PDF](resume.pdf).

## Prerequisites

- Python ≥ 3.6
- [python-markdown](https://python-markdown.github.io/) (`pip install
markdown`)
- Optional, required for PDF output: Google Chrome or Chromium

## Instructions
## Usage

1. Get a copy of this repository by [using the
1. Download [resume.py](resume.py), [resume.md](resume.md) and
[resume.css](resume.css) (or make a copy of this repository by [using the
template](https://github.com/mikepqr/resume.md/generate), forking, or
cloning
cloning).

2. Install the dependencies:
<pre>
pip install <a href="https://python-markdown.github.io/">markdown</a> <a href="https://weasyprint.org/">weasyprint</a>
</pre>
Note weasyprint has additional non-python dependencies (cairo, Pango and
GDK-PixBuf). See the [weasyprint documentation for
details](https://weasyprint.readthedocs.io/en/latest/install.html).
2. Edit [resume.md](resume.md) (the placeholder text is taken with thanks from
the [JSON Resume Project](https://jsonresume.org/themes/))

3. Edit [resume.md](resume.md) (the placeholder text is taken with thanks from the
[JSON Resume Project](https://jsonresume.org/themes/))
3. Run `python3 resume.py` to build resume.html and resume.pdf.

4. Run `make resume` to build resume.html and resume.pdf. If `make` is not
available (e.g. Windows) run `python resume.py` then `weasyprint resume.html
resume.pdf` instead.
- Use `--no-html` or `--no-pdf` to disable HTML or PDF output.

Optionally, run `make watch` while you are working on your resume to rebuild it
whenever resume.md or resume.css change (requires
[entr](http://eradman.com/entrproject/)).
- Use `--chrome-path=/path/to/chrome` if resume.py cannot find your Chrome
or Chromium executable.

## Customization

Expand All @@ -55,21 +52,3 @@ here](https://github.com/mikepqr/resume.md/blob/5d99e02bf65ff6a2a0ccd18c1a0255c2
<code><a
href="https://python-markdown.github.io/extensions/attr_list/">attr_list</a></code>
in particular may by useful if you are editing the CSS.

## Tips

The simplest way to maintain multiple versions of your resume is to comment bits
of text in or out based on the audience. This can be done with standard HTML
comment syntax (e.g. `<!-- Skills: Microsoft Word -->`) but beware that
commented out text will be included in the HTML source that you are presumably
going to put online or share.

An alternative is to keep snippets of Markdown (or CSS) in separate files, and
collect them into a single file for each version of your resume using a
templating tool, makefile or shell script.

Use, e.g. `git tag` to record which version of the resume you sent to which
person.

Use `git diff --word-diff` to make `git diff` more legible (this applies any
time you run git diff on natural language).
118 changes: 114 additions & 4 deletions resume.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,120 @@

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Richard Hendricks</title>
<link rel="stylesheet" type="text/css" href="resume.css">
<style>
body {
color: #000000;
background: #EEEEEE;
font: 1.1em "Times New Roman";
line-height: 1.2;
margin: 40px 0;
}
#resume {
margin: 0 auto;
max-width: 800px;
padding: 40px 60px;
background: #FFFFFF;
border: 1px solid #CCCCCC;
box-shadow: 2px 2px 4px #AAAAAA;
-webkit-box-shadow: 2px 2px 4px #AAAAAA;
}
h1 {
text-transform: uppercase;
text-align: center;
font-size: 200%;
margin: 0;
padding: 0;
}
h2 {
border-bottom: 1px solid #000000;
text-transform: uppercase;
font-size: 130%;
margin: 1em 0 0 0;
padding: 0;
}
h3 {
font-size: 100%;
margin: 0.8em 0 0.3em 0;
padding: 0;
display: flex;
justify-content: space-between;
}
p {
margin: 0 0 0.5em 0;
padding: 0;
}
ul {
padding: 0;
margin: 0 1.5em;
}
/* ul immediately after h1 = contact list */
h1 + ul {
text-align: center;
margin: 0;
padding: 0;
}
h1 + ul > li {
display: inline;
white-space: pre;
list-style-type: none;
}
h1 + ul > li:after {
content: " \2022 ";
}
h1 + ul > li:last-child:after {
content: "";
}
/* p immediately after contact list = summary */
h1 + ul + p {
margin: 1em 0;
}
@media print {
body {
font-size: 10pt;
margin: 0;
padding: 0;
background: none;
}
#resume {
margin: 0;
padding: 0;
border: 0px;
background: none;
box-shadow: none;
-webkit-box-shadow: none;
}
/* Make links black in PDF */
/* Move this outside the print block to apply this in HTML too */
a, a:link, a:visited, a:hover {
color: #000000;
text-decoration: underline;
}
}
@page {
/* Change margins and paper size of PDF */
/* https://developer.mozilla.org/en-US/docs/Web/CSS/@page */
size: letter;
margin: 0.5in 0.8in;
}
@media screen and (max-width: 800px) {
body {
font-size: 16pt;
margin: 0;
padding: 0;
background: #FFFFFF !important;
}
#resume {
margin: 0;
padding: 1em;
border: 0px;
background: none;
box-shadow: none;
-webkit-box-shadow: none;
}
}

</style>
</head>
<body>
<div id="resume">
Expand Down Expand Up @@ -60,7 +171,6 @@ <h2>Skills</h2>
<ul>
<li>Web development: HTML, CSS, JavaScript</li>
<li>Compression: Mpeg, MP4, GIF</li>
</ul>
</div>
</ul></div>
</body>
</html>
Binary file modified resume.pdf
Binary file not shown.
Loading

0 comments on commit 206a6cb

Please sign in to comment.