Improve first/last name handling.

By default first/last name are now extracted from the value of #+AUTHOR,
but #+FIRSTNAME and #+LASTNAME can be used to override the values
if needed.
This commit is contained in:
Diego Zamboni 2019-12-08 16:12:56 +01:00
parent 2a322a9b12
commit 95c9051532
3 changed files with 43 additions and 33 deletions

View file

@ -102,21 +102,23 @@ CVs. In addition to the regular document attributes, the following are supported
<div class="ox-hugo-table table table-striped">
<div></div>
| Field | Description |
|------------------|------------------------------------------------------------|
| PHOTOSTYLE | Style of photo to use. Values include |
| | circle/rectangle,edge/noedge,left/right |
| CVCOLOR | Color of highlights. |
| STACKOVERFLOW | Stack overflow, must be specified as `ID username` |
| FONTDIR | Directory where the fonts can be found, defaults |
| | to `fonts/` (as in the standard AwesomeCV) |
| CVHIGHLIGHTS | Whether to colorize highlights. Defaults to true |
| QUOTE | Optional quote to include at the top of the CV |
| FIRSTNAME | Your first name. Must be specified (in addition to AUTHOR) |
| LASTNAME | Your last name. Must be specified. |
| CVFOOTER\_LEFT | Text to include in the left footer. |
| CVFOOTER\_MIDDLE | Text to include in the middle footer. |
| CVFOOTER\_RIGHT | Text to include in the right footer. |
| Field | Description |
|------------------|-----------------------------------------------------------|
| PHOTOSTYLE | Style of photo to use. Comma-separated values can include |
| | circle/rectangle,edge/noedge,left/right. |
| CVCOLOR | Color of highlights. |
| STACKOVERFLOW | Stack overflow, must be specified as `ID username` |
| FONTDIR | Directory where the fonts can be found, defaults |
| | to `fonts/` (as in the standard AwesomeCV) |
| CVHIGHLIGHTS | Whether to colorize highlights. Defaults to true |
| QUOTE | Optional quote to include at the top of the CV |
| FIRSTNAME | First name to be shown in the CV. By default the first |
| | space-separated part of AUTHOR is used. |
| LASTNAME | Last name to be shown in the CV. By default the second |
| | space-separated part of AUTHOR is used. |
| CVFOOTER\_LEFT | Text to include in the left footer. None by default |
| CVFOOTER\_MIDDLE | Text to include in the middle footer. None by default. |
| CVFOOTER\_RIGHT | Text to include in the right footer. None by default. |
</div>

View file

@ -31,6 +31,7 @@
(require 'cl-lib)
(require 'ox-latex)
(require 'org-cv-utils)
(require 'subr)
;; Install a default set-up for awesomecv export.
(unless (assoc "awesomecv" org-latex-classes)
@ -70,6 +71,7 @@
(:linkedin "LINKEDIN" nil nil parse)
(:twitter "TWITTER" nil nil parse)
(:stackoverflow "STACKOVERFLOW" nil nil split)
(:extrainfo "EXTRAINFO" nil nil parse)
(:with-email nil "email" t t)
(:fontdir "FONTDIR" nil "fonts/" t)
(:latex-title-command nil nil "\\makecvheader" t)
@ -120,9 +122,13 @@ holding export options."
(style-str (if photo-style (format "[%s]" photo-style) "")))
(when (org-string-nw-p photo) (format "\\photo%s{%s}\n" style-str photo)))
;; Author.
(let ((first-name (org-export-data (plist-get info :firstname) info))
(last-name (org-export-data (plist-get info :lastname) info)))
;; Author. If FIRSTNAME or LASTNAME are not given, try to deduct
;; their values by splitting AUTHOR on white space.
(let* ((author (split-string (org-export-data (plist-get info :author) info)))
(first-name-prop (org-export-data (plist-get info :firstname) info))
(last-name-prop (org-export-data (plist-get info :lastname) info))
(first-name (or (org-string-nw-p first-name-prop) (first author)))
(last-name (or (org-string-nw-p last-name-prop) (second author))))
(format "\\name{%s}{%s}\n" first-name last-name))
;; Title

View file

@ -219,21 +219,23 @@ When exporting you can call the following function to get the latex file.
CVs. In addition to the regular document attributes, the following are supported:
#+attr_html: :class table table-striped
| Field | Description |
|-----------------+------------------------------------------------------------|
| PHOTOSTYLE | Style of photo to use. Values include |
| | circle/rectangle,edge/noedge,left/right |
| CVCOLOR | Color of highlights. |
| STACKOVERFLOW | Stack overflow, must be specified as =ID username= |
| FONTDIR | Directory where the fonts can be found, defaults |
| | to =fonts/= (as in the standard AwesomeCV) |
| CVHIGHLIGHTS | Whether to colorize highlights. Defaults to true |
| QUOTE | Optional quote to include at the top of the CV |
| FIRSTNAME | Your first name. Must be specified (in addition to AUTHOR) |
| LASTNAME | Your last name. Must be specified. |
| CVFOOTER_LEFT | Text to include in the left footer. |
| CVFOOTER_MIDDLE | Text to include in the middle footer. |
| CVFOOTER_RIGHT | Text to include in the right footer. |
| Field | Description |
|-----------------+-----------------------------------------------------------|
| PHOTOSTYLE | Style of photo to use. Comma-separated values can include |
| | circle/rectangle,edge/noedge,left/right. |
| CVCOLOR | Color of highlights. |
| STACKOVERFLOW | Stack overflow, must be specified as =ID username= |
| FONTDIR | Directory where the fonts can be found, defaults |
| | to =fonts/= (as in the standard AwesomeCV) |
| CVHIGHLIGHTS | Whether to colorize highlights. Defaults to true |
| QUOTE | Optional quote to include at the top of the CV |
| FIRSTNAME | First name to be shown in the CV. By default the first |
| | space-separated part of AUTHOR is used. |
| LASTNAME | Last name to be shown in the CV. By default the second |
| | space-separated part of AUTHOR is used. |
| CVFOOTER_LEFT | Text to include in the left footer. None by default |
| CVFOOTER_MIDDLE | Text to include in the middle footer. None by default. |
| CVFOOTER_RIGHT | Text to include in the right footer. None by default. |
AwesomeCV supports a few additional types of environment types in
=CV_ENV=, including =cvemployer=, =cvskills=, =cvhonors= and =cvschool=. Some of