branch: externals/org
commit 3c78e2c531bc502f74891fe27a85228d501e29d5
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    org-html-fontify-code: Work around htmlize force-fontifying buffer
    
    * lisp/ox-html.el (org-html-fontify-code): Disable `font-lock-ensure'
    while applying htmlize.  This prevents our custom faces from being
    overridden.
    
    Reported-by: Roi Martin <[email protected]>
    Link: https://orgmode.org/list/[email protected]
---
 lisp/ox-html.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 6916cc2160..654e510e4e 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2433,11 +2433,17 @@ is the language used for CODE, as a string, or nil."
                          (forward-char 1))))
                    (org-src-mode)
                    (set-buffer-modified-p nil)
-                   ;; Htmlize region.
-                   (let ((org-html-htmlize-output-type output-type)
-                         (org-html-htmlize-font-prefix font-prefix))
-                     (org-html-htmlize-region-for-paste
-                      (point-min) (point-max))))))
+                    ;; htmlize itself triggers re-fontification.
+                    ;; We do additional font manipulation, so
+                    ;; prevent font-lock from undoing our changes by
+                    ;; preventing `font-lock-mode' from re-fontifying
+                    ;; the buffer.
+                    (let ((font-lock-ensure-function #'ignore))
+                     ;; Htmlize region.
+                     (let ((org-html-htmlize-output-type output-type)
+                           (org-html-htmlize-font-prefix font-prefix))
+                       (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))))

Reply via email to