From a94bf0e5ad8a6c7c8c3940c3ea79dd00f0ccc352 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Sun, 22 Oct 2023 04:01:41 +0200 Subject: [PATCH] fix hugo export string replace and build fix hugo hugo fix collective environments --- doc/content/post/hugo_export.md | 6 +++++- genfiles.el | 23 +++++++++++++---------- ox-hugocv.el | 10 +++++++--- readme.org | 9 ++++++++- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/doc/content/post/hugo_export.md b/doc/content/post/hugo_export.md index 7a7bbe9..a0d1844 100644 --- a/doc/content/post/hugo_export.md +++ b/doc/content/post/hugo_export.md @@ -16,4 +16,8 @@ exclude some tags during export. (org-export-to-file 'hugocv "hugocv.md")) ``` -You are responsible for styling your website. +You are responsible for styling your website. Use all the CSS magic you know. +Each entry is inside a `div` container and each element of the properties has +its own class. + +\#+end_src diff --git a/genfiles.el b/genfiles.el index d3970c2..4b59a25 100644 --- a/genfiles.el +++ b/genfiles.el @@ -19,20 +19,24 @@ (require 'ox-awesomecv) (require 'ox-awesomecv2)) -(defun export-latex (backend file) +(defun export-with (backend file ext) (let ((workfile (concat cv-workdir file)) - (outfile (concat cv-workdir file ".tex")) - (pdffile (concat cv-workdir file ".pdf"))) + (outfile (concat cv-workdir file ext))) (message (format "%s exists: %s" workfile (file-exists-p workfile))) (with-current-buffer (find-file-noselect workfile) (org-mode) (message "back %S, out %S" backend outfile) - (org-export-to-file backend outfile) - (message (format "%s exists: %s" outfile (file-exists-p outfile))) - (shell-command (format "xelatex --output-directory=%s %s" cv-workdir outfile) "*Messages*" "*Messages*") - (message (format "%s exists: %s" pdffile (file-exists-p pdffile))) - (copy-file pdffile (concat cv-cwd "/doc/static/" (concat file ".pdf")) t)))) + (org-export-to-file backend outfile)) + outfile)) + +(defun export-latex (backend file) + (let ((outfile (export-with backend file ".tex")) + (pdffile (concat cv-workdir file ".pdf"))) + (message (format "%s exists: %s" outfile (file-exists-p outfile))) + (shell-command (format "xelatex --output-directory=%s %s" cv-workdir outfile) "*Messages*" "*Messages*") + (message (format "%s exists: %s" pdffile (file-exists-p pdffile))) + (copy-file pdffile (concat cv-cwd "/doc/static/" (concat file ".pdf")) t))) (let ((readme (concat cv-cwd "readme.org"))) (make-directory cv-workdir t) @@ -43,10 +47,9 @@ (copy-file (concat cv-cwd "doc/smile.png") cv-workdir t) (make-directory (concat cv-cwd "/doc/static/") t) -(message "alta %s" (featurep 'ox-altacv)) (export-latex 'altacv "altacv.org") (export-latex 'moderncv "moderncv.org") (export-latex 'awesomecv2 "awesomecv.org") (export-latex 'awesomecv "awesomecv.org") (export-latex 'awesomecv "awesome-letter.org") -(export-latex 'hugocv "hugocv.org") +(export-with 'hugocv "hugocv.org" ".md") diff --git a/ox-hugocv.el b/ox-hugocv.el index ed7b36c..08b3eb3 100644 --- a/ox-hugocv.el +++ b/ox-hugocv.el @@ -59,10 +59,11 @@ (cl-ecase field (host (-some->> (alist-get 'host entry) + (org-string-nw-p) (format "%s\n{.cv-host}"))) (date (-some->> - (org-cv-utils--format-time-window (alist-get 'from-date entry) (alist-get 'to-date entry)) + (alist-get 'date entry) (format "%s\n{.cv-date}"))) (location (-some->> (alist-get 'location entry) @@ -74,7 +75,7 @@ CONTENTS holds the contents of the headline. INFO is a plist used as a communication channel." (let* ((environment (org-export-get-tags headline info)) - (env-class (string-replace "cv" "" (cl-find-if (lambda (s) (string-prefix-p "cv" s)) environment))) + (env-class (replace-regexp-in-string "^cv" "" (cl-find-if (lambda (s) (string-prefix-p "cv" s)) environment))) (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)) @@ -98,7 +99,10 @@ as a communication channel." (let ((environment (cons (org-element-property :CV_ENV headline) (org-export-get-tags headline info)))) (cond - ((cl-find-if (lambda (s) (string-prefix-p "cv" s)) environment) + ((cl-find-if (lambda (s) (and (string-prefix-p "cv" s) + ;; avoid conflict with awesomecv block environments + (not (member s '("cventries" "cvhonors"))))) + environment) (org-hugocv--format-cventry headline contents info)) ((org-export-with-backend 'hugo headline contents info)))))) diff --git a/readme.org b/readme.org index 4bd2cea..af9e7c2 100644 --- a/readme.org +++ b/readme.org @@ -453,7 +453,14 @@ exclude some tags during export. (org-export-to-file 'hugocv "hugocv.md")) #+END_SRC -You are responsible for styling your website. +You are responsible for styling your website. Use all the CSS magic you know. +Each entry is inside a =div= container and each element of the properties has +its own class. + +#+begin_src org :exports none :tangle hugocv.org +,#+HTML_HEAD: +#+end_src + # Next block is to generate exports #+BEGIN_SRC org :exports none :tangle hugocv.org #+include: basic_cv.org