1
0
Fork 0

unify parsing of cventry

This commit is contained in:
Óscar Nájera 2020-06-01 19:54:47 +02:00
parent 395069b130
commit cb32990168
4 changed files with 34 additions and 29 deletions

View File

@ -54,5 +54,17 @@ in case TO-DATE is nil return Present"
(if (not to-date) "Present"
(org-cv-utils-org-timestamp-to-shortdate to-date))))
(defun org-cv-utils--parse-cventry (headline info)
"Return alist describing the entry
INFO is a plist used
as a communication channel."
(let ((title (org-export-data (org-element-property :title headline) info)))
`((title . ,title)
(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) "")))))
(provide 'org-cv-utils)
;;; org-cv-utils ends here

View File

@ -193,18 +193,14 @@ holding export options."
"Format HEADLINE as as cventry.
CONTENTS holds the contents of the headline. INFO is a plist used
as a communication channel."
(let* ((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) ""))
(let* ((entry (org-cv-utils--parse-cventry headline info))
(divider (if (org-export-last-sibling-p headline info) "\n" "\\divider")))
(format "\n\\cvevent{%s}{%s}{%s}{%s}%s\n%s"
title
employer
(org-cv-utils--format-time-window from-date to-date)
location contents divider)))
(alist-get 'title entry)
(alist-get 'employer entry)
(org-cv-utils--format-time-window (alist-get 'from-date entry)
(alist-get 'to-date entry))
(alist-get 'location entry) contents divider)))
;;;; Headline
(defun org-altacv-headline (headline contents info)

View File

@ -60,13 +60,10 @@
"Format HEADLINE as as cventry.
CONTENTS holds the contents of the headline. INFO is a plist used
as a communication channel."
(let* ((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))
(let* ((entry (org-cv-utils--parse-cventry headline info))
(loffset (string-to-number (plist-get info :hugo-level-offset))) ;"" -> 0, "0" -> 0, "1" -> 1, ..
(level (org-export-get-relative-level headline info))
(employer (org-element-property :EMPLOYER headline))
(location (or (org-element-property :LOCATION headline) "")))
(title (concat (make-string (+ loffset level) ?#) " " (alist-get 'title entry))))
(format "\n%s
<ul class=\"cventry\">
@ -76,12 +73,12 @@ as a communication channel."
</ul>
%s
"
(concat (make-string (+ loffset level) ?#) " " title)
employer
location
(org-cv-utils--format-time-window from-date to-date)
contents)))
" title
(alist-get 'employer entry)
(alist-get 'location entry)
(org-cv-utils--format-time-window (alist-get 'from-date entry) (alist-get 'to-date entry))
contents)))
;;;; Headline

View File

@ -183,16 +183,16 @@ holding export options."
"Format HEADLINE as as cventry.
CONTENTS holds the contents of the headline. INFO is a plist used
as a communication channel."
(let* ((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) ""))
(let* ((entry (org-cv-utils--parse-cventry headline info))
(note (or (org-element-property :NOTE headline) "")))
(format "\\cventry{\\textbf{%s}}{%s}{%s}{%s}{%s}{%s}\n"
(org-cv-utils--format-time-window from-date to-date)
title employer location note contents)))
(format "\\cventry{\\textbf{%s}}{%s}{%s}{%s}{%s}{%s}\n"
(org-cv-utils--format-time-window (alist-get 'from-date entry)
(alist-get 'to-date entry))
(alist-get 'title entry)
(alist-get 'employer entry)
(alist-get 'location entry)
note contents)))
;;;; Headline
(defun org-moderncv-headline (headline contents info)