* [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
@ 2023-02-06 21:42 Rudolf Adamkovič
2023-02-07 2:24 ` Max Nikulin
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Adamkovič @ 2023-02-06 21:42 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Rudolf Adamkovič
* 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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 8e3a04562..7ee4bc533 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -2030,7 +2030,7 @@ Once computed, the results remain cached."
(input-content
(concat (format "@setfilename %s" input-file) "\n"
"@node Top" "\n"
- (format "@displaymath{%s}" math-example) "\n")))
+ (format "@math{%s}" math-example) "\n")))
(with-temp-file input-file
(insert input-content))
(let* ((output-file (org-texinfo-compile input-file))
--
2.39.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
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č
0 siblings, 1 reply; 11+ messages in thread
From: Max Nikulin @ 2023-02-07 2:24 UTC (permalink / raw)
To: Rudolf Adamkovič, emacs-orgmode
On 07/02/2023 04:42, Rudolf Adamkovič wrote:
> --- a/lisp/ox-texinfo.el
> +++ b/lisp/ox-texinfo.el
> @@ -2030,7 +2030,7 @@ Once computed, the results remain cached."
> (input-content
> (concat (format "@setfilename %s" input-file) "\n"
> "@node Top" "\n"
> - (format "@displaymath{%s}" math-example) "\n")))
> + (format "@math{%s}" math-example) "\n")))
Should not the format argument be corrected to have valid @displaymath
snippet instead?
https://list.orgmode.org/87bkwud6ni.fsf@nicolasgoaziou.fr/
Re: [PATCH] Re: No mathematics in Texinfo exports. Thu, 21 Apr 2022
13:20:49 +0200
>> I do see @displaymath in my TeXinfo 6.8. Also,
>> https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Inserting-Math.html
>
> So it is a fairly recent addition, since Texinfo 6.8 was released last
> July. For example, it is not available in Debian stable. I don't know if
> displaymath was stealthily supported before.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-07 2:24 ` Max Nikulin
@ 2023-02-07 8:39 ` Rudolf Adamkovič
2023-02-07 12:13 ` Max Nikulin
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Adamkovič @ 2023-02-07 8:39 UTC (permalink / raw)
To: Max Nikulin, emacs-orgmode
[-- 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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-07 8:39 ` Rudolf Adamkovič
@ 2023-02-07 12:13 ` Max Nikulin
2023-02-07 12:21 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Max Nikulin @ 2023-02-07 12:13 UTC (permalink / raw)
To: Rudolf Adamkovič, emacs-orgmode
Rudolf, I am afraid there is another obstacle till your step to improve
Org may be completed.
On 07/02/2023 15:39, Rudolf Adamkovič wrote:
> - (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
In emacs-26 `string-join' is defined in subr-x.el, but ox-texinfo.el
does not have (require 'subr-x). Personally I see nothing bad in
(format "@displaymath\n%s\n@end" math-example)
Historically subr-x was avoided in Org. Latest discussion:
https://list.orgmode.org/b1eef17f-b8ef-2e2a-d463-7909b03ce6eb@gmail.com/T/#u
[BUG] Re: 98e168b48 Add compatibility wrapper for
string-clean-whitespace (Emacs 26 compatibility) Fri, 07 Oct 2022
13:14:11 +0800
I will leave the decision to the maintainers since I have no particular
opinion. Alternatively you may use (mapconcat #'identity (list) "\n").
It is preferable to fix earlier added call to `string-join' in this
file. The similar approach should be applied to the tests added by this
patch.
> + (list (format "@setfilename %s" input-file)
> + "@node Top"
> + "@displaymath"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-07 12:13 ` Max Nikulin
@ 2023-02-07 12:21 ` Ihor Radchenko
2023-02-07 15:13 ` Max Nikulin
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-02-07 12:21 UTC (permalink / raw)
To: Max Nikulin; +Cc: Rudolf Adamkovič, emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> In emacs-26 `string-join' is defined in subr-x.el, but ox-texinfo.el
> does not have (require 'subr-x). Personally I see nothing bad in
>
> (format "@displaymath\n%s\n@end" math-example)
>
> Historically subr-x was avoided in Org. Latest discussion:
> https://list.orgmode.org/b1eef17f-b8ef-2e2a-d463-7909b03ce6eb@gmail.com/T/#u
... which concluded that it is safe to use subr-x.
If we need to add a require, so be it. I see no major downsides.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-07 12:21 ` Ihor Radchenko
@ 2023-02-07 15:13 ` Max Nikulin
2023-02-15 18:22 ` Rudolf Adamkovič
0 siblings, 1 reply; 11+ messages in thread
From: Max Nikulin @ 2023-02-07 15:13 UTC (permalink / raw)
To: Rudolf Adamkovič, emacs-orgmode
On 07/02/2023 19:21, Ihor Radchenko wrote:
> Max Nikulin writes:
>>
>> Historically subr-x was avoided in Org. Latest discussion:
>> https://list.orgmode.org/b1eef17f-b8ef-2e2a-d463-7909b03ce6eb@gmail.com/T/#u
>
> ... which concluded that it is safe to use subr-x.
> If we need to add a require, so be it. I see no major downsides.
I do not mind.
Since content of subr-x.el consists of `defsubst' definitions, likely it
is preferable to use
(eval-when-compile (require 'subr-x))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-07 15:13 ` Max Nikulin
@ 2023-02-15 18:22 ` Rudolf Adamkovič
2023-02-17 10:41 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Rudolf Adamkovič @ 2023-02-15 18:22 UTC (permalink / raw)
To: Max Nikulin, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
Max Nikulin <manikulin@gmail.com> writes:
> Since content of subr-x.el consists of `defsubst' definitions, likely it
> is preferable to use
>
> (eval-when-compile (require 'subr-x))
All right, I added the 'require' to both files. Better?
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: 3545 bytes --]
From 384515548a4eb790e9b947e484dd9da41bdece94 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 | 16 ++++++++++------
testing/lisp/test-ox-texinfo.el | 32 ++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index 8e3a04562..4ff482cc3 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -32,6 +32,8 @@
(require 'cl-lib)
(require 'ox)
+(eval-when-compile (require 'subr-x))
+
(defvar orgtbl-exp-regexp)
(defvar org-texinfo-supports-math--cache)
@@ -2025,12 +2027,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..38395500d 100644
--- a/testing/lisp/test-ox-texinfo.el
+++ b/testing/lisp/test-ox-texinfo.el
@@ -24,6 +24,8 @@
(require 'cl-lib)
(require 'ox-texinfo)
+(eval-when-compile (require 'subr-x))
+
(unless (featurep 'ox-texinfo)
(signal 'missing-test-dependency "org-export-texinfo"))
@@ -292,5 +294,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: 214 bytes --]
--
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-15 18:22 ` Rudolf Adamkovič
@ 2023-02-17 10:41 ` Ihor Radchenko
2023-02-17 12:51 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-02-17 10:41 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: Max Nikulin, emacs-orgmode
Rudolf Adamkovič <salutis@me.com> writes:
> All right, I added the 'require' to both files. Better?
Thanks!
Applied, onto bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=99c8ed09f
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-17 10:41 ` Ihor Radchenko
@ 2023-02-17 12:51 ` Ihor Radchenko
2023-03-24 16:37 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-02-17 12:51 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko <yantar92@posteo.net> writes:
>> All right, I added the 'require' to both files. Better?
>
> Thanks!
> Applied, onto bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=99c8ed09f
The tests are failing on older Emacs.
https://builds.sr.ht/~bzg/job/942040
https://builds.sr.ht/~bzg/job/942041
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-02-17 12:51 ` Ihor Radchenko
@ 2023-03-24 16:37 ` Ihor Radchenko
2023-04-01 21:22 ` Rudolf Adamkovič
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-03-24 16:37 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko <yantar92@posteo.net> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>>> All right, I added the 'require' to both files. Better?
>>
>> Thanks!
>> Applied, onto bugfix.
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=99c8ed09f
>
> The tests are failing on older Emacs.
> https://builds.sr.ht/~bzg/job/942040
> https://builds.sr.ht/~bzg/job/942041
I finally managed to fix the tests.
See
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?h=bugfix&id=4c01eba265edfb910e926c5559aca5bf7d7a3650
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ox-texinfo: Fix invalid syntax in Texinfo version detection code
2023-03-24 16:37 ` Ihor Radchenko
@ 2023-04-01 21:22 ` Rudolf Adamkovič
0 siblings, 0 replies; 11+ messages in thread
From: Rudolf Adamkovič @ 2023-04-01 21:22 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko <yantar92@posteo.net> writes:
> I finally managed to fix the tests.
Thank you! I have had this on my to-do list since you brought it up,but
I could not find the time to fix it.
Rudy
--
"'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č <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-04-01 21:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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č
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č
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).