From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: controlling how htmlize fontifies code Date: Tue, 04 Aug 2015 16:00:12 +0200 Message-ID: <87wpxbrw5v.fsf@gmx.us> References: <874mkihwl2.fsf@ucl.ac.uk> <20150802131919.GA98482@eyeBook.home> <87a8u8jxb0.fsf@ucl.ac.uk> <20150803210802.GA2327@eyeBook.home> <87a8u7faou.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMclf-00048O-AL for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 10:00:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMclW-0004fP-IZ for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 10:00:35 -0400 Received: from plane.gmane.org ([80.91.229.3]:46666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMclW-0004ed-4y for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 10:00:26 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZMclT-0005gU-BO for emacs-orgmode@gnu.org; Tue, 04 Aug 2015 16:00:23 +0200 Received: from ip5b4025d5.dynamic.kabel-deutschland.de ([91.64.37.213]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Aug 2015 16:00:23 +0200 Received: from rasmus by ip5b4025d5.dynamic.kabel-deutschland.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Aug 2015 16:00:23 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi Eric, Thanks for looking into this. Eric S Fraga writes: > Trying to fix this is definitely beyond my ability unfortunately. I may > need to see how onerous it is to set the output type to css globally. Here's a simple fix, though I suspect Nicolas will have a more through solution up his sleeve. Of course, in org-html--build-head the mysterious :html-htmlized-css-url is required so you won't actually get any default colors, which is a bit boring in my opinion. I don't know if I'm misunderstanding :html-htmlized-css-url, a bug or something supposed to be set via a publish project. Rasmus -- This is the kind of tedious nonsense up with which I will not put --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0004-ox-html-Respect-local-values-when-formatting-code.patch >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


--=-=-=--