From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cNALO9Q7kGB7jAAAgWs5BA (envelope-from ) for ; Mon, 03 May 2021 20:07:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id kMq0NtQ7kGBwTgAAB5/wlQ (envelope-from ) for ; Mon, 03 May 2021 18:07:16 +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 649B02BC07 for ; Mon, 3 May 2021 20:07:16 +0200 (CEST) Received: from localhost ([::1]:56898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldcyR-0004Q0-JQ for larch@yhetil.org; Mon, 03 May 2021 14:07:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldcuW-00028Y-23 for emacs-orgmode@gnu.org; Mon, 03 May 2021 14:03:15 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:50970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldcuQ-0006b1-Cm for emacs-orgmode@gnu.org; Mon, 03 May 2021 14:03:11 -0400 Received: by mail-pj1-x102a.google.com with SMTP id md17so3602963pjb.0 for ; Mon, 03 May 2021 11:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=fk1z3mnSs2Ou6XYQpfCW9sAXSHcVRtAXB/wPN3Soarg=; b=tyCcWjgws1fLDwI5Q3hPC0UyeQuLUue8HICML0ZhYEEbn3+Lgwh8NhnPPlLF8TNgya ru3V9l6WYpUzbvhieo0cXNschRDxcw+/UOP2JPHe8FUIOZsLtZjM2o85IhkAJPbCpqfE x9OBLrDIh5pItqq59EOjEVIjZacRGv6DbQ0MN8gyXjKW4A7gFtYtV1o76zBH/LV0OHIO MiXUqRov2WZJp24fYnKEN+lQvaLc9fKPbnuyHAhyQbOEOVE3nFIUjZk7OSyShyNmNeyg /3QNzylWIdlpUi9Pkjb5mAZUdR4sC+tEBSplIJwwTPpNgaJenylddo/jpKQGwvLwvIdY UAog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=fk1z3mnSs2Ou6XYQpfCW9sAXSHcVRtAXB/wPN3Soarg=; b=ZjVu6s/nmCaHdh4o3uEb4GUfyuwTzV7D9yAvT5ZEqHN1/YSQLJwX+NF0rJQ9qlzhbL AYLCAxlYcucDAM3dnvd/Snbdg7LCvX85dj9JA//pqrmHPlo16S7hvYRItENuk1Nu9CNj pCxF+6D8RCL+HAyEm7WEB9kCncgtKHFTfUgZfpvpZMw4Ff/jshV/HmoCpxunIfnjsNRY 9zF63HB4US7/p0xb0qBL1TMpKpj0kUfYd3UnVPhRs6YZewKjEYcM9C4RhNDl86S76oUk 5me/7e78iqXS8ohNxHSverl7UkJvJpl7O1ieKMW1ms4T5dxaZPtH4KcQNFGZ5kjlI+r7 Ijcw== X-Gm-Message-State: AOAM53066TaP3t1vzcucnLjkMSy4E4hZkiytPoT0gL1GDmEt4GvehXPK mGGuKgPXU4AbCmfV23lVKXZ2umN/3EaOcw== X-Google-Smtp-Source: ABdhPJzeATdAhIcDu9d5Z1bjPwM2yhSxtiFgVsOoZf8Tj6I58RmcWC9+N9PdWBiJpv3VJ+lpldfHqA== X-Received: by 2002:a17:90a:d78c:: with SMTP id z12mr31831834pju.106.1620064984066; Mon, 03 May 2021 11:03:04 -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 q194sm6895350pfc.62.2021.05.03.11.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 11:03:03 -0700 (PDT) References: <87ft0bff7q.fsf@gmail.com> <87lf8v7q2z.fsf@nicolasgoaziou.fr> User-agent: mu4e 1.4.15; emacs 28.0.50 From: Timothy To: Nicolas Goaziou Subject: Re: [PATCH] Wrap LaTeX snippets in $$ with markdown export In-reply-to: <87lf8v7q2z.fsf@nicolasgoaziou.fr> Message-ID: <87h7jjitkb.fsf@gmail.com> Date: Tue, 04 May 2021 02:03:00 +0800 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=tecosaur@gmail.com; helo=mail-pj1-x102a.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: , 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=1620065236; 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:dkim-signature; bh=fk1z3mnSs2Ou6XYQpfCW9sAXSHcVRtAXB/wPN3Soarg=; b=Lf0rjJ2Opq/I3fJ7kaQvBCpyCQiCiemN/GJFLG9qrbpwJgTP+9ts+eZ9zVwZMtQj8N6z/m MXM1JxJLY5IGIl2BPSolTSQRwYqqD/vHKGTi14a9EDMRgucjsksQ2OkKkSnvPglE0/uvoy CMiOY7awK4kLvMQlTMFWH7y+WDRZTHPr7RQFiOir1SssOCQURoEjDt8rpphdEsx+tqCcXs LZ6EHJzDHcBMGO1CBZj8meXGJpbA+/tTKA2/2Kosdasgmbjbcjr6PJLbiVbK7MDF3Y3hPT WG+4tFHEcSOnSGVXrcTKis4/EW8ZKR0Odd9mcdNHuJiIW4yl9H3ZZvc2sO3iIg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620065236; a=rsa-sha256; cv=none; b=BO7MX8vLW+QpV7l3V8yRLSGQsAzEkmY9IniI/oP6U9UR+P7fiUk35AhridfSwkv9lBFUKU l38S3UFh7OZuDNA7/xq0igRlsvnR+q1mvVxdVeWtMZa2pvdI3nRFiFTck3g/q8PWrjwogC UBt2WD0zaFJnMiHfwwglhiesXLo5xxv2V24uzCzBghEajyhqrSwUpHYzsABeAo4K3JpvE0 C49iYz0ercKqvcU7ZYqcnrJ07zjywk64S9rBgqkvDcIQNurvJw2mxtCJHJV11SsLkVNpys Rv72H4mGt9B5qyFE6i/39SFv37L9f20kW+aEQdtYMAR6cEoiX2muAOh5aoUHyQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=tyCcWjgw; 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.16 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=tyCcWjgw; 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: 649B02BC07 X-Spam-Score: -2.16 X-Migadu-Scanner: scn0.migadu.com X-TUID: HsylYR5PntR6 Nicolas Goaziou writes: > This sounds reasonable. I'm glad to hear that! >> +(defun org-md-latex-environment [...] > Nitpick: I would use `format', also the final newline character is > useless, since it will be removed later during the export process. Actually, since writing this patch I'm not sure that $$-surrounding \begin{}...\end{} environments is also a good idea. I'm inclined to leave this out of the patch. >> +;;;; 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. I do rather like the `rx' macro, however I'm not sure that (rx bol "\\(") is really an improvement over "^\\\\(" in this particular case. > You are missing some cases. The fragment could be $...$ or $$...$$ > already, so you can return it as-is without sending the message. Ah yep, after getting your thoughts on this message I'll send a revised patch with fixes this (along with any other changes). > 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. I'm not sure what to do here either. Perhaps nothing/HTML backend? Finally, I think if this case (lone macro) is handled, there aren't any possible "Unrecognized fragment"s that could be passed, and so that condition would no longer be necessary? -- Timothy.