Support for AwesomeCV

Added a new ox-awesomecv.el, which provides support for the AwesomeCV
LaTeX class: https://github.com/posquit0/Awesome-CV

Added the corresponding documentation in the README as well.

An example of a CV produced with this exporter can be found at
https://zzamboni.org/vita/
This commit is contained in:
Diego Zamboni 2019-12-07 20:46:35 +01:00
parent 91e5a55fe1
commit 51c7ef8ed5
3 changed files with 218 additions and 12 deletions

View file

@ -92,3 +92,86 @@ When exporting you can call the following function to get the latex file.
<object data="altacv.org.pdf" type="application/pdf" width="100%" height="500px">
<p>Alternative text - include a link <a href="altacv.org.pdf">to the PDF!</a></p>
</object>
## Using AwesomeCV {#using-awesomecv}
[AwesomeCV](https://github.com/posquit0/Awesome-CV) is another LaTeX template for producing nice-looking
CVs. AwesomeCV supports a few additional types of environment types in
`CV_ENV`, including `cvemployer`, `cvskills`, `cvhonors` and `cvschool`. Some of
these support additional property fields:
<div class="ox-hugo-table table table-striped">
<div></div>
| Field | Description |
|------------|----------------------------------------------------------------------|
| FROM | Start date of the entry |
| TO | End date of the entry |
| DATE | Shortcut to specify both `FROM` and `TO` as the same date. |
| | Both `FROM` and `TO` override `DATE`. |
| EMPLOYER | Employer or organization, can also be specified |
| | as `ORGANIZATION`, `SCHOOL`, `EVENT` or `POSITION` (different |
| | names make more sense depending on the type of environment) |
| LABEL | In `cvsubentry` environments, adds the given text to the left |
| | of the date range, can be used to add additional information |
| | to the entry. |
| RIGHT\_IMG | path to an image to include floating to the right of a `cventry`, |
| | a `cvsubentry` or `cvschool` entry. Meant to be used to show a logo. |
</div>
All the supported values of `CV_ENV` are described below.
### `cventries` {#cventries}
Enclose all the subheaders in a `cventries` environment. Subheaders can
be of type `cventry`, `cvschool`, or `cvemployer`.
### `cvhonors` {#cvhonors}
Enclose all the subheaders in a `cvhonors` environment. Subheaders must
be of type `cvhonor`
### `cventry` {#cventry}
Converts to a `\cventry` command. Supports attributes `FROM`, `TO`, `DATE`,
`EMPLOYER`, `LOCATION`, `RIGHT_IMG`.
### `cvsubentry` {#cvsubentry}
Converts to a `\cvsubentry` command. Supports attributes `FROM`, `TO`, `DATE`,
`LABEL` `RIGHT_IMG`.
### `cvemployer` {#cvemployer}
Converts to a `\cventry` with only the title line. Supports attributes
`FROM`, `TO`, `DATE` and `LOCATION`.
### `cvschool` {#cvschool}
Converts to a `\cventry`. The headline should contain the degree
obtained, shown as the main title. Supports attributes `LOCATION`,
`SCHOOL`, `FROM`, `TO`, `DATE` and `RIGHT_IMG`.
### `cvhonor` {#cvhonor}
Converts to a `\cvhonor` command (must be inside a `cvhonors`
headline). Supports attributes `LOCATION`, `EMPLOYER` (in this case `EVENT`
or `POSITION` might be more semantically accurate, and can also be
used), `FROM`, `TO`, `DATE`.
### `cvskills` {#cvskills}
Converts to a `\cvskills` environment. The headline must contain a
[description list](https://orgmode.org/manual/Plain-lists.html), which gets converted into a sequence of `\cvskill`
commands, with the term as the skill title and the description as its
contents.

View file

@ -117,7 +117,6 @@ holding export options."
;; photo
(let* ((photo (plist-get info :photo))
(photo-style (plist-get info :photostyle))
(_ (message "photo=%s photo-style=%s" photo photo-style))
(style-str (if photo-style (format "[%s]" photo-style) "")))
(when (org-string-nw-p photo) (format "\\photo%s{%s}\n" style-str photo)))
@ -194,7 +193,7 @@ holding export options."
(footer-mid (format-spec (or (plist-get info :cvfooter_middle) "") spec))
(footer-right (format-spec (or (plist-get info :cvfooter_right) "") spec)))
(when (not (string= "" (concat footer-left footer-mid footer-right)))
(format "\\makecvfooter{%s}{%s}{%s}" footer-left footer-mid footer-right)))
(format "\\makecvfooter{%s}{%s}{%s}\n" footer-left footer-mid footer-right)))
;; Document's body.
contents
@ -204,31 +203,78 @@ holding export options."
;; Document end.
"\\end{document}")))
;;;; Produce latex code for a right-float image
(defun org-awesomecv--cventry-right-img-code (file)
(if file
(format "\\begin{wrapfigure}{r}{0.15\\textwidth}
\\raggedleft\\vspace{-4.0mm}
\\includegraphics[width=0.1\\textwidth]{%s}
\\end{wrapfigure}" file) ""))
;;;; Individual cventry/cvsubentry/cvemployer/cvschool headlines
(defun org-awesomecv--format-cventry (headline contents info)
"Format HEADLINE as as cventry.
CONTENTS holds the contents of the headline. INFO is a plist used
as a communication channel."
(let* ((entrytype (org-element-property :CV_ENV headline))
(title (org-export-data (org-element-property :title headline) info))
(from-date (or (org-element-property :FROM headline) (error "No FROM property provided for cventry %s" title)))
(to-date (org-element-property :TO headline))
(employer (org-element-property :EMPLOYER headline))
(location (or (org-element-property :LOCATION headline) "")))
(date (org-element-property :DATE headline))
(from-date (or (org-element-property :FROM headline) date))
(to-date (or (org-element-property :TO headline) date))
(employer (or (org-element-property :ORGANIZATION headline)
(org-element-property :SCHOOL headline)
(org-element-property :EMPLOYER headline)
(org-element-property :EVENT headline)
(org-element-property :POSITION headline)))
(location (or (org-element-property :LOCATION headline) ""))
(right-img (org-element-property :RIGHT_IMG headline))
(label (or (org-element-property :LABEL headline) nil))
(label-str (if label (format "%s\\hfill{}" label) "")))
(cond
((string= entrytype "cvemployer")
(format "\n\\cventry{%s}{%s}{}{}{}\n%s\n"
title
(format "%s\\hfill %s" (org-cv-utils--format-time-window from-date to-date) location)
contents)
)
((string= entrytype "cventry")
(format "\n\\cventry\n{%s}\n{%s}\n{%s}\n{%s}\n{\n%s}\n"
(format "\n\\cventry\n{%s}\n{%s}\n{%s}\n{%s}\n{\n%s%s}\n"
employer
location
title
(org-cv-utils--format-time-window from-date to-date)
(org-awesomecv--cventry-right-img-code right-img)
contents))
((string= entrytype "cvsubentry")
(format "\n\\cvsubentry\n{%s}\n{%s}\n{\n%s}\n"
(format "\n\\cvsubentry\n{%s}\n{%s}\n{\n%s%s}\n"
title
(format "%s%s" label-str (org-cv-utils--format-time-window from-date to-date))
(org-awesomecv--cventry-right-img-code right-img)
contents))
((string= entrytype "cvschool")
(format "\n\\cventry\n{%s}\n{%s}\n{%s}\n{%s}\n{\n%s%s}\n"
title
location
employer
(org-cv-utils--format-time-window from-date to-date)
contents)))))
(org-awesomecv--cventry-right-img-code right-img)
contents))
((string= entrytype "cvhonor")
(format "\n\\cvhonor\n{%s}\n{%s}\n{%s}\n{%s}\n"
title
employer
location
(org-cv-utils--format-time-window from-date to-date))))))
;;;; Headlines of type "cventries"
(defun org-awesomecv--format-cvenvironment (environment headline contents info)
"Format HEADLINE as as a cventries/cvhonors environment.
CONTENTS holds the contents of the headline. INFO is a plist used
as a communication channel."
(format "%s\n\\begin{%s}\n%s\\end{%s}\n"
(org-export-with-backend 'latex headline nil info)
environment contents environment))
;;;; Headline
(defun org-awesomecv-headline (headline contents info)
@ -240,8 +286,14 @@ as a communication channel."
(or (org-string-nw-p env) "block"))))
(cond
;; is a cv entry or subentry
((or (string= environment "cventry") (string= environment "cvsubentry"))
((or (string= environment "cventry")
(string= environment "cvsubentry")
(string= environment "cvemployer")
(string= environment "cvschool")
(string= environment "cvhonor"))
(org-awesomecv--format-cventry headline contents info))
((or (string= environment "cventries") (string= environment "cvhonors"))
(org-awesomecv--format-cvenvironment environment headline contents info))
((org-export-with-backend 'latex headline contents info))))))
;;;; Plain List, to intercept and transform "cvskills" lists
@ -250,11 +302,12 @@ as a communication channel."
"Transcode a PLAIN-LIST element from Org to LaTeX.
CONTENTS is the contents of the list. INFO is a plist holding
contextual information."
(let* ((cv-env (org-entry-get (org-element-property :begin plain-list) "CV_ENV" t)))
(let* ((cv-env (org-entry-get (org-element-property :begin plain-list) "CV_ENV" nil))
(parent-type (car (org-element-property :parent plain-list))))
(cond
((string= cv-env "cvskills")
(format "\\begin{cvskills}\n%s\\end{cvskills}" contents))
((or (string= cv-env "cventry") (string= cv-env "cvsubentry"))
((and (eq parent-type 'section) (or (string= cv-env "cventry") (string= cv-env "cvsubentry") (string= cv-env "cvschool")))
(format "\\begin{cvitems}\n%s\\end{cvitems}" contents))
(t
(org-latex-plain-list plain-list contents info)))))

View file

@ -213,6 +213,76 @@ When exporting you can call the following function to get the latex file.
</object>
#+END_EXPORT
** Using AwesomeCV
[[https://github.com/posquit0/Awesome-CV][AwesomeCV]] is another LaTeX template for producing nice-looking
CVs. AwesomeCV supports a few additional types of environment types in
=CV_ENV=, including =cvemployer=, =cvskills=, =cvhonors= and =cvschool=. Some of
these support additional property fields:
#+attr_html: :class table table-striped
| Field | Description |
|-----------+------------------------------------------------------------------|
| FROM | Start date of the entry |
| TO | End date of the entry |
| DATE | Shortcut to specify both =FROM= and =TO= as the same date. |
| | Both =FROM= and =TO= override =DATE=. |
| EMPLOYER | Employer or organization, can also be specified |
| | as =ORGANIZATION=, =SCHOOL=, =EVENT= or =POSITION= (different |
| | names make more sense depending on the type of environment) |
| LABEL | In =cvsubentry= environments, adds the given text to the left |
| | of the date range, can be used to add additional information |
| | to the entry. |
| RIGHT_IMG | path to an image to include floating to the right of a =cventry=, |
| | a =cvsubentry= or =cvschool= entry. Meant to be used to show a logo. |
All the supported values of =CV_ENV= are described below.
*** =cventries=
Enclose all the subheaders in a =cventries= environment. Subheaders can
be of type =cventry=, =cvschool=, or =cvemployer=.
*** =cvhonors=
Enclose all the subheaders in a =cvhonors= environment. Subheaders must
be of type =cvhonor=
*** =cventry=
Converts to a =\cventry= command. Supports attributes =FROM=, =TO=, =DATE=,
=EMPLOYER=, =LOCATION=, =RIGHT_IMG=.
*** =cvsubentry=
Converts to a =\cvsubentry= command. Supports attributes =FROM=, =TO=, =DATE=,
=LABEL= =RIGHT_IMG=.
*** =cvemployer=
Converts to a =\cventry= with only the title line. Supports attributes
=FROM=, =TO=, =DATE= and =LOCATION=.
*** =cvschool=
Converts to a =\cventry=. The headline should contain the degree
obtained, shown as the main title. Supports attributes =LOCATION=,
=SCHOOL=, =FROM=, =TO=, =DATE= and =RIGHT_IMG=.
*** =cvhonor=
Converts to a =\cvhonor= command (must be inside a =cvhonors=
headline). Supports attributes =LOCATION=, =EMPLOYER= (in this case =EVENT=
or =POSITION= might be more semantically accurate, and can also be
used), =FROM=, =TO=, =DATE=.
*** =cvskills=
Converts to a =\cvskills= environment. The headline must contain a
[[https://orgmode.org/manual/Plain-lists.html][description list]], which gets converted into a sequence of =\cvskill=
commands, with the term as the skill title and the description as its
contents.
* Markdown Hugo Exporter
:PROPERTIES:
:EXPORT_FILE_NAME: hugo_export