Function: org-texinfo-supports-math-p

org-texinfo-supports-math-p is a byte-compiled function defined in ox-texinfo.el.gz.

Signature

(org-texinfo-supports-math-p)

Documentation

Return t if the installed version of Texinfo supports "@math".

Once computed, the results remain cached.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-texinfo.el.gz
(defun org-texinfo-supports-math-p ()
  "Return t if the installed version of Texinfo supports \"@math\".

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 (string-join
                                   (list (format "@setfilename %s" input-file)
                                         "@node Top"
                                         "@displaymath"
                                         math-example
                                         "@end displaymath")
                                   "\n")))
              (with-temp-file input-file
                (insert input-content))
              (when-let* ((output-file
                           ;; If compilation fails, consider math to
                           ;; be not supported.
                           (ignore-errors (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)