From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6JJ/FBsgFmCXaAAA0tVLHw (envelope-from ) for ; Sun, 31 Jan 2021 03:12:27 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uuIbEBsgFmCKMAAAbx9fmQ (envelope-from ) for ; Sun, 31 Jan 2021 03:12:27 +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 EF8769403CA for ; Sun, 31 Jan 2021 03:12:26 +0000 (UTC) Received: from localhost ([::1]:44844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l63A1-0007TN-Tw for larch@yhetil.org; Sat, 30 Jan 2021 22:12:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5KoK-0002aB-0N for emacs-orgmode@gnu.org; Thu, 28 Jan 2021 22:51:04 -0500 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:46504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5KoI-0003Jb-2R for emacs-orgmode@gnu.org; Thu, 28 Jan 2021 22:51:03 -0500 Received: by mail-qt1-x829.google.com with SMTP id l23so5792429qtq.13 for ; Thu, 28 Jan 2021 19:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:in-reply-to:date:message-id :mime-version; bh=JxDzxjhEErbq/u31mBTKEDb7XL72w7csqgLCwr8pi8c=; b=EOwh8BD6LVvgAT5uNKGzvufwaYgXEShTWlrH1e2GRkrEGxgcfx3rz5xXLysRXZHVEb oHIvapv6XLEhnAqASsA964PXqdbgwDOpc2PwW8nMbfGa05RaISzvyYTjIzg5z7nge9ww M3haOSHg6CBgWRkVYrE1V36J14e4rnthltfK25nHJm3JTcwKQsLxp0xemnZMFVc7z28I bWv6Gd1gm+NpYx8fsrRAD1bNLfAPRfBBk7oTPWY72NMGCt3GlFqKREydXyhssu834lld 76Ao8KLsuM6WjzSPxLceXHNDwNTyhybz4OcMwZaPU5uERudS51gqKqfyvlQ5OV+Femaj gtjg== 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 :in-reply-to:date:message-id:mime-version; bh=JxDzxjhEErbq/u31mBTKEDb7XL72w7csqgLCwr8pi8c=; b=goCBPvDy1bpnSnJVWXpbx9ciM4CHVzsO/tnze/EOgz3I1MKjNsoIApjVvWUbLmxX06 fRACm/bytBWaSaMacS2a6yOPIN2n2M5IAo7vkkbtp6Yr0orqMEF7aNay2Jeg2JkEiNNx UiNJmB3OGrYJw4Dw0LAEUJ6y68rbwXRnxsEiKJXTr81ehXp1meaQB6fHyeMyk1NORUPM QZS9LZXYVhsL+h/SqzYCwPBonNJIVdDIVcx5wGM7Tjt0ayZKkfK3+agIfl7ay9eHFb68 2Ft0pXOe3ns56Vgf54Jko/iu19ugKPnqihqQxEoQTodCWM3KEnyr/8Ar38ialiurQxAz /LYQ== X-Gm-Message-State: AOAM532wRDFfKP/Xf3UnZDHA2NSBl1BVCeVu44z55frHj5Ya2ile6SdM kYAUdTzvxPiRtHmE+c/Bf0PZks5Ai8Y= X-Google-Smtp-Source: ABdhPJxha+lK1R17ErlPIMAuo9Cw0C0TPOf7O8NfdAM2zwEGbKZR5OkLA7bAx7TwFP1cJ2jBLbSuYg== X-Received: by 2002:a05:622a:201:: with SMTP id b1mr2566800qtx.237.1611892260746; Thu, 28 Jan 2021 19:51:00 -0800 (PST) Received: from localhost ([190.239.232.181]) by smtp.gmail.com with ESMTPSA id h22sm4577379qth.55.2021.01.28.19.50.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 19:51:00 -0800 (PST) References: <87bld8qug1.fsf@gmail.com> User-agent: mu4e 1.4.14; emacs 27.1 From: Rodrigo Morales To: emacs-orgmode@gnu.org Subject: Re: [PATCH] ox-md.el export code blocks using grave accents In-reply-to: <87bld8qug1.fsf@gmail.com> Date: Thu, 28 Jan 2021 22:47:46 -0500 Message-ID: <877dnwqu8t.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-qt1-x829.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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-Mailman-Approved-At: Sat, 30 Jan 2021 22:11:09 -0500 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: -2.05 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=EOwh8BD6; 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: EF8769403CA X-Spam-Score: -2.05 X-Migadu-Scanner: scn1.migadu.com X-TUID: 4rcx6JoakIpg --=-=-= Content-Type: text/plain Sorry for not attaching the files. Here they are. --=-=-= Content-Type: text/markdown Content-Disposition: attachment; filename=mre.md # Table of Contents When exporting the following code block using indentation, it is not possible to know where the source code ends and the results of evaluation starts. echo "echo ab" echo "seq 1 2" echo ab seq 1 2 The language of the following code block will be `sh` because `dash` doesn't belong to `org-md-lang-export` result=0 for i in $(seq 1 5) do for j in $(seq 1 5) do result=$((result + i + j)) done done echo "$result" 150 The language of the following code block will be the same as the one used in Org Mode because `R` doesn't belong to `org-md-lang-export` data(Loblolly) max(Loblolly $ height) [1] 64.1 --=-=-= Content-Type: text/markdown Content-Disposition: attachment; filename=mre-patch.md # Table of Contents When exporting the following code block using indentation, it is not possible to know where the source code ends and the results of evaluation starts. ```sh echo "echo ab" echo "seq 1 2" ``` ``` echo ab seq 1 2 ``` The language of the following code block will be `sh` because `dash` doesn't belong to `org-md-lang-export` ```sh result=0 for i in $(seq 1 5) do for j in $(seq 1 5) do result=$((result + i + j)) done done echo "$result" ``` ``` 150 ``` The language of the following code block will be the same as the one used in Org Mode because `R` doesn't belong to `org-md-lang-export` ```R data(Loblolly) max(Loblolly $ height) ``` ``` [1] 64.1 ``` --=-=-= Content-Type: application/vnd.lotus-organizer Content-Disposition: attachment; filename=mre.org Content-Transfer-Encoding: base64 V2hlbiBleHBvcnRpbmcgdGhlIGZvbGxvd2luZyBjb2RlIGJsb2NrIHVzaW5nIGluZGVudGF0aW9u LCBpdCBpcyBub3QKcG9zc2libGUgdG8ga25vdyB3aGVyZSB0aGUgc291cmNlIGNvZGUgZW5kcyBh bmQgdGhlIHJlc3VsdHMgb2YKZXZhbHVhdGlvbiBzdGFydHMuCgojK2JlZ2luX3NyYyBkYXNoCmVj aG8gImVjaG8gYWIiCmVjaG8gInNlcSAxIDIiCiMrZW5kX3NyYwoKIytSRVNVTFRTOgojK2JlZ2lu X2V4YW1wbGUKZWNobyBhYgpzZXEgMSAyCiMrZW5kX2V4YW1wbGUKClRoZSBsYW5ndWFnZSBvZiB0 aGUgZm9sbG93aW5nIGNvZGUgYmxvY2sgd2lsbCBiZSA9c2g9IGJlY2F1c2UgPWRhc2g9CmRvZXNu J3QgYmVsb25nIHRvID1vcmctbWQtbGFuZy1leHBvcnQ9CgojK2JlZ2luX3NyYyBkYXNoCnJlc3Vs dD0wCgpmb3IgaSBpbiAkKHNlcSAxIDUpCmRvCiAgZm9yIGogaW4gJChzZXEgMSA1KQogIGRvCiAg ICByZXN1bHQ9JCgocmVzdWx0ICsgaSArIGopKQogIGRvbmUKZG9uZQoKZWNobyAiJHJlc3VsdCIK IytlbmRfc3JjCgojK1JFU1VMVFM6CiMrYmVnaW5fZXhhbXBsZQoxNTAKIytlbmRfZXhhbXBsZQoK VGhlIGxhbmd1YWdlIG9mIHRoZSBmb2xsb3dpbmcgY29kZSBibG9jayB3aWxsIGJlIHRoZSBzYW1l IGFzIHRoZSBvbmUKdXNlZCBpbiBPcmcgTW9kZSBiZWNhdXNlID1SPSBkb2Vzbid0IGJlbG9uZyB0 byA9b3JnLW1kLWxhbmctZXhwb3J0PQoKIytiZWdpbl9zcmMgUgpkYXRhKExvYmxvbGx5KQoKbWF4 KExvYmxvbGx5ICQgaGVpZ2h0KQojK2VuZF9zcmMKCiMrUkVTVUxUUzoKIytiZWdpbl9leGFtcGxl ClsxXSA2NC4xCiMrZW5kX2V4YW1wbGUK --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=patch-export-src-code.diff --- ox-md.el 2021-01-28 22:18:51.566067501 -0500 +++ ox-md-patched.el 2021-01-28 22:14:34.762735829 -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. --=-=-= Content-Type: text/plain -- Greetings, Rodrigo Morales. --=-=-=--