From 0815f6f49e9007df803901a776a6c1b383a2fe9e Mon Sep 17 00:00:00 2001 From: Christoph Ruegge Date: Sat, 25 Apr 2015 20:29:53 +0200 Subject: [PATCH] Enable using highlight.js instead of htmlize.el for code blocks When using highlight plugin, wrap src blocks in the required

tags. Additionally, in that case, htmlize.el fontification of the code
is inhibitied, since it should be carried out by hightlight.js. Also, do
not include the plugin by default in order not to break existing
documents relying on htmlize.
---
 ox-reveal.el | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/ox-reveal.el b/ox-reveal.el
index bdd6d8e..fa45a4a 100755
--- a/ox-reveal.el
+++ b/ox-reveal.el
@@ -293,7 +293,7 @@ can contain the following escaping elements:
   :type 'string)
 
 (defcustom org-reveal-plugins
-  '(classList markdown highlight zoom notes)
+  '(classList markdown zoom notes)
   "Default builtin plugins"
   :group 'org-export-reveal
   :type '(set
@@ -717,14 +717,24 @@ CONTENTS holds the contents of the item.  INFO is a plist holding
 contextual information."
   (if (org-export-read-attribute :attr_html src-block :textarea)
       (org-html--textarea-block src-block)
-    (let ((lang (org-element-property :language src-block))
-          (caption (org-export-get-caption src-block))
-          (code (org-html-format-code src-block info))
-          (frag (org-export-read-attribute :attr_reveal src-block :frag))
-          (label (let ((lbl (org-element-property :name src-block)))
-                   (if (not lbl) ""
-                     (format " id=\"%s\""
-                             (org-export-solidify-link-text lbl))))))
+    (let* ((buffer-plugins (plist-get info :reveal-plugins))
+           (use-highlight (memq 'highlight
+                                (cond
+                                 ((string= buffer-plugins "") nil)
+                                 (buffer-plugins (car (read-from-string buffer-plugins)))
+                                 (t org-reveal-plugins))))
+           (lang (org-element-property :language src-block))
+           (caption (org-export-get-caption src-block))
+           (code (if (not use-highlight)
+                     (org-html-format-code src-block info)
+                   (cl-letf (((symbol-function 'org-html-htmlize-region-for-paste)
+                              #'buffer-substring))
+                     (org-html-format-code src-block info))))
+           (frag (org-export-read-attribute :attr_reveal src-block :frag))
+           (label (let ((lbl (org-element-property :name src-block)))
+                    (if (not lbl) ""
+                      (format " id=\"%s\""
+                              (org-export-solidify-link-text lbl))))))
       (if (not lang)
           (format "
\n%s
" (or (frag-class frag info) " class=\"example\"") @@ -735,10 +745,14 @@ contextual information." (if (not caption) "" (format "" (org-export-data caption info))) - (format "\n
%s
" - (or (frag-class frag info) - (format " class=\"src src-%s\"" lang)) - label code)))))) + (if use-highlight + (format "\n%s
" + (or (frag-class frag info) "") + label lang code) + (format "\n
%s
" + (or (frag-class frag info) + (format " class=\"src src-%s\"" lang)) + label code))))))) (defun org-reveal-quote-block (quote-block contents info) "Transcode a QUOTE-BLOCK element from Org to Reveal.