From: Ihor Radchenko <yantar92@gmail.com>
To: "David Lukeš" <dafydd.lukes@gmail.com>
Cc: Max Nikulin <manikulin@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Code block syntax highlighting in async export
Date: Tue, 04 Oct 2022 12:04:07 +0800 [thread overview]
Message-ID: <871qrow7yg.fsf@localhost> (raw)
In-Reply-To: <CAEPTPEwLOy9-kXozuSkRcsrUR955uPsP=W5jtoqeM6EX4EECXQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2733 bytes --]
David Lukeš <dafydd.lukes@gmail.com> writes:
>> Could you please provide an example?
>
>> Certainly more details is necessary, even export format (backend) is not
>> specified.
>
> Sorry for that! I somehow thought that the issue would sound familiar
> to more seasoned Org users, and someone would come back with either
> "yeah, you need to do X" or "yeah, that's a known limitation".
>
> The export backend is HTML. In case anyone wants to try reproducing
> this, I made a minimal working example here:
> https://github.com/dlukes/org-html-a-sync-export-syntax-highlighting
Thanks for the easy reproducer!
I played around with the export there, and I think I have found the
cause.
As expected, the problem originates from batch mode of Emacs
operation.
ox-html relies upon htmlize-region -> htmlize-buffer-1 ->
htmlize-make-face-map -> htmlize-face-to-fstruct ->
htmlize-face-to-fstruct-1.
In synchronous export `htmlize-face-to-fstruct-1' returns:
font-lock-comment-face -> #s(htmlize-fstruct "#b22222" nil nil nil nil nil nil nil "org-comment")
font-lock-comment-delimiter-face -> #s(htmlize-fstruct "#b22222" nil nil nil nil nil nil nil "org-comment-delimiter")
font-lock-doc-face -> #s(htmlize-fstruct "#8b2252" nil nil nil nil nil nil nil "org-doc")
font-lock-keyword-face -> #s(htmlize-fstruct "#a020f0" nil nil nil nil nil nil nil "org-keyword")
font-lock-function-name-face -> #s(htmlize-fstruct "#0000ff" nil nil nil nil nil nil nil "org-function-name")
In asynchronous export:
default -> #s(htmlize-fstruct "#000000" "#ffffff" 1 nil nil nil nil nil "org-default")
font-lock-comment-face -> #s(htmlize-fstruct nil nil nil t t nil nil nil "org-comment")
font-lock-comment-delimiter-face -> #s(htmlize-fstruct nil nil nil t t nil nil nil "org-comment-delimiter")
font-lock-doc-face -> #s(htmlize-fstruct nil nil nil nil t nil nil nil "org-doc")
font-lock-keyword-face -> #s(htmlize-fstruct nil nil nil t nil nil nil nil "org-keyword")
font-lock-function-name-face -> #s(htmlize-fstruct nil nil nil t nil nil nil nil "org-function-name")
-----------------------------
What can we do on the Org side to fix the issue?
One way could be avoiding batch execution altogether, like in the
attached patch. However, it will break our process sentinel watching for
the export results. Moreover, I am not sure how it will work when export
is done from terminal Emacs. Also, I know no way to _not_ create an
extra Emacs frame during such export - I imagine that a new frame (even
minimized) might be annoying for the users.
Maybe we should request Emacs to add --graphical-batch mode feature that
will preserve graphical features while not interfering with the WM?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-Do-not-disable-graphical-Emacs-capabilities-durin.patch --]
[-- Type: text/x-patch, Size: 1581 bytes --]
From 8bc0a66275ca6ffdf142e8e2c2b38d79923531d8 Mon Sep 17 00:00:00 2001
Message-Id: <8bc0a66275ca6ffdf142e8e2c2b38d79923531d8.1664855997.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Tue, 4 Oct 2022 11:58:45 +0800
Subject: [PATCH] ox: Do not disable graphical Emacs capabilities during async
export
* lisp/ox.el (org-export-async-start): Run Emacs in possibly iconized
window instead of batch mode. This way, font colors can be processed
by htmlize during async export.
---
lisp/ox.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lisp/ox.el b/lisp/ox.el
index 42204ffde..a31459632 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6432,7 +6432,9 @@ (defun org-export-async-start (fun body)
(funcall ',copy-fun)
(restore-buffer-modified-p nil)
;; Sexp to evaluate in the buffer.
- (print ,body)))
+ (print ,body)
+ ;; Kill Emacs at the end.
+ (kill-emacs 0)))
nil temp-file nil 'silent))
;; Start external process.
(let* ((process-connection-type nil)
@@ -6444,7 +6446,9 @@ (defun org-export-async-start (fun body)
(list "org-export-process"
proc-buffer
(expand-file-name invocation-name invocation-directory)
- "--batch")
+ ;; "--batch"
+ "--iconic"
+ )
(if org-export-async-init-file
(list "-Q" "-l" org-export-async-init-file)
(list "-l" user-init-file))
--
2.35.1
[-- Attachment #3: Type: text/plain, Size: 225 bytes --]
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
prev parent reply other threads:[~2022-10-04 4:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-02 3:24 Code block syntax highlighting in async export David Lukeš
2022-10-02 7:24 ` Ihor Radchenko
2022-10-02 12:13 ` Max Nikulin
2022-10-03 12:08 ` David Lukeš
2022-10-03 12:42 ` Timothy
2022-10-03 13:22 ` David Lukeš
2022-10-03 13:58 ` Ihor Radchenko
2022-10-03 14:40 ` Timothy
2022-10-04 4:10 ` Ihor Radchenko
2022-10-04 4:14 ` Timothy
2022-10-03 15:57 ` Max Nikulin
2022-10-03 19:32 ` David Lukeš
2022-10-04 4:04 ` Ihor Radchenko [this message]
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=871qrow7yg.fsf@localhost \
--to=yantar92@gmail.com \
--cc=dafydd.lukes@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
/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).