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 <e.fraga@ucl.ac.uk>
<http://permalink.gmane.org/gmane.emacs.orgmode/99450>
This commit is contained in:
Rasmus 2015-08-04 15:52:47 +02:00
parent f63d76872c
commit 6db0b0cd43
1 changed files with 24 additions and 19 deletions

View File

@ -2041,25 +2041,30 @@ is the language used for CODE, as a string, or nil."
;; Case 2: Default. Fontify code. ;; Case 2: Default. Fontify code.
(t (t
;; htmlize ;; htmlize
(setq code (with-temp-buffer (setq code
;; Switch to language-specific mode. (let ((output-type org-html-htmlize-output-type)
(funcall lang-mode) (font-prefix orgb-html-htmlize-font-prefix))
(insert code) (with-temp-buffer
;; Fontify buffer. ;; Switch to language-specific mode.
(font-lock-ensure) (funcall lang-mode)
;; Remove formatting on newline characters. (insert code)
(save-excursion ;; Fontify buffer.
(let ((beg (point-min)) (font-lock-ensure)
(end (point-max))) ;; Remove formatting on newline characters.
(goto-char beg) (save-excursion
(while (progn (end-of-line) (< (point) end)) (let ((beg (point-min))
(put-text-property (point) (1+ (point)) 'face nil) (end (point-max)))
(forward-char 1)))) (goto-char beg)
(org-src-mode) (while (progn (end-of-line) (< (point) end))
(set-buffer-modified-p nil) (put-text-property (point) (1+ (point)) 'face nil)
;; Htmlize region. (forward-char 1))))
(org-html-htmlize-region-for-paste (org-src-mode)
(point-min) (point-max)))) (set-buffer-modified-p nil)
;; Htmlize region.
(let ((org-html-htmlize-output-type output-type)
(org-html-htmlize-font-prefix font-prefix))
(org-html-htmlize-region-for-paste
(point-min) (point-max))))))
;; Strip any enclosing <pre></pre> tags. ;; Strip any enclosing <pre></pre> tags.
(let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0))) (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
(end (and beg (string-match "</pre>\\'" code)))) (end (and beg (string-match "</pre>\\'" code))))