emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: controlling how htmlize fontifies code
Date: Tue, 04 Aug 2015 16:00:12 +0200	[thread overview]
Message-ID: <87wpxbrw5v.fsf@gmx.us> (raw)
In-Reply-To: 87a8u7faou.fsf@ucl.ac.uk

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

Hi Eric,

Thanks for looking into this.

Eric S Fraga <e.fraga@ucl.ac.uk> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-ox-html-Respect-local-values-when-formatting-code.patch --]
[-- Type: text/x-diff, Size: 2560 bytes --]

From dcf2ba74fcfe68c4590f7f71ed8029c72a3c10ac Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
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 <e.fraga@ucl.ac.uk>
<http://permalink.gmane.org/gmane.emacs.orgmode/99450>
---
 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 <pre></pre> tags.
 	  (let* ((beg (and (string-match "\\`<pre[^>]*>\n*" code) (match-end 0)))
 		 (end (and beg (string-match "</pre>\\'" code))))
-- 
2.5.0


  reply	other threads:[~2015-08-04 14:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-02  9:24 controlling how htmlize fontifies code Eric S Fraga
2015-08-02 12:17 ` Rasmus
2015-08-03 13:51   ` Eric S Fraga
2015-08-02 13:19 ` Rick Frankel
2015-08-02 13:41   ` Kaushal
2015-08-03 13:50   ` Eric S Fraga
2015-08-03 21:08     ` Rick Frankel
2015-08-04 12:41       ` Eric S Fraga
2015-08-04 13:24       ` Eric S Fraga
2015-08-04 14:00         ` Rasmus [this message]
2015-08-04 15:09           ` Nicolas Goaziou
2015-08-04 15:21             ` Rasmus
2015-08-04 18:27               ` Nicolas Goaziou
2015-08-04 18:38                 ` Rasmus
2015-08-04 18:44                   ` Nicolas Goaziou
2015-08-04 16:03             ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wpxbrw5v.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).