From: Thibault Marin <thibault.marin@gmx.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: ox-md: Export links to equations for use with MathJax
Date: Sat, 10 Feb 2018 23:21:53 -0600 [thread overview]
Message-ID: <87d11cdrta.fsf@dell-desktop.WORKGROUP> (raw)
[-- Attachment #1: Type: text/plain, Size: 588 bytes --]
Hi list,
Similar to a change introduced recently to ox-html (ba6c0f1ea9), I'd
like to be able to export (in markdown, using ox-md.el) links to LaTeX
equations with "\eqref{org0000000}" and rely on MathJax for rendering
instead of the default markdown format ("[description][#org0000000]").
The attached patch is my first attempt at this. It is almost identical
to the ox-html version. I have added an option to select which mode to
use (markdown or MathJax).
Could this patch be considered for a merge? Please let know if there
are any suggestions or comments.
Thanks,
thibault
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-md.el-Add-option-to-export-equation-links-to-eqre.patch --]
[-- Type: text/x-diff, Size: 3647 bytes --]
From bf03749fe18726f43684d0818a75a2affbe3e546 Mon Sep 17 00:00:00 2001
From: thibault <thibault.marin@gmx.com>
Date: Sat, 10 Feb 2018 22:58:35 -0600
Subject: [PATCH] ox-md.el: Add option to export equation links to "\eqref"
(MathJax)
* lisp/ox-md.el (org-md-link): Export link to LateX equation as
"\eqref" (for use with MathJax) when the new option `:md-link-mathjax'
is non-nil.
(org-export-define-derived-backend 'md): Add new option
`:md-link-mathjax' to control the export of equation links. Its value
is set to that of the new customization variable `org-md-link-mathjax'.
(org-md-link-mathjax): Add customization variable to enable export to
MathJax "\eqref" (disabled by default).
---
lisp/ox-md.el | 45 +++++++++++++++++++++++++++++++++------------
1 file changed, 33 insertions(+), 12 deletions(-)
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index e2a000bd0..575499072 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -70,6 +70,17 @@ The %s will be replaced by the footnote reference itself."
:version "26.1"
:package-version '(Org . "9.0"))
+;;;; Links
+
+(defcustom org-md-link-mathjax nil
+ "Non-nil means process LaTeX equation links for MathJax.
+
+When non-nil, links to LaTeX equations will be exported to \"\\eqref\"."
+
+ :group 'org-export-md
+ :package-version '(Org . "9.2")
+ :type 'boolean)
+
\f
;;; Define Back-End
@@ -111,7 +122,8 @@ The %s will be replaced by the footnote reference itself."
:options-alist
'((:md-footnote-format nil nil org-md-footnote-format)
(:md-footnotes-section nil nil org-md-footnotes-section)
- (:md-headline-style nil nil org-md-headline-style)))
+ (:md-headline-style nil nil org-md-headline-style)
+ (:md-link-mathjax nil nil org-md-link-mathjax)))
\f
;;; Filters
@@ -419,17 +431,26 @@ a communication channel."
(or (org-element-property :CUSTOM_ID destination)
(org-export-get-reference destination info))))
(_
- (let ((description
- (or (org-string-nw-p contents)
- (let ((number (org-export-get-ordinal destination info)))
- (cond
- ((not number) nil)
- ((atom number) (number-to-string number))
- (t (mapconcat #'number-to-string number ".")))))))
- (when description
- (format "[%s](#%s)"
- description
- (org-export-get-reference destination info))))))))
+ (if (and destination
+ (plist-get info :md-link-mathjax)
+ (eq 'latex-environment (org-element-type destination))
+ (eq 'math (org-latex--environment-type destination)))
+ ;; Caption and labels are introduced within LaTeX
+ ;; environment. Use "eqref" macro to refer to those in
+ ;; the document.
+ (format "\\eqref{%s}"
+ (org-export-get-reference destination info))
+ (let ((description
+ (or (org-string-nw-p contents)
+ (let ((number (org-export-get-ordinal destination info)))
+ (cond
+ ((not number) nil)
+ ((atom number) (number-to-string number))
+ (t (mapconcat #'number-to-string number ".")))))))
+ (when description
+ (format "[%s](#%s)"
+ description
+ (org-export-get-reference destination info)))))))))
((org-export-inline-image-p link org-html-inline-image-rules)
(let ((path (let ((raw-path (org-element-property :path link)))
(cond ((not (equal "file" type)) (concat type ":" raw-path))
--
2.15.1
next reply other threads:[~2018-02-11 5:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-11 5:21 Thibault Marin [this message]
2018-02-12 14:16 ` ox-md: Export links to equations for use with MathJax Nicolas Goaziou
2018-02-13 2:49 ` Thibault Marin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d11cdrta.fsf@dell-desktop.WORKGROUP \
--to=thibault.marin@gmx.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.