32
32
(expand-file-name " macros.org" (file-name-directory load-file-name)))
33
33
(org-macro--collect-macros )))
34
34
35
- ; ;; Code highlighting
36
- (defun org-html-decode-plain-text (text )
37
- " Convert HTML character to plain TEXT. i.e. do the inversion of
38
- `org-html-encode-plain-text`. Possible conversions are set in
39
- `org-html-protect-char-alist' ."
40
- (mapc
41
- (lambda (pair )
42
- (setq text (replace-regexp-in-string (cdr pair) (car pair) text t t )))
43
- (reverse org-html-protect-char-alist))
44
- text)
45
-
46
35
; ; Use pygments highlighting for code
47
36
(defun pygmentize (lang code )
48
37
" Use Pygments to highlight the given code and return the output"
64
53
(" clojure" . " clojure" )
65
54
(" css" . " css" )
66
55
(" d" . " d" )
67
- (" emacs-lisp" . " scheme" )
56
+ (" emacs-lisp" . " emacs-lisp" )
57
+ (" elisp" . " elisp" )
68
58
(" F90" . " fortran" )
69
59
(" gnuplot" . " gnuplot" )
70
60
(" groovy" . " groovy" )
@@ -98,20 +88,16 @@ See: http://orgmode.org/worg/org-contrib/babel/languages.html and
98
88
http://pygments.org/docs/lexers/ for adding new languages to the mapping." )
99
89
100
90
; ; Override the html export function to use pygments
101
- (defun org-html-src-block (src-block contents info )
91
+ (define-advice org-html-src-block (:around (old- src-block src-block contents info) )
102
92
" Transcode a SRC-BLOCK element from Org to HTML.
103
93
CONTENTS holds the contents of the item. INFO is a plist holding
104
94
contextual information."
105
- (if (org-export-read-attribute :attr_html src-block :textarea )
106
- (org-html--textarea-block src-block)
107
- (let ((lang (org-element-property :language src-block))
108
- (code (org-element-property :value src-block))
109
- (code-html (org-html-format-code src-block info)))
110
- (if nikola-use-pygments
111
- (progn
112
- (unless lang (setq lang " " ))
113
- (pygmentize (downcase lang) (org-html-decode-plain-text code)))
114
- code-html))))
95
+ (if (or (not nikola-use-pygments)
96
+ (org-export-read-attribute :attr_html src-block :textarea ))
97
+ (funcall old-src-block src-block contents info)
98
+ (let ((lang (or (org-element-property :language src-block) " " ))
99
+ (code (car (org-export-unravel-code src-block))))
100
+ (pygmentize (downcase lang) code))))
115
101
116
102
; ; Export images with custom link type
117
103
(defun org-custom-link-img-url-export (path desc format )
@@ -129,12 +115,12 @@ contextual information."
129
115
130
116
; ; Support for magic links (link:// scheme)
131
117
(org-link-set-parameters
132
- " link"
133
- :export (lambda (path desc backend )
134
- (cond
135
- ((eq 'html backend)
136
- (format " <a href=\" link:%s \" >%s </a> "
137
- path (or desc path))))))
118
+ " link"
119
+ :export (lambda (path desc backend )
120
+ (cond
121
+ ((eq 'html backend)
122
+ (format " <a href=\" link:%s \" >%s </a> "
123
+ path (or desc path))))))
138
124
139
125
; ; Export function used by Nikola.
140
126
(defun nikola-html-export (infile outfile )
0 commit comments