Contact details can be empty strings, skip those

This commit is contained in:
Óscar Nájera 2019-02-02 17:47:47 +01:00
parent 19213346a8
commit 3900071b8d
3 changed files with 36 additions and 25 deletions

View file

@ -139,19 +139,23 @@ holding export options."
"\\personalinfo{\n" "\\personalinfo{\n"
;; address ;; address
(let ((address (org-export-data (plist-get info :address) info))) (let ((address (org-export-data (plist-get info :address) info)))
(when (org-string-nw-p address) (format "\\mailaddress{%s}\n" (when (org-string-nw-p address)
(mapconcat (lambda (line) (format "%s" line)) (format "\\mailaddress{%s}\n" (mapconcat (lambda (line)
(split-string address "\n") " -- ")))) (format "%s" line))
(split-string address "\n") " -- "))))
;; email ;; email
(let ((email (and (plist-get info :with-email) (let ((email (and (plist-get info :with-email)
(org-export-data (plist-get info :email) info)))) (org-export-data (plist-get info :email) info))))
(when email (format "\\email{%s}\n" email))) (when (org-string-nw-p email)
(format "\\email{%s}\n" email)))
;; phone ;; phone
(let ((mobile (org-export-data (plist-get info :mobile) info))) (let ((mobile (org-export-data (plist-get info :mobile) info)))
(when mobile (format "\\phone{%s}\n" mobile))) (when (org-string-nw-p mobile)
(format "\\phone{%s}\n" mobile)))
;; homepage ;; homepage
(let ((homepage (org-export-data (plist-get info :homepage) info))) (let ((homepage (org-export-data (plist-get info :homepage) info)))
(when homepage (format "\\homepage{%s}\n" homepage))) (when (org-string-nw-p homepage)
(format "\\homepage{%s}\n" homepage)))
(mapconcat (lambda (social-network) (mapconcat (lambda (social-network)
(let ((command (org-export-data (plist-get info (let ((command (org-export-data (plist-get info
(car social-network)) (car social-network))

View file

@ -118,23 +118,25 @@ holding export options."
;; email ;; email
(let ((email (and (plist-get info :with-email) (let ((email (and (plist-get info :with-email)
(org-export-data (plist-get info :email) info)))) (org-export-data (plist-get info :email) info))))
(when email (format "<li class=\"fa fa-envelope\"><a href=\"mailto:%s\"> %s</a></li>\n" email email))) (when (org-string-nw-p email)
(format "<li class=\"fa fa-envelope\"><a href=\"mailto:%s\"> %s</a></li>\n" email email)))
;; homepage ;; homepage
(let ((homepage (org-export-data (plist-get info :homepage) info))) (let ((homepage (org-export-data (plist-get info :homepage) info)))
(when homepage (format "<li class=\"fa fa-globe\"><a href=\"https://%s\"> %s</a></li>\n" homepage homepage))) (when (org-string-nw-p homepage) (format "<li class=\"fa fa-globe\"><a href=\"https://%s\"> %s</a></li>\n" homepage homepage)))
;; social media ;; social media
(mapconcat (lambda (social-network) (mapconcat (lambda (social-network)
(let ((command (org-export-data (plist-get info (let ((network (org-export-data
(car social-network)) (plist-get info (car social-network))
info))) info)))
(and command (format "<li class=\"fa fa-%s\"><a href=\"https://%s/%s\"> %s</a></li>\n" (when (org-string-nw-p network)
(format "<li class=\"fa fa-%s\"><a href=\"https://%s/%s\"> %s</a></li>\n"
(nth 1 social-network) (nth 1 social-network)
(nth 2 social-network) (nth 2 social-network)
command network
command)))) network))))
'((:github "github" "www.github.com") '((:github "github" "www.github.com")
(:gitlab "gitlab" "www.gitlab.com") (:gitlab "gitlab" "www.gitlab.com")

View file

@ -104,28 +104,33 @@ holding export options."
(format "\\name{%s}{}\n" author)) (format "\\name{%s}{}\n" author))
;; photo ;; photo
(let ((photo (org-export-data (plist-get info :photo) info))) (let ((photo (org-export-data (plist-get info :photo) info)))
(when (org-string-nw-p photo) (format "\\photo{%s}\n" photo))) (when (org-string-nw-p photo)
(format "\\photo{%s}\n" photo)))
;; email ;; email
(let ((email (and (plist-get info :with-email) (let ((email (and (plist-get info :with-email)
(org-export-data (plist-get info :email) info)))) (org-export-data (plist-get info :email) info))))
(when email (format "\\email{%s}\n" email))) (when (org-string-nw-p email)
(format "\\email{%s}\n" email)))
;; phone ;; phone
(let ((mobile (org-export-data (plist-get info :mobile) info))) (let ((mobile (org-export-data (plist-get info :mobile) info)))
(when mobile (format "\\phone[mobile]{%s}\n" mobile))) (when (org-string-nw-p mobile)
(format "\\phone[mobile]{%s}\n" mobile)))
;; homepage ;; homepage
(let ((homepage (org-export-data (plist-get info :homepage) info))) (let ((homepage (org-export-data (plist-get info :homepage) info)))
(when homepage (format "\\homepage{%s}\n" homepage))) (when (org-string-nw-p homepage)
(format "\\homepage{%s}\n" homepage)))
;; address ;; address
(let ((address (org-export-data (plist-get info :address) info))) (let ((address (org-export-data (plist-get info :address) info)))
(when address (format "\\address%s\n" (mapconcat (lambda (line) (format "{%s}" line)) (when (org-string-nw-p address)
(split-string address "\n") "")))) (format "\\address%s\n" (mapconcat (lambda (line)
(format "{%s}" line))
(split-string address "\n") ""))))
(mapconcat (lambda (social-network) (mapconcat (lambda (social-network)
(let ((command (org-export-data (plist-get info (let ((network (org-export-data
(car social-network)) (plist-get info (car social-network)) info)))
info))) (when (org-string-nw-p network)
(and command (format "\\social[%s]{%s}\n" (format "\\social[%s]{%s}\n"
(nth 1 social-network) (nth 1 social-network) network))))
command))))
'((:github "github") '((:github "github")
(:gitlab "gitlab") (:gitlab "gitlab")
(:linkedin "linkedin")) (:linkedin "linkedin"))