Skip to content

Commit 11cdca2

Browse files
committed
fix(orgmode): use org-export-unravel-code to handle indentation
1 parent 6ac28db commit 11cdca2

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

v8/orgmode/init.el

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
("clojure" . "clojure")
6565
("css" . "css")
6666
("d" . "d")
67-
("emacs-lisp" . "scheme")
67+
("emacs-lisp" . "emacs-lisp")
68+
("elisp" . "elisp")
6869
("F90" . "fortran")
6970
("gnuplot" . "gnuplot")
7071
("groovy" . "groovy")
@@ -98,20 +99,16 @@ See: http://orgmode.org/worg/org-contrib/babel/languages.html and
9899
http://pygments.org/docs/lexers/ for adding new languages to the mapping.")
99100

100101
;; Override the html export function to use pygments
101-
(defun org-html-src-block (src-block contents info)
102+
(define-advice org-html-src-block (:around (old-src-block src-block contents info))
102103
"Transcode a SRC-BLOCK element from Org to HTML.
103104
CONTENTS holds the contents of the item. INFO is a plist holding
104105
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))))
106+
(if (or (not nikola-use-pygments)
107+
(org-export-read-attribute :attr_html src-block :textarea))
108+
(funcall old-src-block src-block contents info)
109+
(let ((lang (or (org-element-property :language src-block) ""))
110+
(code (car (org-export-unravel-code src-block))))
111+
(pygmentize (downcase lang) (org-html-decode-plain-text code)))))
115112

116113
;; Export images with custom link type
117114
(defun org-custom-link-img-url-export (path desc format)
@@ -129,12 +126,12 @@ contextual information."
129126

130127
;; Support for magic links (link:// scheme)
131128
(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))))))
129+
"link"
130+
:export (lambda (path desc backend)
131+
(cond
132+
((eq 'html backend)
133+
(format "<a href=\"link:%s\">%s</a>"
134+
path (or desc path))))))
138135

139136
;; Export function used by Nikola.
140137
(defun nikola-html-export (infile outfile)

0 commit comments

Comments
 (0)