From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 iJi9A2ZtYGJXMAEAbAwnHQ (envelope-from ) for ; Wed, 20 Apr 2022 22:30:30 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id AGbdAmZtYGJoJQEAG6o9tA (envelope-from ) for ; Wed, 20 Apr 2022 22:30:30 +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 8525B3D7E2 for ; Wed, 20 Apr 2022 22:30:29 +0200 (CEST) Received: from localhost ([::1]:52924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhGy4-0007eN-Go for larch@yhetil.org; Wed, 20 Apr 2022 16:30:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhGiX-0004YM-Pp for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 16:14:25 -0400 Received: from st43p00im-ztbu10073701.me.com ([17.58.63.183]:45606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhGiV-0004HV-EM for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 16:14:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1650485660; bh=uRFd+a8QmmOplMO2S0q+QNBqgrd5jiI0CCJbcMnJJaY=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=xAGzxs6wGVvvtKzhYSnb2Bz5VmP3u0sqpZqwEv3muDsZD1kcZAH31gFVtUT6M5PxA 80U1gHvGux77Sba1t33UlI7n4D2OwmqoaYk96ObAc+FZe7L6Sd/2b7l7Q4DWOEscNZ r4kwHVzBzNuo0HVaJawFpwEEpt2nPzBH6kQeULFRdyN6YaaUMCBp+89+hNDU2c/ox4 TFWAM2E9o8R1rNYeXVyCbQ9qEgYNFn+C5GPCOhADv9lJ0DdFWBcqnqDhYUuv7V4vZD nCiqbEZk/L/waQQuntVsfElAY2ORhof9uQoYBYiaxUuV1gKfAFUYnxUx/6zm4d4irG dA3ahGmKT6eOA== Received: from Workstation.local (st43p00im-dlb-asmtp-mailmevip.me.com [17.42.251.41]) by st43p00im-ztbu10073701.me.com (Postfix) with ESMTPSA id D02F11803F0 for ; Wed, 20 Apr 2022 20:14:19 +0000 (UTC) From: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= To: emacs-orgmode@gnu.org Subject: Re: [PATCH] Re: No mathematics in Texinfo exports In-Reply-To: References: Date: Wed, 20 Apr 2022 22:14:16 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.486, 18.0.858 definitions=2022-04-20_05:2022-04-20, 2022-04-20 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2204200119 Received-SPF: pass client-ip=17.58.63.183; envelope-from=salutis@me.com; helo=st43p00im-ztbu10073701.me.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650486629; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=uRFd+a8QmmOplMO2S0q+QNBqgrd5jiI0CCJbcMnJJaY=; b=crUVKC6NK/xHSL0Hs7+Fs7WWMGMb2le3OKEKbDj379yH66z3cX1UuaXcwCQb9MyJPS+OGc spS+9s1fk0auKoWAjgbp4iEvws2cFWBHWq5gRbSP6iLsF+B3bzK9cTqYm2IUAYD4D0GITO v/HlJ92IXZh6AxRIKNH7jRKAJpHNmLD2Jcq9AH+GUgFpFznbQOilv3w59enMLrGLGlNHMs KnZ2RUzNiqiavoUib1mwRgv+VXx+70zxHPPAKuwv1g6K4z7qTEFNmXR3q1fBtlOEHB0R+R vzUzmwttAuPay3FQDW2eDHHlrI4MZPIaj4VXhxp81PK0jzRMPSy0dzsaNuSXTg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650486629; a=rsa-sha256; cv=none; b=qBJ4jIlQgIcwP8pLZMzFs24YcYbqQWvHpcs0cJGRk8vDMpkQyLYlvQJudSwhlTAdIFXE8+ K5qRQBy+nwam9mySNy4MF6FGqAQRuK+D6TamCUErTn391CspgFIF8fJcMB9og5pyB+9cDk qmqYXnYXhe3g+VvqVsiMR5IxOc6KcFB5SeJ2T1GLW1RKZTpysl5AQB1eaLvb5CLIrHmyVL IQ/PKZczLy6qDKfOrtv0T/9wmDNQCD+mMO4qBC3i/UtGOxob13JVfNHJPfKVU4JJi56JQt E5ytiKaZ51zf2dZDzR7a078hTdcumJqfTXS5jp7s4MiyCS5DreB0Z33OirS2Ag== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=me.com header.s=1a1hai header.b=xAGzxs6w; dmarc=pass (policy=quarantine) header.from=me.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: -6.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=me.com header.s=1a1hai header.b=xAGzxs6w; dmarc=pass (policy=quarantine) header.from=me.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: 8525B3D7E2 X-Spam-Score: -6.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: aoZEGzN2P/As Hello everyone, My patch (from almost a month ago) has yet to appear at https://updates.orgmode.org Any ideas what to do? Could someone review it? Thank you! Rudy +++ The original message below. +++ Rudolf Adamkovi=C4=8D writes: > Rudolf Adamkovi=C4=8D writes: > >> [=E2=80=A6], or do I have to tackle the problem myself? I would appreci= ate >> any tips. > > I pulled up my sleeves and added the functionality myself. See the > attached patch. Please note that I have never contributed patches via > mail, and I have never signed any FSF papers. I would appreciate your > guidance. Thank you! > > From 5fe65432c1a6440c86d0bbc0b66a6603e5a8f100 Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Rudolf=3D20Adamkovi=3DC4=3D8D?=3D > Date: Sat, 26 Mar 2022 16:46:47 +0100 > Subject: [PATCH] ox-texinfo: Include LaTeX in Texinfo exports > > * lisp/ox-texinfo.el (org-texinfo-latex-environment): New function. > * lisp/ox-texinfo.el (org-texinfo-latex-fragment): New function. > * lisp/ox-texinfo.el (texinfo): Set latex-environment. > * lisp/ox-texinfo.el (texinfo): Set latex-fragment. > * testing/lisp/test-ox-texinfo.el: Add basic tests. > > Include (La)TeX mathematics, both inline and display style, in Texinfo > exports. > --- > lisp/ox-texinfo.el | 42 ++++++ > testing/lisp/test-ox-texinfo.el | 221 ++++++++++++++++++++++++++++++++ > 2 files changed, 263 insertions(+) > create mode 100644 testing/lisp/test-ox-texinfo.el > > diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el > index a01bb268c..0bfd06550 100644 > --- a/lisp/ox-texinfo.el > +++ b/lisp/ox-texinfo.el > @@ -55,6 +55,8 @@ > (italic . org-texinfo-italic) > (item . org-texinfo-item) > (keyword . org-texinfo-keyword) > + (latex-environment . org-texinfo-latex-environment) > + (latex-fragment . org-texinfo-latex-fragment) > (line-break . org-texinfo-line-break) > (link . org-texinfo-link) > (node-property . org-texinfo-node-property) > @@ -1212,6 +1214,46 @@ CONTENTS is nil. INFO is a plist holding contextu= al information." > (concat "@listoffloats " > (org-export-translate "Listing" :utf-8 info)))))))) >=20=20 > +;;;; LaTeX Environment > + > +(defun org-texinfo-latex-environment (environment _contents info) > + "Transcode a LaTeX ENVIRONMENT from Org to Texinfo. CONTENTS is > +nil. INFO is a plist holding contextual information." > + (when (plist-get info :with-latex) > + (let ((value (org-element-property :value environment))) > + (string-join (list "@displaymath" > + (string-trim (org-remove-indentation value)) > + "@end displaymath") > + "\n")))) > + > +;;;; LaTeX Fragment > + > +(defun org-texinfo-latex-fragment (fragment _contents info) > + "Transcode a LaTeX FRAGMENT from Org to Texinfo. CONTENTS is > +nil. INFO is a plist holding contextual information." > + (when (plist-get info :with-latex) > + (let ((value (org-remove-indentation > + (org-element-property :value fragment)))) > + (cond > + ((or (string-match-p "^\\\\\\[" value) > + (string-match-p "^\\$\\$" value)) > + (concat "\n" > + "@displaymath" > + "\n" > + (string-trim (substring value 2 -2)) > + "\n" > + "@end displaymath" > + "\n")) > + ((string-match-p "^\\$" value) > + (concat "@math{" > + (string-trim (substring value 1 -1)) > + "}")) > + ((string-match-p "^\\\\(" value) > + (concat "@math{" > + (string-trim (substring value 2 -2)) > + "}")) > + (t value))))) > + > ;;;; Line Break >=20=20 > (defun org-texinfo-line-break (_line-break _contents _info) > diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texin= fo.el > new file mode 100644 > index 000000000..316b7cb1d > --- /dev/null > +++ b/testing/lisp/test-ox-texinfo.el > @@ -0,0 +1,221 @@ > +;;; test-ox-texinfo.el --- Tests for ox-texinfo.el > + > +;; Copyright (C) 2022 Rudolf Adamkovi=C4=8D > + > +;; Author: Rudolf Adamkovi=C4=8D > + > +;; This file is not part of GNU Emacs. > + > +;; This program is free software; you can redistribute it and/or modify > +;; it under the terms of the GNU General Public License as published by > +;; the Free Software Foundation, either version 3 of the License, or > +;; (at your option) any later version. > + > +;; This program is distributed in the hope that it will be useful, > +;; but WITHOUT ANY WARRANTY; without even the implied warranty of > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;; GNU General Public License for more details. > + > +;; You should have received a copy of the GNU General Public License > +;; along with this program. If not, see . > + > +;;; Code: > + > +(require 'cl-lib) > +(require 'ox-texinfo) > + > +(unless (featurep 'ox-texinfo) > + (signal 'missing-test-dependency "org-export-texinfo")) > + > +(ert-deftest test-org-export-texinfo/latex-fragment () > + "Test `org-texinfo-latex-fragment' output." > + > + ;; inline TeX fragment > + (should > + (equal "@math{a^2 =3D b}" > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + '(:value "$a^2 =3D b$")) > + nil > + '(:with-latex t)))) > + > + ;; inline TeX fragment, padded > + (should > + (equal "@math{a^2 =3D b}" > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + '(:value "$ a^2 =3D b $")) > + nil > + '(:with-latex t)))) > + > + ;; inline LaTeX fragment > + (should > + (equal "@math{a^2 =3D b}" > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + '(:value "\\(a^2 =3D b\\)")) > + nil > + '(:with-latex t)))) > + > + ;; inline LaTeX fragment, padded > + (should > + (equal "@math{a^2 =3D b}" > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + '(:value "\\( a^2 =3D b \\)")) > + nil > + '(:with-latex t)))) > + > + ;; displayed TeX fragment, inline > + (should > + (equal (string-join > + (list "" > + "@displaymath" > + "a ^ 2 =3D b" > + "@end displaymath" > + "") > + "\n") > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + (list :value "$$a ^ 2 =3D b$$")) > + nil > + '(:with-latex t)))) > + > + ;; displayed TeX fragment, inline, padded > + (should > + (equal (string-join > + (list "" > + "@displaymath" > + "a ^ 2 =3D b" > + "@end displaymath" > + "") > + "\n") > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + (list :value "$$ a ^ 2 =3D b $$")) > + nil > + '(:with-latex t)))) > + > + ;; displayed TeX fragment, multi-line > + (should > + (equal (string-join > + (list "" > + "@displaymath" > + "a ^ 2 =3D b" > + "b ^ 2 =3D c" > + "@end displaymath" > + "") > + "\n") > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + (list :value > + (string-join > + (list "$$" > + "a ^ 2 =3D b" > + "b ^ 2 =3D c" > + "$$") > + "\n"))) > + nil > + '(:with-latex t)))) > + > + ;; displayed TeX fragment, multi-line, indented > + (should > + (equal (string-join > + (list "" > + "@displaymath" > + "a ^ 2 =3D b" > + "b ^ 2 =3D c" > + "@end displaymath" > + "") > + "\n") > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + (list :value > + (string-join > + (list " $$" > + " a ^ 2 =3D b" > + " b ^ 2 =3D c" > + " $$") > + "\n"))) > + nil > + '(:with-latex t)))) > + > + ;; displayed LaTeX fragment, inline > + (should > + (equal (string-join > + (list "" > + "@displaymath" > + "a ^ 2 =3D b" > + "@end displaymath" > + "") > + "\n") > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + (list :value "\\[a ^ 2 =3D b\\]")) > + nil > + '(:with-latex t)))) > + > + ;; displayed LaTeX fragment, inline, padded > + (should > + (equal (string-join > + (list "" > + "@displaymath" > + "a ^ 2 =3D b" > + "@end displaymath" > + "") > + "\n") > + (org-texinfo-latex-fragment > + (org-element-create 'latex-fragment > + (list :value "\\[ a ^ 2 =3D b \\]")) > + nil > + '(:with-latex t))))) > + > +(ert-deftest test-org-export-texinfo/latex-environment () > + "Test `org-texinfo-latex-environment' output." > + > + ;; LaTeX environment > + (should > + (equal (string-join > + (list "@displaymath" > + "\\begin{equation}" > + "a ^ 2 =3D b" > + "b ^ 2 =3D c" > + "\\end{equation}" > + "@end displaymath") > + "\n") > + (org-texinfo-latex-environment > + (org-element-create 'latex-environment > + (list :value > + (string-join > + (list "\\begin{equation}" > + "a ^ 2 =3D b" > + "b ^ 2 =3D c" > + "\\end{equation}") > + "\n"))) > + nil > + '(:with-latex t)))) > + > + ;; LaTeX environment, indented > + (should > + (equal (string-join > + (list "@displaymath" > + "\\begin{equation}" > + "a ^ 2 =3D b" > + "b ^ 2 =3D c" > + "\\end{equation}" > + "@end displaymath") > + "\n") > + (org-texinfo-latex-environment > + (org-element-create 'latex-environment > + (list :value > + (string-join > + (list " \\begin{equation}" > + " a ^ 2 =3D b" > + " b ^ 2 =3D c" > + " \\end{equation}") > + "\n"))) > + nil > + '(:with-latex t))))) > + > +(provide 'test-ox-texinfo) > +;;; test-ox-texinfo.el end here > --=20 > 2.35.1 > > > Rudy > --=20 > "'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and > if it were so, it would be; but as it isn't, it ain't. That's logic.'" > -- Lewis Carroll, Through the Looking Glass, 1871/1872 > > Rudolf Adamkovi=C4=8D [he/him] > Studenohorsk=C3=A1 25 > 84103 Bratislava > Slovakia --=20 "It is no paradox to say that in our most theoretical moods we may be nearest to our most practical applications." -- Alfred North Whitehead, 1861-1947 Rudolf Adamkovi=C4=8D [he/him] Studenohorsk=C3=A1 25 84103 Bratislava Slovakia