From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uEg0B9TrFWAxIQAA0tVLHw (envelope-from ) for ; Sat, 30 Jan 2021 23:29:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id oM34AtTrFWBzbgAAB5/wlQ (envelope-from ) for ; Sat, 30 Jan 2021 23:29:24 +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 62A2A9404D0 for ; Sat, 30 Jan 2021 23:29:23 +0000 (UTC) Received: from localhost ([::1]:38452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5zgA-0006uA-Az for larch@yhetil.org; Sat, 30 Jan 2021 18:29:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5zew-0006tj-O5 for emacs-orgmode@gnu.org; Sat, 30 Jan 2021 18:28:06 -0500 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:39441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5zeu-0002D6-6m for emacs-orgmode@gnu.org; Sat, 30 Jan 2021 18:28:06 -0500 Received: by mail-pf1-x435.google.com with SMTP id e19so9019680pfh.6 for ; Sat, 30 Jan 2021 15:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version; bh=O5higTd5tHmLoCaRcpP2L4MXSFe6FtS6Pw1GTmBeZZo=; b=honEjO+uhPT8ahUi/we4K9OKTZnUntmhQpBx53uwSNHcXUMzbg0BcjbsVvvKnzZZ/j vq5bfYzwGekah6BVmPeYIjAN9jn24KJO8cC7HhGSY00tgQ5ueOgyQlav4dBc1EatEOc5 RWhrCB0Xmj+sAaTJcznpJeNObbTGlPrA89w8XNItEXIb831wdwBC+FBDOV3+aaB/tnaS j0T9EdeISCJWCgD0w1A6Gap6tb3hoL3IVt2jP8OlYnd5ZhXmmE5XOpMPW3fFVGMzvsnQ m5u8bkDwpYtWV3Ehf2G54vQzLrqGJ0kpnCK7B1L2irZjry2NKB/UddE79GWcWb4mwYwj vypw== 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:subject:date :in-reply-to:message-id:mime-version; bh=O5higTd5tHmLoCaRcpP2L4MXSFe6FtS6Pw1GTmBeZZo=; b=heoqsP/JxKLaTiDD1TGGIq3gPziSvLg8to9zNLpqJAn9ZY2qUFT/PLO0OVRdBoo/Ky 8V2SdbyAORwQ7/t/tna9dZnLUyAkIxvcCl1JafjE9TccvWLboQmFs0UABQm7pgCq/W35 yulFHJUU+xvYgWhLo6tsMkrm0ziPcyDC6Au+ScpvYlrlsH/vs6dznNILBCw2jjzo+/EI dMeIi3P0d5mIRj7/q43+ERdc0rQgY9dCVyS3gMfLG9GkvoijYfP6pX0vzAdr1JK8e5fi Kchw01uQ8g5MGwrFFwmA5+piAETsldNpbi+BDrR16t06tk4qiILQMMZTYRzkQCKlk31p wBXA== X-Gm-Message-State: AOAM53183KdgSv43sRRXu3G7oyOX5YFb3D1jZkdlcmuH/MW+DBS7IPUS ceX02NJGHSIVRpAie/ng1VZD+D1I/m8SMw== X-Google-Smtp-Source: ABdhPJxDMDFKTQUE5og7wAAKE+3KX+IccvbZV3EnHe/KtBigvKluOzuPEhaZg7jz0tWp7sGVFQqCig== X-Received: by 2002:a63:3403:: with SMTP id b3mr10602186pga.308.1612049282128; Sat, 30 Jan 2021 15:28:02 -0800 (PST) Received: from tim-desktop (106-69-90-18.dyn.iinet.net.au. [106.69.90.18]) by smtp.gmail.com with ESMTPSA id a2sm13179480pgi.8.2021.01.30.15.28.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jan 2021 15:28:01 -0800 (PST) References: <87lfcaytom.fsf@gmail.com> User-agent: mu4e 1.5.8; emacs 27.1.91 From: Tim Cross To: emacs-orgmode@gnu.org Subject: Re: [PATCH] ox-md.el export code blocks using grave accents. Date: Sun, 31 Jan 2021 09:51:27 +1100 In-reply-to: <87lfcaytom.fsf@gmail.com> Message-ID: <875z3e2ef5.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=theophilusx@gmail.com; helo=mail-pf1-x435.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 X-Migadu-Spam-Score: -3.05 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=honEjO+u; 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: 62A2A9404D0 X-Spam-Score: -3.05 X-Migadu-Scanner: scn1.migadu.com X-TUID: oDn1l7TEWnEJ I don't think this patch is correct. There are no precise standards for markdown, but org states in the manual that the version of markdown it supports is that defined at http://daringfireball.net/projects/markdown - which uses the indentation style for code blocks, not the ```` style. Note that there is the github markdown exporter which does support the '''' style. One of the problems with markdown is the differing flavours out there. While ```` may be supported on sites like github and stackoverflow, other sites only support the indentation style. We therefore need to be somewhat conservative with respect to introducing changes as while we may 'fix' things for some sites, we could easily break them for others. Given there is a package which supports the ```` style code blocks, I don't think modifying the existing markdown exporter is necessary. >From your explanation, I suspect what you really need is to use the github flavoured markdown package available as ox-gfm on MELPA rather than the default ox-md package in org mode. Note that I have no particular preference for the markdown style defined on daringfireball.net and there has been past discussions on this list regarding what flavour of markdown org should support, so I know there are varying opinions in this area. My main point is that if we specify in the manual that we support a particular flavour, then that is the flavour of markdown we should support. In other words, if we are going to add features/support for syntax not defined on the daringfireball.net flavour of markdown, we would need to document what syntax we do support and consider things like backwards compatibility for any changes introduce. Rodrigo Morales writes: > This patch includes the following changes in =ox-md.el= > > + =org-md-example-block= now exports code blocks using triple grave > accents instead of four spaces of indentation. This has been done > for two main reasons: > > 1. To be able to include the language so that Markdown engines can > syntax highlight the content of code blocks. Syntax highlighting > can also occur when using indentation in some websites (see > [[https://meta.stackexchange.com/questions/184108][this]]. However, > this method doesn't work in all websites (I haven't found > information about this on Github.). Therefore, using grave accents > is more generic. > > 2. To be able to put the source code and the results of evaluation > in different code blocks. When using indentation, both the source > code and the results are shown in the same code block by Markdown > engines. > > + The variable =org-md-lang-export= is now included in order to map > Org Mode language names to Markdown language names. > > The file =mre.org= contains a minimal reproducible example; =mre.md= , > the resulting file when exporting using the current version; and > =mre-patch.md=, the resulting file when exporting with the changes > of this patch applied. > > The patch is shown below. > > #+begin_src dash :dir (progn default-directory) :epilogue ":" > gunzip -c /usr/share/emacs/27.1/lisp/org/ox-md.el.gz > ox-md.el > diff -u ox-md.el ox-md-patched.el > #+end_src > > #+RESULTS: > #+begin_example > --- ox-md.el 2021-01-30 16:49:33.459042367 -0500 > +++ ox-md-patched.el 2021-01-30 16:48:40.232375347 -0500 > @@ -50,6 +50,14 @@ > (const :tag "Use \"atx\" style" atx) > (const :tag "Use \"Setext\" style" setext))) > > +(defcustom org-md-lang-export > + '(("dash" . "sh")) > + "Alist mapping languages to the corresponding language names in Markdown." > + :group 'org-export-md > + :type '(repeat > + (cons > + (string "Org Mode language name") > + (string "Markdown language name")))) > > ;;;; Footnotes > > @@ -181,10 +189,24 @@ > "Transcode EXAMPLE-BLOCK element into Markdown format. > CONTENTS is nil. INFO is a plist used as a communication > channel." > - (replace-regexp-in-string > - "^" " " > - (org-remove-indentation > - (org-export-format-code-default example-block info)))) > + (let* (language > + (org-language > + (plist-get (car (cdr example-block)) :language)) > + (markdown-language > + (cdr (assoc org-language org-md-lang-export))) ; > + (content > + (org-remove-indentation > + (org-export-format-code-default example-block info)))) > + > + (if markdown-language > + (setq language markdown-language) > + (setq language org-language)) > + > + (setq content (replace-regexp-in-string > + "\\`" (concat "```" language "\n") > + content)) > + > + (replace-regexp-in-string "\\'" "```" content))) > > (defun org-md-export-block (export-block contents info) > "Transcode a EXPORT-BLOCK element from Org to Markdown. > #+end_example -- Tim Cross