From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id SDibB2chkGDbVwAAgWs5BA (envelope-from ) for ; Mon, 03 May 2021 18:14:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QBAvA2chkGB2fQAAbx9fmQ (envelope-from ) for ; Mon, 03 May 2021 16:14:31 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9296629121 for ; Mon, 3 May 2021 18:14:30 +0200 (CEST) Received: from localhost ([::1]:46338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldbDJ-00023L-P9 for larch@yhetil.org; Mon, 03 May 2021 12:14:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldbCe-000239-Pm for emacs-orgmode@gnu.org; Mon, 03 May 2021 12:13:48 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:59905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldbCc-0001xe-Ld for emacs-orgmode@gnu.org; Mon, 03 May 2021 12:13:48 -0400 X-Originating-IP: 185.131.40.67 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id F41EE20002; Mon, 3 May 2021 16:13:42 +0000 (UTC) From: Nicolas Goaziou To: Timothy Subject: Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export References: <87ft0bff7q.fsf@gmail.com> Mail-Followup-To: Timothy , org-mode-email Date: Mon, 03 May 2021 18:13:40 +0200 In-Reply-To: <87ft0bff7q.fsf@gmail.com> (Timothy's message of "Thu, 01 Apr 2021 00:41:29 +0800") Message-ID: <87lf8v7q2z.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.200; envelope-from=mail@nicolasgoaziou.fr; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: org-mode-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620058470; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=dIwAAREqY4OYjuZTY8Z9i6FswDy2awE2uvDEL92JjS0=; b=X1IUJqxb1SnB/vZF2nppJoPsdWsvgByeD7ATUVLYt7s5FPdsxZdDjXicvITkyxZVtDMayr FpFT+/UtON1RLhtDPKIKHy9i8GLZDWsso+EPA6W7MqhIQJ+YzWQX8asvySDNfYMn7T4lBI DMs/ZAlDypsBF4JfBvVb8Ve0zSnbbA3uZBdz7yOPVF4XLVZW+gBQsxilZMnPWOEsy3pwHX Tk/mShlJxmuBkI3zsMzZg403wHbErkIfWfijc7C0sorDVhTnVt4lQldICjj0RfV1S+DQI+ KpfuBlnvSFktT8sc6RAfZg+NGXLmb2so+fXlj72Mx4Giwt+hFbCpxcZerj2kiw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620058470; a=rsa-sha256; cv=none; b=n+f0wFtRrCeMRYW54ukfytA6t4nBZIvCWAgdL9tx4XuDa2M2+r1rpAjy/PgBNoJ6I0KUSK Lh7gP3YdhaaMZAbfOMcQIY/LVn1wbfEUM5cwfPJx0JPJ4p6c2VoRCrq1XrBwre+iPufdhK l3P5n1XqXpNdiah/aur6M6j//mDBpeJjwf2Uwreh7D6SBDsPToi8AzzmtT3CATK4RCOaTG 7ySAxJc/fUZtft9N9GFUAkxsphLyj+fMprlMBC4/K/VXpYaHrTQ8Ht5mgXLEnpw2o0FnfW 9VSqeEe9I/3cGhwAamDcioJw4YUZaniLXI9654K4TtYLkqwKzzKcO+nt2bWFsA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.46 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 9296629121 X-Spam-Score: -1.46 X-Migadu-Scanner: scn0.migadu.com X-TUID: ZpKnVEiOX8v2 Hello, Timothy 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