[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export
From: |
Nicolas Goaziou |
Subject: |
Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export |
Date: |
Mon, 03 May 2021 18:13:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Hello,
Timothy <tecosaur@gmail.com> writes:
> I anticipate that this change may be somewhat contentions because ox-md
> explicitly follows only the original Markdown spec from 2003, however
> I've thought this over and come to the conclusion that this change is
> still in keeping with that, and beneficial.
>
> Currently ox-md simply inherits the output from ox-html's handling of
> LaTeX snippets. Needless to say, the original Markdown specification
> does not mention LaTeX snippets. As such, by subtly tweaking the output
> (either adding $$ or substituting out LaTeX-style \(\) / \[\] for $ /
> $$) we are not deviating from the original specification any more than we
> already are.
This sounds reasonable.
> +(defun org-md-latex-environment (latex-environment contents info)
> + "Transcode a LATEX-ENVIRONMENT object from Org to Markdown.
> +CONTENTS is nil. INFO is a plist holding contextual information."
> + (when (plist-get info :with-latex)
> + (concat "$$\n"
> + (org-html-latex-environment latex-environment contents info)
> + "$$\n")))
Nitpick: I would use `format', also the final newline character is
useless, since it will be removed later during the export process.
> +;;;; Latex Fragment
> +
> +(defun org-md-latex-fragment (latex-fragment contents info)
> + "Transcode a LATEX-FRAGMENT object from Org to Markdown.
> +CONTENTS is nil. INFO is a plist holding contextual information."
> + (when (plist-get info :with-latex)
> + (let ((frag (org-html-latex-fragment contents info)))
> + (cond
> + ((string-match-p "^\\\\(" frag)
> + (concat "$" (substring frag 2 -2) "$"))
> + ((string-match-p "^\\\\\\[" frag)
> + (concat "$$" (substring frag 2 -2) "$$"))
> + (t (message "unrecognised fragment: %s" frag)
> + frag)))))
Nitpick: I suggest to use `rx' macro. It really makes the code base
a better place.
You are missing some cases. The fragment could be $...$ or $$...$$
already, so you can return it as-is without sending the message.
Otherwise, it is a macro. We can assume it lives outside math mode. So
maybe the "Unrecognized fragment: %S" is in order in that situation. We
could also let HTML export back-end deal with it. I don't know what is
better.
WDYT?
Regards,
--
Nicolas Goaziou
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Timothy, 2021/05/02
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Timothy, 2021/05/02
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export,
Nicolas Goaziou <=
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Timothy, 2021/05/03
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Nicolas Goaziou, 2021/05/03
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Timothy, 2021/05/03
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Nicolas Goaziou, 2021/05/04
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Timothy, 2021/05/04
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Nicolas Goaziou, 2021/05/06
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Timothy, 2021/05/09
- Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export, Nicolas Goaziou, 2021/05/10