From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yMidNeIosV6tOQAA0tVLHw (envelope-from ) for ; Tue, 05 May 2020 08:50:42 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 0AWUGO0osV4yTAAA1q6Kng (envelope-from ) for ; Tue, 05 May 2020 08:50:53 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::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 4B2EB94456F for ; Tue, 5 May 2020 08:50:51 +0000 (UTC) Received: from localhost ([::1]:46808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVtHv-00058J-Gj for larch@yhetil.org; Tue, 05 May 2020 04:50:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVtHW-00057n-Eq for emacs-orgmode@gnu.org; Tue, 05 May 2020 04:50:27 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:47052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVtHU-0001aw-PF for emacs-orgmode@gnu.org; Tue, 05 May 2020 04:50:25 -0400 Received: by mail-pg1-x52c.google.com with SMTP id q124so710174pgq.13 for ; Tue, 05 May 2020 01:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version :content-transfer-encoding; bh=jJHXHUsVgIpHKaZh6zX8Z592cyIW27uShWjClaLjAGA=; b=JTbG8mMQ5O0OtF5fLqQ+v5A3VDBrhSMfM1CGt79yIJffAzdNlyJnEwDUo+WDR1P81K XynhMY9AaO37pXMIAeFCeg27Gjig10+AREXh+GmGT3RcN23aG1D2BbUtkP0qgWGuoZiC PiQhr5jev3DAwPSz5IUhKecwTBxt4B4U+JYwVxl1paqdnxEaOfMDqb1CcNaSsF25GK07 NvIfX8JOHG4d5ljspHEqa5rnmIbiQ5c1oPhTt4Mdytj4s2Jh9Np9gkJzGZ+TAWeIVzL3 O8l7nMVYkObHXMp1k/8pPHvNuy/jRUQOeF1dbLZwLbZ9mwZTMgn1YN2aC9X5d/+8ixev ENMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=jJHXHUsVgIpHKaZh6zX8Z592cyIW27uShWjClaLjAGA=; b=cDty9wLdpA1qHqV7zdh9zz4f0RDptTqQOsIYppO/WRfsVBvrBT/GWrpKwWTgGEnST1 TE3KsqpNXjo8gEL5YZwOUeCcM2vvlKHD1RlakLtK7pDfUalcDFeLILPTwfDTUZ0mkVnn 3llGM5/jhxX6TKt+kpRoXzNk/19M79GJ9turIy3CCqX6igl4Sxr2Y72evIyYoNGMZ2TX Y7NQSzlOerT6oBuWngZRA+91Ko+5GSkgCmtsWFhPajBUzqr9Fj+AtLfTcXfJ95ddekrC 6deMM+2Uhx90X+SjFMFzXGesHfBkmfohYUtEszFcB9CYEu2xKLep7xPcIjPZVkHsSaIG ai+w== X-Gm-Message-State: AGi0PuahDSOegs1uHdLlOdJyT3fAVKjdsg8ZWK+QhocoUO09kX6bqxXj MGee3ZYwBKQ0T51tXQt0SmMF28cbIj+vpw== X-Google-Smtp-Source: APiQypIQwgNrtTsNqO1AvNkGmr/OJxThofytFAPjcG3ZUQDIg8wa10w5i+KzIg9su9iOMGH3T/C5VA== X-Received: by 2002:a63:ed08:: with SMTP id d8mr2067608pgi.309.1588668621749; Tue, 05 May 2020 01:50:21 -0700 (PDT) Received: from localhost ([210.3.160.226]) by smtp.gmail.com with ESMTPSA id u188sm1399514pfu.33.2020.05.05.01.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 May 2020 01:50:21 -0700 (PDT) From: Ihor Radchenko To: Daryl Manning , Org-mode Subject: Re: Tricking org-mode into using markdown conventions In-Reply-To: References: <874kswnxo6.fsf@localhost> Date: Tue, 05 May 2020 16:46:15 +0800 Message-ID: <87v9lan50o.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=yantar92@gmail.com; helo=mail-pg1-x52c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URIBL_SBL=1.623, URIBL_SBL_A=0.1 autolearn=_AUTOLEARN 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-Scanner: scn0 X-Spam-Score: 0.29 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=JTbG8mMQ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [0.29 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49532078845864]; MX_INVALID(1.00)[]; DWL_DNSWL_FAIL(0.00)[gmail.com:server fail,2001:470:142::17:server fail]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; FREEMAIL_FROM(0.00)[gmail.com]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.13), country: US(-0.00), ip: 2001:470:142::17(-0.50)]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[yantar92@gmail.com,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[zzamboni.org:email,sutd.edu.sg:email,pank.eu:url,wakatara.com:email]; TAGGED_RCPT(0.00)[orgmode]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; HAS_LIST_UNSUB(-0.01)[]; MID_RHS_NOT_FQDN(0.50)[]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: v+pePo12V1ye > I am assuming though, from the lack of answers back, that there appears to > be no way to have org-mode grok markdown code blocks (triple backticks) > when it parses as a substitute for `#+BEGIN_SRC` ? #+BEGIN_SRC is a part of org syntax, "```" is not. You will need to modify the org-mode internals to do change it. Depending on implementation details of org-mode, changing org-block-regexp and all the occurrences of "BEGIN_SRC" and "END_SRC" in org mode sources might achieve what you want, but there is no guarantee that it will not be broken in future versions of org. Best, Ihor Daryl Manning writes: > This looks great (your elisp-fu is impressive) and definitely fulfills > making it look markdown-ish. Thanks! Will plug it in tonight and take it > for a pain. > > I am assuming though, from the lack of answers back, that there appears to > be no way to have org-mode grok markdown code blocks (triple backticks) > when it parses as a substitute for `#+BEGIN_SRC` ? > > Daryl. > > > On Mon, May 4, 2020 at 3:37 PM Diego Zamboni wrote: > >> Ihor, >> >> Awesome, thanks for the tip. Using your code, the following config (insi= de >> the code from https://pank.eu/blog/pretty-babel-src-blocks.html) produces >> a display with the backticks instead of begin/end_src: >> >> (defun yant/str-to-glyph (str) >> "Transform string into glyph, displayed correctly." >> (let ((composition nil)) >> (dolist (char (string-to-list str) >> (nreverse (cdr composition))) >> (push char composition) >> (push '(Br . Bl) composition)))) >> >> (defun rasmus/org-prettify-symbols () >> (mapc (apply-partially 'add-to-list 'prettify-symbols-alist) >> (cl-reduce 'append >> (mapcar (lambda (x) (list x (cons (upcase (car >> x)) (cdr x)))) >> `(("#+begin_src" . ,(yant/str-to-glyph >> "```")) ;; =E2=8E=A1 =E2=9E=A4 =F0=9F=96=9D =E2=9E=9F =E2=9E=A4 =E2=9C=8E >> ("#+end_src" . ,(yant/str-to-glyph >> "```")) ;; =E2=8E=A3 =E2=9C=90 >> ("#+header:" . ,rasmus/ob-header-symb= ol) >> ("#+begin_quote" . ?=C2=AB) >> ("#+end_quote" . ?=C2=BB))))) >> (turn-on-prettify-symbols-mode) >> (add-hook 'post-command-hook 'rasmus/org-prettify-src t t)) >> >> It looks like this in my config (the bars hide the header arguments): >> >> [image: image.png] >> >> --Diego >> >> >> On Mon, May 4, 2020 at 6:19 AM Ihor Radchenko wrote: >> >>> > I did a quick test, and it seems >>> > that =3Dprettify-symbols-alist=3D (which is what this code uses) can = only >>> > replace for a single character, so I was not able to make it display >>> > the three backticks, but there might be other techniques that can be >>> > used. >>> >>> Yes, there is another technique. >>> See part of my config below: >>> >>> >>> (defun yant/str-to-glyph (str) >>> "Transform string into glyph, displayed correctly." >>> (let ((composition nil)) >>> (dolist (char (string-to-list str) >>> (nreverse (cdr composition))) >>> (push char composition) >>> (push '(Br . Bl) composition)))) >>> >>> (append pretty-symbol-patterns >>> `(((yant/str-to-glyph " ") org-specific ,(format >>> "^\\(\\*\\{%d,%d\\}\\)\\*[^*]" (1- org-inlinetask-min-level) (1- >>> org-inlinetask-max-level)) (org-mode) 1) >>> ((yant/str-to-glyph "=E2=87=92=E2=87=92=E2=87=92") org-specif= ic ,(format >>> "^\\(\\*\\{%d,%d\\}\\)\\(\\*\\)[^*]" (1- org-inlinetask-min-level) (1- >>> org-inlinetask-max-level)) (org-mode) 2) >>> (?=E2=95=AD org-specific "^[ ]*#[+]NAME" (org-mode)) >>> (?=E2=95=AD org-specific "^[ ]*#[+]name" (org-mode)) >>> (?=E2=94=9C org-specific "[ ]*#[+]begin_src" (org-mode)) >>> (?=E2=94=9C org-specific "[ ]*#[+]BEGIN_SRC" (org-mode)) >>> (?=E2=95=B0 org-specific "[ ]*#[+]end_src" (org-mode)) >>> (?=E2=95=B0 org-specific "[ ]*#[+]END_SRC" (org-mode)) >>> ((yant/str-to-glyph "=F0=9F=93=81=F0=9F=93=81=F0=9F=93=81") o= rg-specific ":\\(ATTACH\\):" >>> (org-mode) 1) >>> ((yant/str-to-glyph "=E2=98=A0D") org-specific "\\>> (org-mode)) >>> ((yant/str-to-glyph "=E2=97=B4S") org-specific "\\>> (org-mode)))) >>> >>> Diego Zamboni writes: >>> >>> > Hi Daryl, >>> > >>> > If it's for display purposes only, you might be able to simply use >>> > display substitutions for things to appear the way you want. For >>> > example, I use the technique described here: >>> > https://pank.eu/blog/pretty-babel-src-blocks.html to replace the >>> > begin/end_src strings with symbols. I did a quick test, and it seems >>> > that =3Dprettify-symbols-alist=3D (which is what this code uses) can = only >>> > replace for a single character, so I was not able to make it display >>> > the three backticks, but there might be other techniques that can be >>> > used. >>> > >>> > --Diego >>> > >>> > On Sun, May 3, 2020 at 6:24 PM Daryl Manning >>> wrote: >>> >> >>> >> While using C-c C-, is easy enough for insertion and such, I was >>> wondering if there was any way of having org-mode honour markdown >>> conventions for things like code fences and quotes. >>> >> >>> >> ``` elisp >>> >> #+begin_src >>> >> #+end_src >>> >> >>> >> #+begin_quote >>> >> #+end_quote >>> >> ``` >>> >> >>> >> being a bit nicer to read with >>> >> >>> >> ``` go >>> >> code block >>> >> ``` >>> >> as well as >>> >> >>> >> > And gentlemen in England now-a-bed. >>> >> > Shall think themselves accurs'd they were not here, >>> >> > And hold their manhoods cheap whiles any speaks. >>> >> > That fought with us upon Saint Crispin's day. >>> >> >>> >> Just curious as to whether that's possible. YMMV before you start >>> debating on whether you think this is a good idea or not... =3D] >>> >> >>> >> Of course, I'd want the code highlighting especially to work that wa= y, >>> though... =3D] Less concerned with whether it works in export modes fo= r the >>> moment, more about display atm. >>> >> >>> >> thanks! >>> >> Daryl. >>> >> >>> >> >>> >> >>> >> >>> >> >>> > >>> >>> -- >>> Ihor Radchenko, >>> PhD, >>> Center for Advancing Materials Performance from the Nanoscale (CAMP-nan= o) >>> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaoto= ng >>> University, Xi'an, China >>> Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg >>> >> --=20 Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong U= niversity, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg