1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- (require 'json)
- (require 'org)
- (require 'ox)
- (defun org->pelican (filename backend)
- (progn
- (save-excursion
-
- (find-file filename)
-
- (let (
- (org-export-env (org-export-get-environment))
-
- (modifiedstr (cdr (assoc-string "MODIFIED" org-file-properties t)))
-
- (dateobj (car (plist-get (org-export-get-environment) ':date)))
- )
-
- (if (symbolp (car (plist-get org-export-env :title)))
- (error "Each page/article must have a #+TITLE: property"))
-
- (princ (json-encode
- (list
-
- :title (substring-no-properties
- (car (plist-get org-export-env :title)))
-
-
-
- :date (if (symbolp dateobj)
- ""
- (if (stringp dateobj)
- (org-read-date nil nil dateobj nil)
- (org-timestamp-format dateobj "%Y-%m-%d")))
- :author (substring-no-properties
- (car (plist-get org-export-env ':author)))
-
- :category (cdr (assoc-string "CATEGORY" org-file-properties t))
-
- :language (cdr (assoc-string "LANGUAGE" org-file-properties t))
- :save_as (cdr (assoc-string "SAVE_AS" org-file-properties t))
- :tags (cdr (assoc-string "TAGS" org-file-properties t))
- :summary (cdr (assoc-string "SUMMARY" org-file-properties t))
- :slug (cdr (assoc-string "SLUG" org-file-properties t))
- :modified (if (stringp modifiedstr)
- (org-read-date nil nil modifiedstr nil)
- "")
- :post (org-export-as backend nil nil t)
- )
- )
- )
- )
- )
- )
- )
|