-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildOrg
executable file
·84 lines (67 loc) · 3.01 KB
/
buildOrg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
":"; exec emacs --quick --script "$0" "$@" # -*-emacs-lisp-*-
;;; This script will build all the org files located under src
;; disable auto-save and auto-backup
(setq auto-save-default nil)
(setq make-backup-files nil)
(require 'org)
(require 'ox)
(defvar src (expand-file-name "src" (file-name-directory load-file-name))
"where to build all the org files")
;;Some publishing settings
(setq org-export-with-author nil
org-export-with-toc nil
org-html-head-include-default-style nil
org-html-head-include-scripts nil
org-html-html5-fancy t
;; org-html-htmlize-output-type (quote css)
org-html-postamble nil
org-html-preamble nil
org-export-with-tasks nil
org-export-with-section-numbers nil)
(defun get-highlightjs-lang (org-lang)
(or (cdr (assoc-string org-lang
'(("emacs-lisp" . "scheme")
("js" . "javascript"))))
org-lang))
;; (setq org-html-protect-char-alist ())
(defun blog-org-html-src-block (src-block contents info)
(let ((lang (get-highlightjs-lang (org-element-property :language src-block)))
(caption (org-export-get-caption src-block))
(code (org-html-format-code src-block info))
(label (let ((lbl (org-element-property :name src-block)))
(if (not lbl) ""
(format " id=\"%s\""
(org-export-solidify-link-text lbl))))))
(if (not lang) (format "<pre class=\"example\"%s><code class=\"src example\">%s</code></pre>" label code)
(format
"<div class=\"org-src-container\">\n%s%s\n</div>"
(if (not caption) ""
(format "<label class=\"org-src-name\">%s</label>"
(org-export-data caption info)))
(format "\n<pre class=\"src language-%s\"%s><code class=\"src %s\">%s</code></pre>" lang label lang code)))))
(defun org-blog-html-publish-to-html (plist filename pub-dir)
"same as org-html-publish-to-html but with blog-html backend"
(org-publish-org-to 'blog-html filename
(concat "." (or (plist-get plist :html-extension)
org-html-extension "html"))
plist pub-dir))
(org-export-define-derived-backend 'blog-html 'html
:translate-alist '((src-block . blog-org-html-src-block)))
;;Notice: Backtick and commmas here, src must be evaluated, but other parts must not?
;;http://stackoverflow.com/questions/9449364/elisp-alist-and-strings-type-confusion
(princ (format "%s%s" "publishing org files in " src))
(setq org-publish-project-alist
`(("org-thrown"
:base-directory ,src
:base-extension "org"
:publishing-directory ,src
:recursive t
:publishing-function org-blog-html-publish-to-html
;; :publishing-function org-html-publish-to-html
:headline-levels 4
:html-extension "html"
:body-only t ;; Only export section between <body> </body>)
)))
(org-publish-project "org-thrown")
(princ "\norg publish complete")