From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id iFEqGtbvJGPQrAAAbAwnHQ (envelope-from ) for ; Fri, 16 Sep 2022 23:51:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id eGpJGtbvJGOayAAA9RJhRA (envelope-from ) for ; Fri, 16 Sep 2022 23:51:18 +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 D20B639BFD for ; Fri, 16 Sep 2022 23:51:17 +0200 (CEST) Received: from localhost ([::1]:32838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZJEy-0005Bs-By for larch@yhetil.org; Fri, 16 Sep 2022 17:51:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZJEC-0005Bj-Gz for emacs-orgmode@gnu.org; Fri, 16 Sep 2022 17:50:28 -0400 Received: from mr85p00im-ztdg06021101.me.com ([17.58.23.180]:41352) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZJE8-0002YX-Vg for emacs-orgmode@gnu.org; Fri, 16 Sep 2022 17:50:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1663365021; bh=dq40ahww9ydImRJ+QGFpgiAk0fN+ddLdAnnRpJiXjuc=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=S4WbELh/0OGwJEUdWDI8Z/D2OJwSGPuW6wi+PXWrl6R4gbgWyTqgDKs20qwRnI+t9 9ee6SKPjvvyXBwkNnR1C3GJe59uSaxGTtgsP4Q5JOOJdlIPqmkVWuL3QG1FKOM9QFO JZsUg0ftP/tii6DVNjpSnqRgWKu3GaiKRZcNIHxioFL09LJbI0XH4nZUUkCr7l0kJ5 +ib1WL9tMItfNtPbacBLCm0r63PasEuLAEpOIMebHqPst6VFC2Ez1MiMcWCq2itikm nOqIn+ID7CFQu6+ff4SqKwkdShEcH0iJwdicX9WDKNBxxVyHLPop0Ngs9Ld+AR5YfX YfTUPm3HGknCQ== Received: from Rudolfs-MacBook-Air.local (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-ztdg06021101.me.com (Postfix) with ESMTPSA id D975880AFA; Fri, 16 Sep 2022 21:50:19 +0000 (UTC) From: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= To: Ihor Radchenko Cc: Nicolas Goaziou , emacs-orgmode@gnu.org Subject: Re: [PATCH] Re: No mathematics in Texinfo exports In-Reply-To: <87pmgwq1np.fsf@localhost> References: <87o80v3qzw.fsf@localhost> <87mtgedh98.fsf@nicolasgoaziou.fr> <87a6cezrhm.fsf@localhost> <87bkwud6ni.fsf@nicolasgoaziou.fr> <87czhazhfz.fsf@localhost> <87k0amb4qf.fsf@localhost> <87v8twscml.fsf@localhost> <874k1ae5tz.fsf@localhost> <87bkv75mgo.fsf@localhost> <87edzlxdsq.fsf@localhost> <87pmgwq1np.fsf@localhost> Date: Fri, 16 Sep 2022 23:50:16 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Proofpoint-GUID: q-rHmD-YADC-xDs7v43jX1FHxAASjQ1w X-Proofpoint-ORIG-GUID: q-rHmD-YADC-xDs7v43jX1FHxAASjQ1w X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.138,18.0.572,17.11.62.513.0000000_definitions?= =?UTF-8?Q?=3D2020-02-14=5F11:2020-02-14=5F02,2020-02-14=5F11,2021-12-02?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2209160155 Received-SPF: pass client-ip=17.58.23.180; envelope-from=salutis@me.com; helo=mr85p00im-ztdg06021101.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, 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-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=1663365078; 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=34zuj6MngyE34ctW6XDLXut+46oZOuzqyb5NWSf8G+8=; b=MvLhW07hTLMKtEQOP2XY9S6asNdYLkqd0Z0unM9z6yBuXWV3ki1IOdKNoJTd/PT/dfAu1J axVTgmp7r9zlma9XyxE8MGa/FokbdvZeYGtag8KLJxG5HN7EsIiINWvF/34m4ku62GZCnr 1F5SUlWqfg2UZV8XccWkGikF8/UF1R1pApH5SUDwh06O5pWkEeWRN77U3/F8ZIEQvJh4fB oluZrJWCingYBOnktmfxzIXlqhOqzMArjTw0E37ODTu6tEMSzMb0wSqkU0+M1Pwy1o0ug2 N/TAAud0JyOsjS1bQDxpIQqZDBXx4LfPtT61oYcoDEYaKgWfq0z4fIYeJHdLyQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663365078; a=rsa-sha256; cv=none; b=k7IZug23idhepyLRlGsOqRSGYn6XWJEVr8kkbYTwLYnasSHOENeT6XV22hWhJseneaK61N nahnmthUm9cTs6/Wkg+UiLfVl24fxeaBsnHwhr68NbmrHwbNtDdxYW6XM1SP9p+FuYOPwC lND9UsdXXE5fLcL2ugpqpoRxuCuBJ3u+7gzM8OWYbK6Lso3B0RDGdyO29h0PepvqQjykd3 83kQHuoxTT2FUc2FYrYng550PjWdabQD4DRY+2TlbEFPJpCVdyUMkN4etRbs0UGkO+Kj7t EiEqpdK/WpcV6VK34ZoI/mWcjHCctpvgzBMrwWD7s9xbfQ28UOpRsxh/QoYB5Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=me.com header.s=1a1hai header.b="S4WbELh/"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=me.com (policy=quarantine); 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.00 X-Spam: Yes Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=me.com header.s=1a1hai header.b="S4WbELh/"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=me.com (policy=quarantine); 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: D20B639BFD X-Spam-Score: 6.00 X-Migadu-Spam: Yes X-Migadu-Scanner: scn1.migadu.com X-TUID: iEsvTp70AW2J --=-=-= Content-Type: text/plain Ihor Radchenko writes: > [snip] Please see the attached patch where I attempt to fix every issue you pointed out. I also split the tests into smaller functions for better maintainability. Please, let me know what you think about my latest attempt. Thank you for your guidance! Rudy --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-ox-texinfo-Include-LaTeX-in-Texinfo-exports.patch Content-Transfer-Encoding: quoted-printable >From dd07f22269f64bb2c688853543e137355178c2b3 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-with-latex): New customize. * lisp/ox-texinfo.el (org-texinfo-latex-environment): New function. * lisp/ox-texinfo.el (org-texinfo-latex-fragment): New function. * lisp/ox-texinfo.el (org-texinfo-supports-math-p): New function. * lisp/ox-texinfo.el (org-texinfo-supports-math--cache): New variable. * 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. --- etc/ORG-NEWS | 7 + lisp/ox-texinfo.el | 95 +++++++++- testing/lisp/test-ox-texinfo.el | 296 ++++++++++++++++++++++++++++++++ 3 files changed, 396 insertions(+), 2 deletions(-) create mode 100644 testing/lisp/test-ox-texinfo.el diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index a7f32671e..e51bb6233 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -489,6 +489,13 @@ support in LaTeX. The new =3Dbabel=3D syntax for load= ing languages via =3Dini=3D files and the new command =3D\babelprovide=3D (see: https://mirrors.ctan.org/macros/latex/required/babel/base/babel.pdf) are also supported. +*** Texinfo exports include LaTeX + +With the new customization option ~org-texinfo-with-latex~ set to (its +default value) ~'detect~, if the system runs Texinfo 6.8 (3 July 2021) +or newer, Org will export all LaTeX fragments and environments using +Texinfo ~@math~ and ~@displaymath~ commands respectively. + * Version 9.5 =20 ** Important announcements and breaking changes diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 623c1632c..a2959d027 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -33,7 +33,7 @@ (require 'ox) =20 (defvar orgtbl-exp-regexp) - +(defvar org-texinfo-supports-math--cache) =20 ;;; Define Back-End @@ -58,6 +58,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) @@ -123,7 +125,9 @@ (:texinfo-text-markup-alist nil nil org-texinfo-text-markup-alist) (:texinfo-format-drawer-function nil nil org-texinfo-format-drawer-fun= ction) (:texinfo-format-inlinetask-function nil nil org-texinfo-format-inline= task-function) - (:texinfo-compact-itemx nil "compact-itemx" org-texinfo-compact-itemx)= )) + (:texinfo-compact-itemx nil "compact-itemx" org-texinfo-compact-itemx) + ;; Redefine regular options. + (:with-latex nil "tex" org-texinfo-with-latex))) =20 ;;; User Configurable Variables @@ -358,6 +362,22 @@ The function should return the string to be exported." :group 'org-export-texinfo :type 'function) =20 +;;;; LaTeX + +(defcustom org-texinfo-with-latex (and org-export-with-latex 'detect) + "If non-nil, the Texinfo exporter attempts to process LaTeX math. + +When set to t, the exporter will process LaTeX environments and +fragments as Texinfo \"@displaymath\" and \"@math\" commands +respectively. Alternatively, when set to `detect', the exporter +does so only if the installed version of Texinfo supports the +necessary commands." + :group 'org-export-texinfo + :type '(choice + (const :tag "Detect" detect) + (const :tag "Yes" t) + (const :tag "No" nil))) + ;;;; Itemx =20 (defcustom org-texinfo-compact-itemx nil @@ -1215,6 +1235,52 @@ CONTENTS is nil. INFO is a plist holding contextual= information." (concat "@listoffloats " (org-export-translate "Listing" :utf-8 info)))))))) =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." + (let ((with-latex (plist-get info :with-latex))) + (when (or (eq with-latex t) + (and (eq with-latex 'detect) + (org-texinfo-supports-math-p))) + (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. +INFO is a plist holding contextual information." + (let ((with-latex (plist-get info :with-latex))) + (when (or (eq with-latex t) + (and (eq with-latex 'detect) + (org-texinfo-supports-math-p))) + (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 (defun org-texinfo-line-break (_line-break _contents _info) @@ -1951,6 +2017,31 @@ Return INFO file name or an error if it couldn't be = produced." (message "Process completed.") output)) =20 +(defun org-texinfo-supports-math-p () + "Return t if the installed version of Texinfo supports \"@math\". + +Once computed, the results remains cached." + (unless (boundp 'org-texinfo-supports-math--cache) + (setq org-texinfo-supports-math--cache + (let ((math-example "1 + 1 =3D 2")) + (let* ((input-file + (make-temp-file "test" nil ".info")) + (input-content + (concat (format "@setfilename %s" input-file) "\n" + "@node Top" "\n" + (format "@displaymath{%s}" math-example) "\n")= )) + (with-temp-file input-file + (insert input-content)) + (let* ((output-file (org-texinfo-compile input-file)) + (output-content (with-temp-buffer + (insert-file-contents output-file) + (buffer-string)))) + (let ((result (string-match-p (regexp-quote math-example) + output-content))) + (delete-file input-file) + (delete-file output-file) + (if result t nil))))))) + org-texinfo-supports-math--cache) =20 (provide 'ox-texinfo) =20 diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo= .el new file mode 100644 index 000000000..51fdb3606 --- /dev/null +++ b/testing/lisp/test-ox-texinfo.el @@ -0,0 +1,296 @@ +;;; 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")) + + +;;; TeX fragments + +(ert-deftest test-ox-texinfo/tex-fragment-inline () + "Test inline TeX fragment." + (should + (equal "@math{a^2 =3D b}" + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + '(:value "$a^2 =3D b$")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/tex-fragment-inline-padded () + "Test inline TeX fragment padded with whitespace." + (should + (equal "@math{a^2 =3D b}" + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + '(:value "$ a^2 =3D b $")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/tex-fragment-displayed () + "Test displayed TeX fragment." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + (list :value "$$a ^ 2 =3D b$$")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/tex-fragment-displayed-padded () + "Test displayed TeX fragment padded with whitespace." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + (list :value "$$ a ^ 2 =3D b $$")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/tex-fragment-displayed-multi-line () + "Test displayed TeX fragment with multiple lines." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "b ^ 2 =3D c" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (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)))))) + +(ert-deftest test-ox-texinfo/tex-fragment-displayed-indented () + "Test displayed TeX fragment with indentation." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "b ^ 2 =3D c" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (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)))))) + + +;;; LaTeX fragments + +(ert-deftest test-ox-texinfo/latex-fragment-inline () + "Test inline LaTeX fragment." + (should + (equal "@math{a^2 =3D b}" + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + '(:value "\\(a^2 =3D b\\)")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/latex-fragment-inline-padded () + "Test inline LaTeX fragment padded with whitespace." + (should + (equal "@math{a^2 =3D b}" + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + '(:value "\\( a^2 =3D b \\)")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/latex-fragment-displayed () + "Test displayed LaTeX fragment." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + (list :value "\\[a ^ 2 =3D b\\]")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/latex-fragment-displayed-padded () + "Test displayed LaTeX fragment with multiple lines." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (org-texinfo-latex-fragment + (org-element-create 'latex-fragment + (list :value "\\[ a ^ 2 =3D b \\]")) + nil + '(:with-latex t)))))) + +(ert-deftest test-ox-texinfo/latex-fragment-displayed-multi-line () + "Test displayed LaTeX fragment with multiple lines." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "b ^ 2 =3D c" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (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)))))) + +(ert-deftest test-ox-texinfo/latex-fragment-displayed-indented () + "Test displayed LaTeX fragment with indentation." + (should + (equal (string-join + (list "" + "@displaymath" + "a ^ 2 =3D b" + "b ^ 2 =3D c" + "@end displaymath" + "") + "\n") + (let ((org-texinfo-with-latex t)) + (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)))))) + + +;;; LaTeX environments + +(ert-deftest test-ox-texinfo/latex-environment () + "Test LaTeX environment." + (should + (equal (string-join + (list "@displaymath" + "\\begin{equation}" + "a ^ 2 =3D b" + "b ^ 2 =3D c" + "\\end{equation}" + "@end displaymath") + "\n") + (let ((org-texinfo-with-latex t)) + (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)))))) + +(ert-deftest test-ox-texinfo/latex-environment-indented () + "Test LaTeX environment with indentation." + (should + (equal (string-join + (list "@displaymath" + "\\begin{equation}" + "a ^ 2 =3D b" + "b ^ 2 =3D c" + "\\end{equation}" + "@end displaymath") + "\n") + (let ((org-texinfo-with-latex t)) + (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.37.3 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 "Simplicity is complexity resolved." -- Constantin Br=C3=A2ncu=C8=99i, 1876-1957 Rudolf Adamkovi=C4=8D [he/him] Studenohorsk=C3=A1 25 84103 Bratislava Slovakia --=-=-=--