From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: patch: add custom latex->html conversion command Date: Mon, 17 Feb 2020 01:23:25 +0100 Message-ID: <87k14mdptu.fsf@gnu.org> References: <87blpz1c29.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:60286) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3UC7-0007Gs-94 for emacs-orgmode@gnu.org; Sun, 16 Feb 2020 19:23:28 -0500 In-Reply-To: <87blpz1c29.fsf@gmail.com> (Matt Huszagh's message of "Sat, 15 Feb 2020 18:49:18 -0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: Matt Huszagh Cc: "emacs-orgmode@gnu.org" Hi Matt, Matt Huszagh writes: > From 056d23d9e5caa6fc22907014e0128519fcc84b6e Mon Sep 17 00:00:00 2001 > From: Matt Huszagh > Date: Sat, 15 Feb 2020 18:42:11 -0800 > Subject: [PATCH] add custom command option when converting latex fragments to > html > > This allows you to set a custom command > `org-latex-to-html-convert-command' that will take as input a latex > fragment and use it to generate html for export. This is very > open-ended in the sense that you can use any shell-command you want. I > envisioned this for use with latexml, but there's nothing preventing > you from using something else. The commit message needs to be formatted using the Emacs changelog format. See `add-change-log-entry-other-window' on how to add a changelog entry from a patch (or from magit's diff view). > --- > lisp/org.el | 30 ++++++++++++++++++++++++++++++ > lisp/ox-html.el | 9 +++++++-- > 2 files changed, 37 insertions(+), 2 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 97ce7ec43..94557bf86 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -3203,6 +3203,22 @@ When using LaTeXML set this option to > (const :tag "None" nil) > (string :tag "\nShell command"))) > > +(defcustom org-latex-to-html-convert-command nil > + "Command to convert LaTeX fragments to HTML. > +This command is very open-ended: the output of the command will > +directly replace the latex fragment in the resulting HTML. > +Replace format-specifiers in the command as noted below and use > +`shell-command' to convert LaTeX to HTML. > +%i: The latex fragment to be converted. > + > +For example, this could be used with LaTeXML as > +\"latexmlc 'literal:%i' --profile=math --preload=siunitx.sty 2>/dev/null\"." > + :group 'org-latex > + :version "26.1" No need for :version "26.1" (which is false). Better add :package-version '(Org . "9.5") for when this will be in 9.5. > + :type '(choice > + (const :tag "None" nil) > + (string :tag "\nShell command"))) ^ missing value ? > +(defun org-format-latex-as-html (latex-frag) > + "Convert latex to html with a custom conversion command. > +`LATEX-FRAG' is the latex fragment > +Set the custom command with `org-latex-to-html-convert-command'." > + (let ((cmd (format-spec > + org-latex-to-html-convert-command > + `((?i . ,latex-frag))))) ^ indentation looks weird. Otherwise it looks good. Thanks! -- Bastien