emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Question: how to disable htmlize during exporting?
@ 2014-03-25  3:33 Kelvin Hu
  2014-03-25  8:25 ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Kelvin Hu @ 2014-03-25  3:33 UTC (permalink / raw)
  To: emacs-orgmode

Dears,

Org is awesome and now I use it as my blogging tool, everything is
perfect except the source code highlighting. Org uses htmlize.el to
highlight source code, it's fine, but when I use another theme or on a
different machine, the generated html(contains source code block) will
change due to Emacs theme change. As I use git to manage my generated
html files, so when publishing after a theme change, those html files
contain source code will change and thus I need to *git commit* a lot
of files without actual useful content change!

So now I want to use google prettify.js to highlight my source code,
but I cannot disable htmlize.el during exporting, I googled and
someone said removing htmlize.el will achieve this, but I don't think
it is a good idea.

Any ideas?

Thanks,
Kelvin

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

* Re: Question: how to disable htmlize during exporting?
  2014-03-25  3:33 Question: how to disable htmlize during exporting? Kelvin Hu
@ 2014-03-25  8:25 ` Bastien
       [not found]   ` <CAO61DjxKttv80o3pMN3Z2ZNORDRYw5j=E_eKrT0wiGypdWdSxg@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien @ 2014-03-25  8:25 UTC (permalink / raw)
  To: Kelvin Hu; +Cc: emacs-orgmode

Hi Kelvin,

Kelvin Hu <ini.kelvin@gmail.com> writes:

> Org is awesome and now I use it as my blogging tool, everything is
> perfect except the source code highlighting. Org uses htmlize.el to
> highlight source code, it's fine, but when I use another theme or on a
> different machine, the generated html(contains source code block) will
> change due to Emacs theme change. As I use git to manage my generated
> html files, so when publishing after a theme change, those html files
> contain source code will change and thus I need to *git commit* a lot
> of files without actual useful content change!

> So now I want to use google prettify.js to highlight my source code,
> but I cannot disable htmlize.el during exporting, I googled and
> someone said removing htmlize.el will achieve this, but I don't think
> it is a good idea.

I'd try to set `org-html-htmlize-output-type' to nil but I didn't
test.  If it does not work, this is a bug.

-- 
 Bastien

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

* Fwd: Question: how to disable htmlize during exporting?
       [not found]   ` <CAO61DjxKttv80o3pMN3Z2ZNORDRYw5j=E_eKrT0wiGypdWdSxg@mail.gmail.com>
@ 2014-03-25 12:29     ` Kelvin Hu
  2014-03-25 15:37       ` Rick Frankel
  0 siblings, 1 reply; 5+ messages in thread
From: Kelvin Hu @ 2014-03-25 12:29 UTC (permalink / raw)
  To: emacs-orgmode

[forwarding to mailing-list]

---------- Forwarded message ----------
From: Kelvin Hu <ini.kelvin@gmail.com>
Date: 2014-03-25 18:07 GMT+08:00
Subject: Re: Question: how to disable htmlize during exporting?
To: Bastien <bzg@gnu.org>


Hi Bastien,

2014-03-25 16:25 GMT+08:00 Bastien <bzg@gnu.org>:

> I'd try to set `org-html-htmlize-output-type' to nil but I didn't
> test.  If it does not work, this is a bug.

Thanks for your reply, I have tried this approach, but it reports
"error: (void function nil)".
Per the definition in `ox-html.el', it must be either 'inline-css or 'css.

After some research, now I use the following workaround:

(flet ((org-html-fontify-code
        (code lang) (when code (org-html-encode-plain-text code))))
  ;; code here
  ;; e.g. (insert (org-export-as 'html nil nil t nil))
)

Redefine the function `org-html-fontify-code' will help, but I think
this workaround is a little ugly. So, I hope this feature can be
disabled gracefully, like set `org-html-htmlize-output-type' to nil.

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

* Re: Fwd: Question: how to disable htmlize during exporting?
  2014-03-25 12:29     ` Fwd: " Kelvin Hu
