hugo export using only class styles for properties

employer, date, location are now classes not html5 i tags with set
font-awesome
This commit is contained in:
Oscar Najera 2023-10-21 14:58:55 +02:00
parent 5109cbf0c8
commit e934bcf91d
2 changed files with 15 additions and 25 deletions

View file

@ -28,6 +28,7 @@
;;; Code: ;;; Code:
(require 'org) (require 'org)
(require 'ox)
(require 'org-element) (require 'org-element)
(defun org-cv-utils-org-timestamp-to-shortdate (date_str) (defun org-cv-utils-org-timestamp-to-shortdate (date_str)

View file

@ -35,7 +35,7 @@
;;; User-Configurable Variables ;;; User-Configurable Variables
(defgroup org-export-hugocv nil (defgroup org-export-hugocv nil
"Options for exporting Org mode files to Hugo-compatible Markdown" "Options for exporting Org mode files to Hugo-compatible Markdown."
:tag "Org Export Hugo CV" :tag "Org Export Hugo CV"
:group 'org-export :group 'org-export
:version "25.3") :version "25.3")
@ -43,8 +43,7 @@
;;; Define Back-End ;;; Define Back-End
(org-export-define-derived-backend 'hugocv 'hugo (org-export-define-derived-backend 'hugocv 'hugo
:options-alist :options-alist
'( '((:mobile "MOBILE" nil nil parse)
(:mobile "MOBILE" nil nil parse)
(:homepage "HOMEPAGE" nil nil parse) (:homepage "HOMEPAGE" nil nil parse)
(:address "ADDRESS" nil nil newline) (:address "ADDRESS" nil nil newline)
(:photo "PHOTO" nil nil parse) (:photo "PHOTO" nil nil parse)
@ -60,15 +59,15 @@
(cl-ecase field (cl-ecase field
(employer (employer
(-some->> (alist-get 'employer entry) (-some->> (alist-get 'employer entry)
(format "<i class=\"fa fa-building\"></i>%s<br/>"))) (format "%s\n{.cv-host}")))
(date (date
(-some->> (-some->>
(org-cv-utils--format-time-window (alist-get 'from-date entry) (alist-get 'to-date entry)) (org-cv-utils--format-time-window (alist-get 'from-date entry) (alist-get 'to-date entry))
(format "<i class=\"fa fa-calendar\"></i>%s"))) (format "%s\n{.cv-date}")))
(location (location
(-some->> (alist-get 'location entry) (-some->> (alist-get 'location entry)
(org-string-nw-p) (org-string-nw-p)
(format "<i class=\"fa fa-map-marker\"></i>%s"))))) (format "%s\n{.cv-location}")))))
(defun org-hugocv--format-cventry (headline contents info) (defun org-hugocv--format-cventry (headline contents info)
"Format HEADLINE as as cventry. "Format HEADLINE as as cventry.
@ -78,34 +77,24 @@ as a communication channel."
(loffset (string-to-number (plist-get info :hugo-level-offset))) ;"" -> 0, "0" -> 0, "1" -> 1, .. (loffset (string-to-number (plist-get info :hugo-level-offset))) ;"" -> 0, "0" -> 0, "1" -> 1, ..
(level (org-export-get-relative-level headline info)) (level (org-export-get-relative-level headline info))
(title (concat (make-string (+ loffset level) ?#) " " (alist-get 'title entry)))) (title (concat (make-string (+ loffset level) ?#) " " (alist-get 'title entry))))
(format "<div class=\"cv-entry\"> (format "<div class=\"cv-entry\">\n\n%s\n\n%s\n\n%s\n</div>"
\n%s (concat title " {.cv-role}")
%s
%s
</div>" title
(mapconcat (lambda (field) (org-hugocv--entry-with-icon field entry)) (mapconcat (lambda (field) (org-hugocv--entry-with-icon field entry))
'(employer date location) '(employer date location)
"\n") "\n")
contents))) contents)))
;;;; Headline ;;;; Headline
(defun org-hugocv-headline (headline contents info) (defun org-hugocv-headline (headline contents info)
"Transcode HEADLINE element into hugocv code. "Transcode HEADLINE element into hugocv code.
CONTENTS is the contents of the headline. INFO is a plist used CONTENTS is the contents of the headline. INFO is a plist used
as a communication channel." as a communication channel."
(unless (org-element-property :footnote-section-p headline) (unless (org-element-property :footnote-section-p headline)
(let ((environment (let ((env (org-element-property :CV_ENV headline))) (let ((environment (org-export-get-tags headline info)))
(or (org-string-nw-p env) "block"))))
(cond (cond
;; is a cv entry ((seq-intersection environment '("cventry"))
((equal environment "cventry")
(org-hugocv--format-cventry headline contents info)) (org-hugocv--format-cventry headline contents info))
((org-export-with-backend 'hugo headline contents info)))))) ((org-export-with-backend 'hugo headline contents info))))))
(provide 'ox-hugocv) (provide 'ox-hugocv)
;;; ox-hugocv ends here ;;; ox-hugocv.el ends here