diff --git a/org-cv-utils.el b/org-cv-utils.el index 7a972a6..e381461 100644 --- a/org-cv-utils.el +++ b/org-cv-utils.el @@ -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 diff --git a/ox-altacv.el b/ox-altacv.el index 4d890ba..959bc56 100644 --- a/ox-altacv.el +++ b/ox-altacv.el @@ -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) diff --git a/ox-hugocv.el b/ox-hugocv.el index 492c5d9..f0797f9 100644 --- a/ox-hugocv.el +++ b/ox-hugocv.el @@ -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 %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 diff --git a/ox-moderncv.el b/ox-moderncv.el index 28adf00..ffe7c0a 100644 --- a/ox-moderncv.el +++ b/ox-moderncv.el @@ -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)