From: "Rudolf Adamkovič" <salutis@me.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Re: No mathematics in Texinfo exports
Date: Wed, 20 Apr 2022 22:14:16 +0200 [thread overview]
Message-ID: <m2h76nv7fr.fsf@me.com> (raw)
In-Reply-To: <m24k3kae9a.fsf@me.com>
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č <salutis@me.com> writes:
> Rudolf Adamkovič <salutis@me.com> writes:
>
>> […], or do I have to tackle the problem myself? I would appreciate
>> 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: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
> 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 contextual information."
> (concat "@listoffloats "
> (org-export-translate "Listing" :utf-8 info))))))))
>
> +;;;; 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
>
> (defun org-texinfo-line-break (_line-break _contents _info)
> diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.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č
> +
> +;; Author: Rudolf Adamkovič <salutis@me.com>
> +
> +;; 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 <https://www.gnu.org/licenses/>.
> +
> +;;; 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 = b}"
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + '(:value "$a^2 = b$"))
> + nil
> + '(:with-latex t))))
> +
> + ;; inline TeX fragment, padded
> + (should
> + (equal "@math{a^2 = b}"
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + '(:value "$ a^2 = b $"))
> + nil
> + '(:with-latex t))))
> +
> + ;; inline LaTeX fragment
> + (should
> + (equal "@math{a^2 = b}"
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + '(:value "\\(a^2 = b\\)"))
> + nil
> + '(:with-latex t))))
> +
> + ;; inline LaTeX fragment, padded
> + (should
> + (equal "@math{a^2 = b}"
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + '(:value "\\( a^2 = b \\)"))
> + nil
> + '(:with-latex t))))
> +
> + ;; displayed TeX fragment, inline
> + (should
> + (equal (string-join
> + (list ""
> + "@displaymath"
> + "a ^ 2 = b"
> + "@end displaymath"
> + "")
> + "\n")
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + (list :value "$$a ^ 2 = b$$"))
> + nil
> + '(:with-latex t))))
> +
> + ;; displayed TeX fragment, inline, padded
> + (should
> + (equal (string-join
> + (list ""
> + "@displaymath"
> + "a ^ 2 = b"
> + "@end displaymath"
> + "")
> + "\n")
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + (list :value "$$ a ^ 2 = b $$"))
> + nil
> + '(:with-latex t))))
> +
> + ;; displayed TeX fragment, multi-line
> + (should
> + (equal (string-join
> + (list ""
> + "@displaymath"
> + "a ^ 2 = b"
> + "b ^ 2 = c"
> + "@end displaymath"
> + "")
> + "\n")
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + (list :value
> + (string-join
> + (list "$$"
> + "a ^ 2 = b"
> + "b ^ 2 = c"
> + "$$")
> + "\n")))
> + nil
> + '(:with-latex t))))
> +
> + ;; displayed TeX fragment, multi-line, indented
> + (should
> + (equal (string-join
> + (list ""
> + "@displaymath"
> + "a ^ 2 = b"
> + "b ^ 2 = c"
> + "@end displaymath"
> + "")
> + "\n")
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + (list :value
> + (string-join
> + (list " $$"
> + " a ^ 2 = b"
> + " b ^ 2 = c"
> + " $$")
> + "\n")))
> + nil
> + '(:with-latex t))))
> +
> + ;; displayed LaTeX fragment, inline
> + (should
> + (equal (string-join
> + (list ""
> + "@displaymath"
> + "a ^ 2 = b"
> + "@end displaymath"
> + "")
> + "\n")
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + (list :value "\\[a ^ 2 = b\\]"))
> + nil
> + '(:with-latex t))))
> +
> + ;; displayed LaTeX fragment, inline, padded
> + (should
> + (equal (string-join
> + (list ""
> + "@displaymath"
> + "a ^ 2 = b"
> + "@end displaymath"
> + "")
> + "\n")
> + (org-texinfo-latex-fragment
> + (org-element-create 'latex-fragment
> + (list :value "\\[ a ^ 2 = 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 = b"
> + "b ^ 2 = c"
> + "\\end{equation}"
> + "@end displaymath")
> + "\n")
> + (org-texinfo-latex-environment
> + (org-element-create 'latex-environment
> + (list :value
> + (string-join
> + (list "\\begin{equation}"
> + "a ^ 2 = b"
> + "b ^ 2 = c"
> + "\\end{equation}")
> + "\n")))
> + nil
> + '(:with-latex t))))
> +
> + ;; LaTeX environment, indented
> + (should
> + (equal (string-join
> + (list "@displaymath"
> + "\\begin{equation}"
> + "a ^ 2 = b"
> + "b ^ 2 = c"
> + "\\end{equation}"
> + "@end displaymath")
> + "\n")
> + (org-texinfo-latex-environment
> + (org-element-create 'latex-environment
> + (list :value
> + (string-join
> + (list " \\begin{equation}"
> + " a ^ 2 = b"
> + " b ^ 2 = c"
> + " \\end{equation}")
> + "\n")))
> + nil
> + '(:with-latex t)))))
> +
> +(provide 'test-ox-texinfo)
> +;;; test-ox-texinfo.el end here
> --
> 2.35.1
>
>
> 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
--
"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č <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
next prev parent reply other threads:[~2022-04-20 20:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-25 7:45 No mathematics in Texinfo exports Rudolf Adamkovič
2022-03-26 16:07 ` [PATCH] " Rudolf Adamkovič
2022-04-20 20:14 ` Rudolf Adamkovič [this message]
2022-04-21 6:11 ` Ihor Radchenko
2022-04-21 7:31 ` Nicolas Goaziou
2022-04-21 9:59 ` Ihor Radchenko
2022-04-21 11:20 ` Nicolas Goaziou
2022-04-21 13:36 ` Ihor Radchenko
2022-05-15 19:37 ` Rudolf Adamkovič
2022-05-16 2:17 ` Ihor Radchenko
2022-05-20 12:52 ` Rudolf Adamkovič
2022-05-23 11:30 ` Rudolf Adamkovič
2022-05-23 11:37 ` Ihor Radchenko
2022-05-27 7:04 ` Rudolf Adamkovič
2022-05-28 2:42 ` Ihor Radchenko
2022-06-05 9:08 ` Rudolf Adamkovič
2022-06-05 12:22 ` Ihor Radchenko
2022-06-15 20:26 ` Rudolf Adamkovič
2022-06-19 8:23 ` Ihor Radchenko
2022-06-24 19:33 ` Rudolf Adamkovič
2022-06-25 5:51 ` Ihor Radchenko
2022-08-14 19:28 ` Rudolf Adamkovič
2022-08-19 4:48 ` Ihor Radchenko
2022-09-16 21:50 ` Rudolf Adamkovič
2022-09-21 7:33 ` Ihor Radchenko
2022-09-21 20:36 ` 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=m2h76nv7fr.fsf@me.com \
--to=salutis@me.com \
--cc=emacs-orgmode@gnu.org \
/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).