emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Rudolf Adamkovič" <salutis@me.com>
To: Max Nikulin <manikulin@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
Date: Tue, 07 Feb 2023 09:39:18 +0100	[thread overview]
Message-ID: <m2sffhna2x.fsf@me.com> (raw)
In-Reply-To: <daf1768c-41e8-18f2-5c35-20a79944a930@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

Max Nikulin <manikulin@gmail.com> writes:

> Should not the format argument be corrected to have valid @displaymath 
> snippet instead?

Thank you, Max!  See, this happens when I write code 10 minutes before going to
bed: incorrect code and no tests, both equally bad.

Please see the attached patch.

Rudy

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-texinfo-Fix-invalid-syntax-in-Texinfo-version-det.patch --]
[-- Type: text/x-patch, Size: 3177 bytes --]

From ce1062dbda870346b18ae35c28e9cc034c0de548 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Mon, 6 Feb 2023 22:33:40 +0100
Subject: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection
 code

* lisp/ox-texinfo.el (org-texinfo-supports-math-p): Fix the incorrect
syntax @displaymath{1 + 1 = 2} used to detect whether Texinfo supports
TeX "math mode".  Instead, use the correct syntax @math{1 + 1 = 2}.
---
 lisp/ox-texinfo.el              | 14 ++++++++------
 testing/lisp/test-ox-texinfo.el | 30 ++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 8e3a04562..56564a5c5 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -2025,12 +2025,14 @@ Once computed, the results remain cached."
   (unless (boundp 'org-texinfo-supports-math--cache)
     (setq org-texinfo-supports-math--cache
           (let ((math-example "1 + 1 = 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")))
+            (let* ((input-file (make-temp-file "test" nil ".info"))
+                   (input-content (string-join
+                                   (list (format "@setfilename %s" input-file)
+                                         "@node Top"
+                                         "@displaymath"
+                                         math-example
+                                         "@end displaymath")
+                                   "\n")))
               (with-temp-file input-file
                 (insert input-content))
               (let* ((output-file (org-texinfo-compile input-file))
diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el
index 51fdb3606..4bb902988 100644
--- a/testing/lisp/test-ox-texinfo.el
+++ b/testing/lisp/test-ox-texinfo.el
@@ -292,5 +292,35 @@
              nil
              '(:with-latex t))))))
 
+\f
+;;; End-to-end
+
+(ert-deftest test-ox-texinfo/end-to-end-inline ()
+  "Test end-to-end with inline TeX fragment."
+  (should
+   (org-test-with-temp-text
+    "$a^2 = b$"
+    (let ((export-buffer "*Test Texinfo Export*")
+          (org-export-show-temporary-export-buffer nil))
+      (org-export-to-buffer 'texinfo export-buffer
+        nil nil nil nil nil
+        #'texinfo-mode)))))
+
+(ert-deftest test-ox-texinfo/end-to-end-sanity-check-displayed ()
+  "Test end-to-end with LaTeX environment."
+  (should
+   (org-test-with-temp-text
+    (string-join
+     (list "\\begin{equation}"
+           "a ^ 2 = b"
+           "b ^ 2 = c"
+           "\\end{equation}")
+     "\n")
+    (let ((export-buffer "*Test Texinfo Export*")
+          (org-export-show-temporary-export-buffer nil))
+      (org-export-to-buffer 'texinfo export-buffer
+        nil nil nil nil nil
+        #'texinfo-mode)))))
+
 (provide 'test-ox-texinfo)
 ;;; test-ox-texinfo.el end here
-- 
2.39.0


[-- Attachment #3: Type: text/plain, Size: 278 bytes --]

-- 
"Strange as it may sound, the power of mathematics rests on its evasion
of all unnecessary thought and on its wonderful saving of mental
operations."
-- Ernst Mach, 1838-1916

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia

  reply	other threads:[~2023-02-07  8:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06 21:42 [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code Rudolf Adamkovič
2023-02-07  2:24 ` Max Nikulin
2023-02-07  8:39   ` Rudolf Adamkovič [this message]
2023-02-07 12:13     ` Max Nikulin
2023-02-07 12:21       ` Ihor Radchenko
2023-02-07 15:13         ` Max Nikulin
2023-02-15 18:22           ` Rudolf Adamkovič
2023-02-17 10:41             ` Ihor Radchenko
2023-02-17 12:51               ` Ihor Radchenko
2023-03-24 16:37                 ` Ihor Radchenko
2023-04-01 21:22                   ` Rudolf Adamkovič

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=m2sffhna2x.fsf@me.com \
    --to=salutis@me.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).