From dcf2ba74fcfe68c4590f7f71ed8029c72a3c10ac Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 4 Aug 2015 15:52:47 +0200 Subject: [PATCH 4/4] ox-html: Respect local values when formatting code * ox-html.el (org-html-fontify-code): Use local value of org-html-htmlize-output-type parent and org-html-htmlize-font-prefix parent. Reported-by: Eric S Fraga --- lisp/ox-html.el | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index d454fab..87351a8 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2041,25 +2041,31 @@ is the language used for CODE, as a string, or nil." ;; Case 2: Default. Fontify code. (t ;; htmlize - (setq code (with-temp-buffer - ;; Switch to language-specific mode. - (funcall lang-mode) - (insert code) - ;; Fontify buffer. - (font-lock-ensure) - ;; Remove formatting on newline characters. - (save-excursion - (let ((beg (point-min)) - (end (point-max))) - (goto-char beg) - (while (progn (end-of-line) (< (point) end)) - (put-text-property (point) (1+ (point)) 'face nil) - (forward-char 1)))) - (org-src-mode) - (set-buffer-modified-p nil) - ;; Htmlize region. - (org-html-htmlize-region-for-paste - (point-min) (point-max)))) + (setq code + (let ((parent (current-buffer))) + (with-temp-buffer + ;; Switch to language-specific mode. + (funcall lang-mode) + (insert code) + ;; Fontify buffer. + (font-lock-ensure) + ;; Remove formatting on newline characters. + (save-excursion + (let ((beg (point-min)) + (end (point-max))) + (goto-char beg) + (while (progn (end-of-line) (< (point) end)) + (put-text-property (point) (1+ (point)) 'face nil) + (forward-char 1)))) + (org-src-mode) + (set-buffer-modified-p nil) + ;; Htmlize region. + (let ((org-html-htmlize-output-type + (buffer-local-value 'org-html-htmlize-output-type parent)) + (org-html-htmlize-font-prefix + (buffer-local-value 'org-html-htmlize-font-prefix parent))) + (org-html-htmlize-region-for-paste + (point-min) (point-max)))))) ;; Strip any enclosing
 tags.
 	  (let* ((beg (and (string-match "\\`]*>\n*" code) (match-end 0)))
 		 (end (and beg (string-match "\\'" code))))
-- 
2.5.0