Skip to content

Commit 77d6e98

Browse files
committed
Merge pull request #13 from ekfriis/disable-gravatar
Add option to disable gravatar in HTML output
2 parents f0966df + 92cbf6f commit 77d6e98

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pdf: clean $(PDFS)
99
html: clean $(HTML)
1010

1111
%.html: %.md
12-
python resume.py html < $< | pandoc -t html -c resume.css -o $@
12+
python resume.py html $(GRAVATAR_OPTION) < $< | pandoc -t html -c resume.css -o $@
1313

1414
%.pdf: %.md
1515
python resume.py tex < $< | pandoc --template=./pandoc-templates/default.latex -H header.tex -o $@

README.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ Markdown is passed through a Python script that looks for contact details
2323
beginning on the fourth line and moves them into a right-aligned, zero-height
2424
box at the top of the document. Lines with bullets (•) will be treated as
2525
separate contact lines in the output.
26+
27+
By default, an image of your [Gravatar](http://www.gravatar.com) will be added
28+
to the HTML resumé. This feature can be disabled by setting the environment
29+
variable `GRAVATAR_OPTION=--no-gravatar`.

resume.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def sub(pattern, repl, string, **kwargs):
8181
([^{}\n\r]*)
8282
""" % pattern
8383

84-
repl = re.sub(r"\\(\d)", lambda m: r"\%d" % (int(m.group(1)) + 2), repl)
84+
repl = re.sub(r"\\(\d)",
85+
lambda m: r"\%d" % (int(m.group(1)) + 2), repl)
8586

8687
return re.sub(pattern, r"\1\2%s\%d" % (repl, num_groups + 3), string,
8788
flags=flags, **kwargs)
@@ -128,15 +129,15 @@ def html(lines, contact_lines, *args):
128129

129130
gravatar = None
130131
for line in contact_lines:
131-
if line.find("@") > 0:
132+
if '@' in line and '--no-gravatar' not in args:
132133
gravatar = GRAVATAR.format(
133134
hash=hashlib.md5(line.lower().strip('<>')).hexdigest())
134135
break
135136
if gravatar is not None:
136137
contact_lines.insert(0, "<img src='{}' />".format(gravatar))
137138

138139
lines.insert(0, "<div id='container'><div id='contact'>%s</div>\n" %
139-
("<p>" + "</p><p>".join(contact_lines) + "</p>"))
140+
("<p>" + "</p><p>".join(contact_lines) + "</p>"))
140141
lines.insert(1, "<div>")
141142
lines.append("</div>")
142143

@@ -149,6 +150,11 @@ def main():
149150
except IndexError:
150151
raise Exception("No format specified")
151152

153+
if '-h' in sys.argv or '--help' in sys.argv:
154+
sys.stderr.write(
155+
"Usage: python resume.py tex|html [--no-gravatar] < INPUT.md\n")
156+
raise SystemExit
157+
152158
lines = sys.stdin.readlines()
153159

154160
contact_lines = []

0 commit comments

Comments
 (0)