From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2Kc/He+wO2Ps7gAAbAwnHQ (envelope-from ) for ; Tue, 04 Oct 2022 06:05:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id WAd5He+wO2Nl7wAA9RJhRA (envelope-from ) for ; Tue, 04 Oct 2022 06:05:03 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C90863CD01 for ; Tue, 4 Oct 2022 06:05:02 +0200 (CEST) Received: from localhost ([::1]:41206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofZAz-00068E-Qe for larch@yhetil.org; Tue, 04 Oct 2022 00:05:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofZ9M-00067c-R3 for emacs-orgmode@gnu.org; Tue, 04 Oct 2022 00:03:23 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:35797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofZ9I-0003FZ-Pk for emacs-orgmode@gnu.org; Tue, 04 Oct 2022 00:03:19 -0400 Received: by mail-pf1-x42d.google.com with SMTP id i6so12135363pfb.2 for ; Mon, 03 Oct 2022 21:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date; bh=H1R8s5DtiGE6IDvVehDADeYtHCWwe6RwbALWtxn+Quo=; b=OuI5i1eyJs6Bu7Erqh9NcbG0dVSNDpQ5IMMGegXnOWYB7bnbp35fI8c/SV1Esu8n4x jAoGQTvnDrLkNkjOZm6z5dcpYgqwzVAhjJB4PqeTecu+Y4Y1YJMUrVsizXMJAqMFO8ZD PUpyxOBB70NHE4EbZjMXbDpF4SbF8pNeM7rAIUdI97wguZShDVYOzcBFwm7pyWmK4Xe6 kfZ7Bu9hYjTfFckc9MZf/KKcYDrdZYRoKxruFw8/Zcizp0dMb8pxwBkXAe8Cr9bOY9Qi CysvpdqFgLVYk8+101Jf7zUpQGUTdeelD2MUmOnPVXWHbkCwiuZzDcUV5LVgvkLKG3dS N9qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=H1R8s5DtiGE6IDvVehDADeYtHCWwe6RwbALWtxn+Quo=; b=SNXwP1juBQGyHp3yVZrLkb4krpmiKoCIFbFUfWVq9GuB/CnkRHsitkvXt+LMxCPltv NgDBv1po7h8vUmeUxB6X6iNk5RUYv/W5JseQBdSDFrMQ5Xf6EVzwVihq3Vzym9Fh9opD Qslop5q10tTTzBJcfzMwbyRWabGncd2HZSzCpDMcudbmyutS3hUT5WWe+mQu7M/JahgX rx3Fo+RU0XIXfUSSWkROKp8G0H8lSPwAlh0o3vTLV5xs3XW/5Pn6ymtMw3L/8h4ArypI te2qM8jeDcAA9re5GoSQfPjXMTPil0x8ygpF3tAWCGKjYKhLcOgVoHsz3ag3Z2NaXINn OjrQ== X-Gm-Message-State: ACrzQf1YaIQH714+XfAGT7wRPqa0QKtHhMw1V3HPADRoFlBENz/JuE9O 3f7FysZzxGxv8UIoKMzjdI6O1w10+R1z5cC+xW4= X-Google-Smtp-Source: AMsMyM7ZrkuC+Jghg/+62Dsd24OGfwPIxlpeZtVHXscaYNBEMEOHJUgkNu2Ryp2g6NSDql1bSPNSyw== X-Received: by 2002:a05:6a00:23c7:b0:543:e6f7:7eb2 with SMTP id g7-20020a056a0023c700b00543e6f77eb2mr25467772pfc.43.1664856194658; Mon, 03 Oct 2022 21:03:14 -0700 (PDT) Received: from localhost ([1.83.154.214]) by smtp.gmail.com with ESMTPSA id c12-20020a056a00008c00b0055acb3268a1sm8163409pfj.210.2022.10.03.21.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 21:03:13 -0700 (PDT) From: Ihor Radchenko To: David =?utf-8?Q?Luke=C5=A1?= Cc: Max Nikulin , emacs-orgmode@gnu.org Subject: Re: Code block syntax highlighting in async export In-Reply-To: References: <878rly1ydl.fsf@localhost> Date: Tue, 04 Oct 2022 12:04:07 +0800 Message-ID: <871qrow7yg.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=yantar92@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664856303; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=H1R8s5DtiGE6IDvVehDADeYtHCWwe6RwbALWtxn+Quo=; b=LL8qHe1My3NiJXd9uAVWObz4Ho7aQfJ3ELEWZgbL8lv3Ii8FztLYWOLUgCQ6GVbNJhTGWa BqSLU+5Lhk5QBJSmHbIZL8XvmbbkrWnNqENZlSKjd7Q3iQK9rCrEdKedsGMoUFvnhH1ETH A5bfOfKbqgZ5WOEIhfwyxl9+9d5tEEFCkPPuGx6HPVWww0PtvHusP2YwcPP0G/h3WgfF+1 sPlaWwr1hfuYlAnqkb2gTjfNo579T3zzW2n34T49Ro8vKqVcD8+KCgHX1ndQtF100PR408 v8k8ZwHlevybBg4qABKUGlqAVZ6Zby/uZcEh6QCF+FhUVA4+XhbS8DDnoOoHFQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664856303; a=rsa-sha256; cv=none; b=gYjMtzjaY4UJHpYTYhhjYqx2f73n97MLx0xiteixkcG9IU9WpL1IDdrzlwC15by3qgv/h2 B/7GzoEWdPOnNRXWOIqF52KbrkX9fwS7Tmnif5lTRFXZkkEkFX7RhUx6Od6fuaW6Bz9mXt 3VHNV3Fbkcz584B7AP+8Lp22zV5nOTd5vamxwawM9V2aiGHb6ZepIVSrEeTbBLWDTBFZAi zO9bC1pjHSVE94YPuCBXzqf/cUOtO5Iw8hS5GUXlHgP0Wxs3s6Id01JuEm9jypmscjJycy 0Du2bXLetzgAn13++A/N1AT/OAEJO4jTyPKJpGAEcoTzCMGKHDwVkYcfqbRLyg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OuI5i1ey; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.16 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OuI5i1ey; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: C90863CD01 X-Spam-Score: -4.16 X-Migadu-Scanner: scn0.migadu.com X-TUID: 8FW6o5fAihse --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable David Luke=C5=A1 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 ni= l 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 ni= l nil nil nil "org-function-name") In asynchronous export: default -> #s(htmlize-fstruct "#000000" "#ffffff" 1 nil nil nil nil nil "or= g-default") font-lock-comment-face -> #s(htmlize-fstruct nil nil nil t t nil nil nil "o= rg-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 ni= l 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? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-Do-not-disable-graphical-Emacs-capabilities-durin.patch >From 8bc0a66275ca6ffdf142e8e2c2b38d79923531d8 Mon Sep 17 00:00:00 2001 Message-Id: <8bc0a66275ca6ffdf142e8e2c2b38d79923531d8.1664855997.git.yantar92@gmail.com> From: Ihor Radchenko 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 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--