emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* ox-html: Opt out of htmlize.el
@ 2017-11-09 16:28 Chunyang Xu
  2017-11-12 22:30 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Chunyang Xu @ 2017-11-09 16:28 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi,

I think htmlize.el should be optional for ox-html. Although htmlize.el
is cool, there are still reasons to don't use it, e.g.,

- Colors looks nice in Emacs looks bad in the web browser
- No color at all in batch mode
- I want to use third party solutions such pygmentize and highlight.js

When user sets org-html-htmlize-output-type to nil, don't use
htmlize.el.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html-Allow-disabling-htmlize.patch --]
[-- Type: text/x-patch, Size: 1650 bytes --]

From 902e6cea48912bd291c1d3192cb30dc9a1a41fa3 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <mail@xuchunyang.me>
Date: Thu, 9 Nov 2017 23:43:32 +0800
Subject: [PATCH] ox-html: Allow disabling htmlize

* lisp/ox-html.el (org-html-fontify-code): Do it.

Disable htmlize by setting org-html-htmlize-output-type to nil.

TINYCHANGE
---
 lisp/ox-html.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 1c3dd8090..d0fe33f2a 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2158,7 +2158,11 @@ is the language used for CODE, as a string, or nil."
      ((not lang)
       ;; Simple transcoding.
       (org-html-encode-plain-text code))
-     ;; Case 2: No htmlize or an inferior version of htmlize
+     ;; Case 2: plain text explicitly set
+     ((not org-html-htmlize-output-type)
+      ;; Simple transcoding.
+      (org-html-encode-plain-text code))
+     ;; Case 3: No htmlize or an inferior version of htmlize
      ((not (and (or (require 'htmlize nil t)
 		    (error "Please install htmlize from https://github.com/hniksic/emacs-htmlize"))
 		(fboundp 'htmlize-region-for-paste)))
@@ -2166,10 +2170,6 @@ is the language used for CODE, as a string, or nil."
       (message "Cannot fontify src block (htmlize.el >= 1.34 required)")
       ;; Simple transcoding.
       (org-html-encode-plain-text code))
-     ;; Case 3: plain text explicitly set
-     ((not org-html-htmlize-output-type)
-      ;; Simple transcoding.
-      (org-html-encode-plain-text code))
      (t
       ;; Map language
       (setq lang (or (assoc-default lang org-src-lang-modes) lang))
-- 
2.14.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: ox-html: Opt out of htmlize.el
  2017-11-09 16:28 ox-html: Opt out of htmlize.el Chunyang Xu
@ 2017-11-12 22:30 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2017-11-12 22:30 UTC (permalink / raw)
  To: Chunyang Xu; +Cc: emacs-orgmode

Hello,

Chunyang Xu <mail@xuchunyang.me> writes:

> I think htmlize.el should be optional for ox-html. Although htmlize.el
> is cool, there are still reasons to don't use it, e.g.,
>
> - Colors looks nice in Emacs looks bad in the web browser
> - No color at all in batch mode
> - I want to use third party solutions such pygmentize and highlight.js
>
> When user sets org-html-htmlize-output-type to nil, don't use
> htmlize.el.

Since the code was already present in "ox-html", but not at the right
branch in the `cond', this qualifies as a bugfix. I applied it to maint
branch.

Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-12 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 16:28 ox-html: Opt out of htmlize.el Chunyang Xu
2017-11-12 22:30 ` Nicolas Goaziou

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).