aboutsummaryrefslogtreecommitdiff
path: root/ennu.el
diff options
context:
space:
mode:
Diffstat (limited to 'ennu.el')
-rw-r--r--ennu.el27
1 files changed, 19 insertions, 8 deletions
diff --git a/ennu.el b/ennu.el
index be81523..f8bab98 100644
--- a/ennu.el
+++ b/ennu.el
@@ -14,7 +14,7 @@
(cl-defstruct (ennu-post (:constructor ennu-make-post)
(:copier nil))
- filename slug author date language links
+ filename slug author date language links tangle
summary tags thumbnail title translation-group)
(cl-defstruct (ennu-operation (:constructor ennu-make-operation)
@@ -46,13 +46,14 @@
(unless (plist-member metadata key)
(user-error "Metadata %s not specified" key)))
ennu-mandatory-metadata)
- (let ((links (org-element-map (org-element-parse-buffer) 'link
- (lambda (link)
- (pcase link
- (`(link ,properties . ,_)
- (let ((link-type (org-element-property :type link)))
- (when (member link-type (list "image" "static" "video"))
- (cons link-type (org-element-property :path link))))))))))
+ (let* ((tree (org-element-parse-buffer))
+ (links (org-element-map tree 'link
+ (lambda (link)
+ (pcase link
+ (`(link ,properties . ,_)
+ (let ((link-type (org-element-property :type link)))
+ (when (member link-type (list "image" "static" "video"))
+ (cons link-type (org-element-property :path link))))))))))
(ennu-make-post
:filename filename
:slug (file-name-base filename)
@@ -60,6 +61,16 @@
:date (org-timestamp-to-time (first (plist-get metadata :date)))
:language (plist-get metadata :language)
:links links
+ ;; TODO: Deal with cases when the :tangle parameter is "yes"
+ :tangle (seq-uniq
+ (org-element-map tree 'src-block
+ (lambda (src-block)
+ (pcase (org-babel-get-src-block-info nil src-block)
+ (`(,_ ,_ ,arguments ,_ ,_ ,_ ,_)
+ (let ((tangle-output-file (map-elt arguments :tangle)))
+ (pcase tangle-output-file
+ ("no" nil)
+ (_ tangle-output-file))))))))
:summary (funcall export (first (plist-get metadata :summary)))
:tags (plist-get metadata :filetags)
:thumbnail (or (plist-get metadata :thumbnail)