From 95c90515327a09d93d12d7802ad8da47134d6ba8 Mon Sep 17 00:00:00 2001 From: Diego Zamboni Date: Sun, 8 Dec 2019 16:12:56 +0100 Subject: [PATCH] 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. --- doc/content/post/latex_export.md | 32 +++++++++++++++++--------------- ox-awesomecv.el | 12 +++++++++--- readme.org | 32 +++++++++++++++++--------------- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/doc/content/post/latex_export.md b/doc/content/post/latex_export.md index d27c14d..6236053 100644 --- a/doc/content/post/latex_export.md +++ b/doc/content/post/latex_export.md @@ -102,21 +102,23 @@ CVs. In addition to the regular document attributes, the following are supported
-| 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. |
diff --git a/ox-awesomecv.el b/ox-awesomecv.el index 9b90473..1fa9d5b 100644 --- a/ox-awesomecv.el +++ b/ox-awesomecv.el @@ -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 diff --git a/readme.org b/readme.org index acaae91..061901b 100644 --- a/readme.org +++ b/readme.org @@ -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