@ 2014-03-25 15:37       ` Rick Frankel
  2014-03-25 15:41         ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Rick Frankel @ 2014-03-25 15:37 UTC (permalink / raw)
  To: Kelvin Hu; +Cc: emacs-orgmode

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

On 2014-03-25 08:29, Kelvin Hu wrote:
> 2014-03-25 16:25 GMT+08:00 Bastien <bzg@gnu.org>:
> 
> I'd try to set `org-html-htmlize-output-type' to nil but I didn't
> test.  If it does not work, this is a bug.
> 
> Thanks for your reply, I have tried this approach, but it reports
> "error: (void function nil)".
> Per the definition in `ox-html.el', it must be either 'inline-css or 
> 'css.
> 

But it's an excellent idea. I have a patch to ox-html which will allow 
ox-htmlize-output type to be set to `nil', to explicitly return plain 
text.

I will push it to master tonight when i get out from behind the 
firewall...

rick

P.S. Attached for review...

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-disabling-of-htmlization-in-ox-html-export.patch --]
[-- Type: text/x-lisp; name=0001-Allow-disabling-of-htmlization-in-ox-html-export.patch, Size: 2327 bytes --]

From b49fa8b36b983f32ca9ff090eec0be7ff45a50c3 Mon Sep 17 00:00:00 2001
From: Rick Frankel <rick@rickster.com>
Date: Tue, 25 Mar 2014 11:27:07 -0400
Subject: [PATCH] Allow disabling of htmlization in ox-html export.

* lisp/ox-html.el (org-html-htmlize-output-type): Add `nil'
  option (no htmlization).
(org-html-fontify-code): Return plain text if
`org-html-htmlize-output-type' is `nil'.
---
 lisp/ox-html.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 52795a3..a843441 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -756,9 +756,10 @@ link's path."
 
 (defcustom org-html-htmlize-output-type 'inline-css
   "Output type to be used by htmlize when formatting code snippets.
-Choices are `css', to export the CSS selectors only, or `inline-css', to
-export the CSS attribute values inline in the HTML.  We use as default
-`inline-css', in order to make the resulting HTML self-containing.
+Choices are `css' to export the CSS selectors only,`inline-css'
+to export the CSS attribute values inline in the HTML or `nil' to
+export plain text.  We use as default `inline-css', in order to
+make the resulting HTML self-containing.
 
 However, this will fail when using Emacs in batch mode for export, because
 then no rich font definitions are in place.  It will also not be good if
@@ -771,7 +772,7 @@ all the faces you are interested in are defined, for example by loading files
 in all modes you want.  Then, use the command
 \\[org-html-htmlize-generate-css] to extract class definitions."
   :group 'org-export-html
-  :type '(choice (const css) (const inline-css)))
+  :type '(choice (const css) (const inline-css) (const nil)))
 
 (defcustom org-html-htmlize-font-prefix "org-"
   "The prefix for CSS class names for htmlize font specifications."
@@ -1894,6 +1895,10 @@ 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))
-- 
1.8.0


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

* Re: Fwd: Question: how to disable htmlize during exporting?
  2014-03-25 15:37       ` Rick Frankel
@ 2014-03-25 15:41         ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2014-03-25 15:41 UTC (permalink / raw)
  To: Rick Frankel; +Cc: emacs-orgmode

Rick Frankel <rick@rickster.com> writes:

> P.S. Attached for review...

Looks useful indeed, thanks in advance for pushing this!

-- 
 Bastien

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

end of thread, other threads:[~2014-03-25 15:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-25  3:33 Question: how to disable htmlize during exporting? Kelvin Hu
2014-03-25  8:25 ` Bastien
     [not found]   ` <CAO61DjxKttv80o3pMN3Z2ZNORDRYw5j=E_eKrT0wiGypdWdSxg@mail.gmail.com>
2014-03-25 12:29     ` Fwd: " Kelvin Hu
2014-03-25 15:37       ` Rick Frankel
2014-03-25 15:41         ` Bastien

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