From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KFFtMtamZGCRegEAgWs5BA (envelope-from ) for ; Wed, 31 Mar 2021 18:44:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QCgvLNamZGCbEQAA1q6Kng (envelope-from ) for ; Wed, 31 Mar 2021 16:44:06 +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 40B9519A38 for ; Wed, 31 Mar 2021 18:44:06 +0200 (CEST) Received: from localhost ([::1]:52762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRdwr-0003pN-2H for larch@yhetil.org; Wed, 31 Mar 2021 12:44:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRduV-0002am-9p for emacs-orgmode@gnu.org; Wed, 31 Mar 2021 12:41:39 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:37697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRduR-0008F7-2R for emacs-orgmode@gnu.org; Wed, 31 Mar 2021 12:41:38 -0400 Received: by mail-pg1-x52f.google.com with SMTP id k8so5429963pgf.4 for ; Wed, 31 Mar 2021 09:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:date:mime-version; bh=PLBteLm4r83chXmDr7xdMPsOa1PKI05MmdDeSj8K3dY=; b=Y+5wYVS/uaSRaUKDF8UKEjieAdfcBEVZmzg8GEmqEVbfiBQ2xKZUoSZBMalIbXnouk cKaKlf+crC6WB2DzhB72eyCXDVeghT+tcMMv2NeonGcsSYb/+HBl4PRXiNj7anUcqrRx Ir2vXoBrReNN+b1BUz8loiRxBOHgi7WaFkq4W+z285KA5sfouc5VXyzkuG2qzd1xF5zN jBOXDHylXAypOVnoPvCay1pFW7JjDPp7U5p5k6zlp97WXDadZT0pQp9n/NU1AklWItcj +OTHuEHYNQAIOXKkbbmXoAiszhvmMg+X/2zq9CtYgQz4GnfSY6fzotJPqLKPnMuOLKlT qxiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version; bh=PLBteLm4r83chXmDr7xdMPsOa1PKI05MmdDeSj8K3dY=; b=aerXPAhPXkkAAShZIzUw0a3B7qvulKWQGRB2rpRgWU6M6nnef87YGC3sSyYSU6nCGa 0d5Q5dK822HaPxBIFCCHXH6pi+eCyXE+PmkjkA0ybgAZG2RalSLh1M8hvVWjLbc0PLhZ Bl1dNbrI55wpXpaAPohovGi0Qczo8w4w6dB789sm6kUckqoKmBn6mZMgmpDkkDEFqg67 0wCf6JgU5p68h/GKHYSTX5VkBxQBGn00JE+hAQkDRTtUmIamdAYScsxTLZHlgf6N0NpG d33hHEyCdMSNpYI4YAwHaCEzL8yRTM8FtJeIanhznpksDNBGvsFqf3UEsJ/qNg3j2IPG fhfw== X-Gm-Message-State: AOAM532tBk+Xnq+oDImYRqFUur1ZaIAi6SXNcHGF6T2KmEQZgUj2uq6f M4S48GHxmJ3RB2V5jeBN/3XBUBlRD1c= X-Google-Smtp-Source: ABdhPJyh9kf3K8pyqVaXC3NXvFNxVzxCw8dfwj8nb0Rs5bZkPjt3HcizEPKb5wJRAZ3HaQHvdyiF6g== X-Received: by 2002:a63:4e47:: with SMTP id o7mr3939832pgl.286.1617208893150; Wed, 31 Mar 2021 09:41:33 -0700 (PDT) Received: from localhost (180-150-91-8.b4965b.per.nbn.aussiebb.net. [180.150.91.8]) by smtp.gmail.com with ESMTPSA id w17sm2419095pfu.29.2021.03.31.09.41.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 09:41:32 -0700 (PDT) User-agent: mu4e 1.4.15; emacs 28.0.50 From: Timothy To: org-mode-email Subject: [PATCH] Wrap LaTeX snippets in $$ with markdown export Message-ID: <87ft0bff7q.fsf@gmail.com> Date: Thu, 01 Apr 2021 00:41:29 +0800 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=tecosaur@gmail.com; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , 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=1617209046; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PLBteLm4r83chXmDr7xdMPsOa1PKI05MmdDeSj8K3dY=; b=SU0xF7pAMsuKBqEv0XXOtmSyFMSCPMFarfmu4Lc3h1WwxYfIaP0o9zeDSUpJtEWPBKhMgU 6X/c/DeircESNG76p8GfEhlvJenGna57C86n2jUxC11yIHy0QQ/hLPESKtoZ3RCwU3XFkN jj+MEX5lYNJYq9dlmWtYE4rYT42wRbHSQsdXdp9ctk8yBejA+aWDiVCAtMuNu7TQR4VFtv APruX+B0u5lp8F5JtbP8i0p5E8iC3WErEAEmHruIj4Jt+TqcVqonHSanHjYcFjte1dMOtt CQgIAwiwvl1NNGbZmzP9TsRbFqrsypYSFyUJAfrxQqtCU9eBM3PguU9nI/VC7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617209046; a=rsa-sha256; cv=none; b=CzqxNYsju3JZpEI8Rn7gGsf9E12tP/ZFmLvcERum4xGxmlEN1zC4Gx4ghTetsCFtyYlon1 +7VEQpTgTBFICDwLSY3gfpUUD9ozs2x/IW28b9GxZka0Q2PJJeuiq2oVh44wGORFPHqQYF RD1adTBBCPta9A/RgUpkLkPgz+XEbLYskOCdPEEtBPwdzM7Qv6IfktrDhV4OvM/9mjgXGB /woAWM9y5+DdvD0ES4+Hh+Fk4wigP9AbBMTvkTQdcdhTLRLg7wB8KbRIupovEf6VNI+vIJ 9o3gahK3TmlkW5G0a19+zp7O0IMws6qc7NsJ40jQwrII3hOA6RTibZ9U1Fu/5g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="Y+5wYVS/"; dmarc=pass (policy=none) header.from=gmail.com; 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: -2.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="Y+5wYVS/"; dmarc=pass (policy=none) header.from=gmail.com; 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: 40B9519A38 X-Spam-Score: -2.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7pK6aydxvMoH --=-=-= Content-Type: text/plain Hi All, 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. While I don't see any issue with this, I do see some benefits. Namely that, of the many Markdown variants that now exist, many support LaTeX snippets, but exclusively in the TeX $$ form. Hence, by applying this change the overall utility of ox-md is increased. Let me know what you think, Timothy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ox-md-Use-TeX-style-math-wrapping.patch >From b7f1b89a50752398672a642519534818d23c72a4 Mon Sep 17 00:00:00 2001 From: TEC Date: Thu, 1 Apr 2021 00:25:41 +0800 Subject: [PATCH] ox-md: Use TeX-style $ math wrapping * lisp/ox-md.el (org-md-latex-environment, org-md-latex-fragment): These two new filters wrap LaTeX maths in $ / $$ TeX-style notation. While ox-md endeavours to adhere to the original Markdown specification, and not any particular variant, the original specification does not deal with LaTeX fragments at all, and so this change does not reduce how faithfully the original specification is followed. There is a major upside to this though. Of the many Markdown variants that have emerged, those that support LaTeX very often exclusively support TeX style notation. This change thus improves the utility of the Markdown export for many use cases, and deviates no more from the original specification that the current method. --- lisp/ox-md.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lisp/ox-md.el b/lisp/ox-md.el index b6b2c1728..c5c0e05a5 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -100,6 +100,8 @@ (org-export-define-derived-backend 'md 'html (italic . org-md-italic) (item . org-md-item) (keyword . org-md-keyword) + (latex-environment . org-md-latex-environment) + (latex-fragment . org-md-latex-fragment) (line-break . org-md-line-break) (link . org-md-link) (node-property . org-md-node-property) @@ -460,6 +462,32 @@ (defun org-md-keyword (keyword contents info) (_ (org-export-with-backend 'html keyword contents info)))) +;;;; Latex Environment + +(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"))) + + +;;;; 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))))) + ;;;; Line Break (defun org-md-line-break (_line-break _contents _info) -- 2.30.1 --=-=-=--