From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 EKo/H4sixWMvggEAbAwnHQ (envelope-from ) for ; Mon, 16 Jan 2023 11:10:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id aK8ZH4sixWO4gQAAauVa8A (envelope-from ) for ; Mon, 16 Jan 2023 11:10:19 +0100 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 42C3489AD for ; Mon, 16 Jan 2023 11:10:19 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHMQP-0006vr-MZ; Mon, 16 Jan 2023 05:09:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHMQN-0006vI-Rs for emacs-orgmode@gnu.org; Mon, 16 Jan 2023 05:09:07 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHMQL-0003W2-37 for emacs-orgmode@gnu.org; Mon, 16 Jan 2023 05:09:07 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id DDC0D240103 for ; Mon, 16 Jan 2023 11:09:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1673863742; bh=qBBlYO9i48cvTIMJcaRK2NGPYGAYYbUShbnbmJtrLP8=; h=From:To:Cc:Subject:Date:From; b=aeJmJaNd/1sZAEzU32r489UyqtDyynDhivvSwZWHvk+L/A9QPppH/G+YPQS8Rbp0h +2Q4FQCPDt5RMtlCKcxEGEYO9i69FFumuiP8aQ45VbdpjoqgnbwmBIbR5UuIOtO1ET TOcgOlt7PvoDQXduIdWaJyN5SG4AWlQW5CKOjHutG/hunnlODHUxeNu8eahNbT0/ao CvLNV3CE54XAA7iXX0YbSH0hc5OGW8xbijzy9kLd9UcXRUMdw44AsnJz0lGFEBuewT MW+xyDAqo8SxAVjHFWwmhdjqxKWr/k1PaFNgw5CVATGNuortovup7nAHYX3M0Wc0Hd 8LNtyZyx4CMjw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NwSRJ5DNDz6tms; Mon, 16 Jan 2023 11:09:00 +0100 (CET) From: Ihor Radchenko To: Johan =?utf-8?Q?Bolmsj=C3=B6?= Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] ox-html does not export captions of source blocks without language In-Reply-To: <87zgb90win.fsf@localhost> References: <116c3126-32cc-44d0-9e95-e802161e1e84@app.fastmail.com> <87zgb90win.fsf@localhost> Date: Mon, 16 Jan 2023 10:09:31 +0000 Message-ID: <87tu0qdc4k.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673863819; a=rsa-sha256; cv=none; b=DpfjZAoJD82jtZaYodKEp4HaGiROxx0ptLteZV9zs7mkNzTCnBJxvLda84hMyWi19VYRo9 cEPEV6+whsjsT+NIgsbK0K5+OAoqrNbVMoHdTkEMtQcQEfLA5Ssfz4YiLSjMtkMlS34O2Q URTbA0auu4aeJXfp9O5tNHnWgw2iTlH+QFA3zIA3JYjxqJj272STuiytnvEjKqyLC5lddt T4lREhlbgtIOpUSuqC/A940q8fIIHfXI7qNWuBzDUusfhLQFfKxhKUjO89UnF9jzkNKYPh Mjtw0ZjCVDyiLg5gY6UzfDcy221RWqfrDoXDd5eWFpla+gb+sp+QgwYq+jKXlw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=aeJmJaNd; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673863819; 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=SLwaVrXwz1mreYWAVIuKg3I1vm+2rB/DSa4gVOiHbmk=; b=gSF8JsCFDwMJUSLrsplJ/0qcghPNcP6s/25IKGS06Lu9vUyWPHdMqL0IigSrcmCJiOGTtq DdQEYP1d5WjSLlvhaEkAtwSg8Hy9g5NbqaNnJVlvJMoJqnHocCr8khxETEBXtLzfpBUVAC 1OWW9NPnvf0Pifsdst6KeQhfro3sjcARjbwrUP1pR+XKwce85vAsYAu8LtwRRypYLC6jYa dfPpove7eECtc3z5CWEXfMboO9K9H5C/KCC54BJKVc0kM9q7UlF5i+X82SoILROz1vLqiU O4vUral1Y60Bx+VARV2/1qiWioQbFnKrcCkutuIG12/e1e4rpdXvuXZQkcmCpw== X-Migadu-Spam-Score: -6.06 X-Spam-Score: -6.06 X-Migadu-Queue-Id: 42C3489AD X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=aeJmJaNd; 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"; dmarc=pass (policy=none) header.from=posteo.net X-TUID: vNAreTIlaYkp --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Here is the plan to resolve this issue: > > 1. We update the manual allowing src blocks to have empty language spec See the attached patch. > 2. We update org-syntax document It turned out to be unnecessary. org-syntax document already declares block DATA to be optional: #+begin_name [DATA] #+end_name See https://orgmode.org/worg/org-syntax.html#Blocks Code blocks fall within a subset of this rule. > 3. We change org-html-src-block to add caption to src blocks without lang See the attached patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-manual.org-Clarify-that-LANGUAGE-may-be-omitted-.patch >From a7c5aa3431cc1946aa7f8055c39e18e5afc4cef4 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Mon, 16 Jan 2023 12:59:47 +0300 Subject: [PATCH 1/2] org-manual.org: Clarify that LANGUAGE may be omitted in code blocks * doc/org-manual.org (Structure of Code Blocks): (Editing Source Code): Clarify that is optional. Link to possible consequences of being omitted. --- doc/org-manual.org | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 4466af8e4..c241e170f 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -17313,9 +17313,16 @@ ** Structure of Code Blocks - == :: #+cindex: language, in code blocks - Mandatory. It is the identifier of the source code language in the + Optional. It is the identifier of the source code language in the block. See [[*Languages]], for identifiers of supported languages. + When == identifier is omitted, the block also cannot + have == and =
=. + + Language identifier is also used to fontify code blocks in Org + buffers, when ~org-src-fontify-natively~ is set to non-~nil~. See + [[*Editing Source Code]]. + - == :: #+cindex: switches, in code blocks @@ -18951,6 +18958,9 @@ ** Editing Source Code header line, then the edit buffer uses that major mode. Use this variable to arbitrarily map language identifiers to major modes. + When language identifier is omitted in the src block, Org mode's + behavior is undefined. + - ~org-src-window-setup~ :: #+vindex: org-src-window-setup @@ -18976,10 +18986,13 @@ ** Editing Source Code #+vindex: org-src-fontify-natively #+vindex: org-src-block-faces -Set ~org-src-fontify-natively~ to non-~nil~ to turn on native code -fontification in the /Org/ buffer. Fontification of code blocks can -give visual separation of text and code on the display page. To -further customize the appearance of ~org-block~ for specific +Fontification of code blocks can give visual separation of text and +code on the display page. Set ~org-src-fontify-natively~ to non-~nil~ +to turn on native code fontification in the /Org/ buffer. The +fontification follows the major mode used to edit the code block (see +~org-src-lang-modes~ above). + +To further customize the appearance of ~org-block~ for specific languages, customize ~org-src-block-faces~. The following example shades the background of regular blocks, and colors source blocks only for Python and Emacs Lisp languages. -- 2.39.0 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0002-org-html-src-block-Treat-code-blocks-without-LANG-eq.patch Content-Transfer-Encoding: quoted-printable >From 8c832d374066bbba430dc21a6b4fb098361c44a9 Mon Sep 17 00:00:00 2001 Message-Id: <8c832d374066bbba430dc21a6b4fb098361c44a9.1673863743.git.yantar= 92@posteo.net> In-Reply-To: References: From: Ihor Radchenko Date: Mon, 16 Jan 2023 13:04:01 +0300 Subject: [PATCH 2/2] org-html-src-block: Treat code blocks without LANG equally MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/ox-html.el (org-html-src-block): Do not treat src blocks without LANG as example blocks. Instead, export them using "nil" language. This way, such src blocks will get captions, unlike example blocks. The new behavior is consistent with ox-latex and ox-ascii. Reported-by: Johan Bolmsj=C3=B6 Link: https://orgmode.org/list/87zgb90win.fsf@localhost --- lisp/ox-html.el | 52 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 7b79c57d4..5e58ccba3 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3616,32 +3616,32 @@ (defun org-html-src-block (src-block _contents info) (klipsify (and (plist-get info :html-klipsify-src) (member lang '("javascript" "js" "ruby" "scheme" "clojure" "php" "html"))))) - (if (not lang) (format "
\n%s
" label= code) - (format "
\n%s%s\n
" - ;; Build caption. - (let ((caption (org-export-get-caption src-block))) - (if (not caption) "" - (let ((listing-number - (format - "%s " - (format - (org-html--translate "Listing %d:" info) - (org-export-get-ordinal - src-block info nil #'org-html--has-caption-p))))) - (format "" - listing-number - (org-trim (org-export-data caption info)))))) - ;; Contents. - (if klipsify - (format "
%s
" - lang - label - (if (string=3D lang "html") - " data-editor-type=3D\"html\"" - "") - code) - (format "
%s
" - lang label code))))))) + (format "
\n%s%s\n
" + ;; Build caption. + (let ((caption (org-export-get-caption src-block))) + (if (not caption) "" + (let ((listing-number + (format + "%s " + (format + (org-html--translate "Listing %d:" info) + (org-export-get-ordinal + src-block info nil #'org-html--has-caption-p))))) + (format "" + listing-number + (org-trim (org-export-data caption info)))))) + ;; Contents. + (if klipsify + (format "
%s
" + lang ; lang being nil is OK. + label + (if (string=3D lang "html") + " data-editor-type=3D\"html\"" + "") + code) + (format "
%s
" + ;; Lang being nil is OK. + lang label code)))))) =20 ;;;; Statistics Cookie =20 --=20 2.39.0 --=-=-= 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 --=-=-=--