* Tricking org-mode into using markdown conventions
@ 2020-05-03 16:22 Daryl Manning
2020-05-03 16:39 ` Diego Zamboni
0 siblings, 1 reply; 8+ messages in thread
From: Daryl Manning @ 2020-05-03 16:22 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 830 bytes --]
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... =]
Of course, I'd want the code highlighting especially to work that way,
though... =] Less concerned with whether it works in export modes for the
moment, more about display atm.
thanks!
Daryl.
[-- Attachment #2: Type: text/html, Size: 3177 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tricking org-mode into using markdown conventions 2020-05-03 16:22 Tricking org-mode into using markdown conventions Daryl Manning @ 2020-05-03 16:39 ` Diego Zamboni 2020-05-04 4:15 ` Ihor Radchenko 0 siblings, 1 reply; 8+ messages in thread From: Diego Zamboni @ 2020-05-03 16:39 UTC (permalink / raw) To: Daryl Manning; +Cc: Org-mode 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 =prettify-symbols-alist= (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 <dwm+orgmode@wakatara.com> 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... =] > > Of course, I'd want the code highlighting especially to work that way, though... =] Less concerned with whether it works in export modes for the moment, more about display atm. > > thanks! > Daryl. > > > > > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tricking org-mode into using markdown conventions 2020-05-03 16:39 ` Diego Zamboni @ 2020-05-04 4:15 ` Ihor Radchenko 2020-05-04 7:37 ` Diego Zamboni 0 siblings, 1 reply; 8+ messages in thread From: Ihor Radchenko @ 2020-05-04 4:15 UTC (permalink / raw) To: Diego Zamboni, Daryl Manning; +Cc: Org-mode > I did a quick test, and it seems > that =prettify-symbols-alist= (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 "⇒⇒⇒") org-specific ,(format "^\\(\\*\\{%d,%d\\}\\)\\(\\*\\)[^*]" (1- org-inlinetask-min-level) (1- org-inlinetask-max-level)) (org-mode) 2) (?╭ org-specific "^[ ]*#[+]NAME" (org-mode)) (?╭ org-specific "^[ ]*#[+]name" (org-mode)) (?├ org-specific "[ ]*#[+]begin_src" (org-mode)) (?├ org-specific "[ ]*#[+]BEGIN_SRC" (org-mode)) (?╰ org-specific "[ ]*#[+]end_src" (org-mode)) (?╰ org-specific "[ ]*#[+]END_SRC" (org-mode)) ((yant/str-to-glyph "📁📁📁") org-specific ":\\(ATTACH\\):" (org-mode) 1) ((yant/str-to-glyph "☠D") org-specific "\\<DEADLINE:" (org-mode)) ((yant/str-to-glyph "◴S") org-specific "\\<SCHEDULED:" (org-mode)))) Diego Zamboni <diego@zzamboni.org> 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 =prettify-symbols-alist= (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 <dwm+orgmode@wakatara.com> 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... =] >> >> Of course, I'd want the code highlighting especially to work that way, though... =] Less concerned with whether it works in export modes for the moment, more about display atm. >> >> thanks! >> Daryl. >> >> >> >> >> > -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tricking org-mode into using markdown conventions 2020-05-04 4:15 ` Ihor Radchenko @ 2020-05-04 7:37 ` Diego Zamboni 2020-05-05 8:12 ` Daryl Manning 0 siblings, 1 reply; 8+ messages in thread From: Diego Zamboni @ 2020-05-04 7:37 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Org-mode, Daryl Manning [-- Attachment #1.1: Type: text/plain, Size: 5242 bytes --] Ihor, Awesome, thanks for the tip. Using your code, the following config (inside 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 "```")) ;; ⎡ ➤ 🖝 ➟ ➤ ✎ ("#+end_src" . ,(yant/str-to-glyph "```")) ;; ⎣ ✐ ("#+header:" . ,rasmus/ob-header-symbol) ("#+begin_quote" . ?«) ("#+end_quote" . ?»))))) (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 <yantar92@gmail.com> wrote: > > I did a quick test, and it seems > > that =prettify-symbols-alist= (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 "⇒⇒⇒") org-specific ,(format > "^\\(\\*\\{%d,%d\\}\\)\\(\\*\\)[^*]" (1- org-inlinetask-min-level) (1- > org-inlinetask-max-level)) (org-mode) 2) > (?╭ org-specific "^[ ]*#[+]NAME" (org-mode)) > (?╭ org-specific "^[ ]*#[+]name" (org-mode)) > (?├ org-specific "[ ]*#[+]begin_src" (org-mode)) > (?├ org-specific "[ ]*#[+]BEGIN_SRC" (org-mode)) > (?╰ org-specific "[ ]*#[+]end_src" (org-mode)) > (?╰ org-specific "[ ]*#[+]END_SRC" (org-mode)) > ((yant/str-to-glyph "📁📁📁") org-specific ":\\(ATTACH\\):" > (org-mode) 1) > ((yant/str-to-glyph "☠D") org-specific "\\<DEADLINE:" (org-mode)) > ((yant/str-to-glyph "◴S") org-specific "\\<SCHEDULED:" > (org-mode)))) > > Diego Zamboni <diego@zzamboni.org> 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 =prettify-symbols-alist= (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 <dwm+orgmode@wakatara.com> > 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... =] > >> > >> Of course, I'd want the code highlighting especially to work that way, > though... =] Less concerned with whether it works in export modes for the > moment, more about display atm. > >> > >> thanks! > >> Daryl. > >> > >> > >> > >> > >> > > > > -- > Ihor Radchenko, > PhD, > Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) > State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong > University, Xi'an, China > Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg > [-- Attachment #1.2: Type: text/html, Size: 7590 bytes --] [-- Attachment #2: image.png --] [-- Type: image/png, Size: 62155 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tricking org-mode into using markdown conventions 2020-05-04 7:37 ` Diego Zamboni @ 2020-05-05 8:12 ` Daryl Manning 2020-05-05 8:42 ` Diego Zamboni 2020-05-05 8:46 ` Ihor Radchenko 0 siblings, 2 replies; 8+ messages in thread From: Daryl Manning @ 2020-05-05 8:12 UTC (permalink / raw) To: Org-mode [-- Attachment #1.1: Type: text/plain, Size: 5872 bytes --] 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 <diego@zzamboni.org> wrote: > Ihor, > > Awesome, thanks for the tip. Using your code, the following config (inside > 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 > "```")) ;; ⎡ ➤ 🖝 ➟ ➤ ✎ > ("#+end_src" . ,(yant/str-to-glyph > "```")) ;; ⎣ ✐ > ("#+header:" . ,rasmus/ob-header-symbol) > ("#+begin_quote" . ?«) > ("#+end_quote" . ?»))))) > (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 <yantar92@gmail.com> wrote: > >> > I did a quick test, and it seems >> > that =prettify-symbols-alist= (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 "⇒⇒⇒") org-specific ,(format >> "^\\(\\*\\{%d,%d\\}\\)\\(\\*\\)[^*]" (1- org-inlinetask-min-level) (1- >> org-inlinetask-max-level)) (org-mode) 2) >> (?╭ org-specific "^[ ]*#[+]NAME" (org-mode)) >> (?╭ org-specific "^[ ]*#[+]name" (org-mode)) >> (?├ org-specific "[ ]*#[+]begin_src" (org-mode)) >> (?├ org-specific "[ ]*#[+]BEGIN_SRC" (org-mode)) >> (?╰ org-specific "[ ]*#[+]end_src" (org-mode)) >> (?╰ org-specific "[ ]*#[+]END_SRC" (org-mode)) >> ((yant/str-to-glyph "📁📁📁") org-specific ":\\(ATTACH\\):" >> (org-mode) 1) >> ((yant/str-to-glyph "☠D") org-specific "\\<DEADLINE:" >> (org-mode)) >> ((yant/str-to-glyph "◴S") org-specific "\\<SCHEDULED:" >> (org-mode)))) >> >> Diego Zamboni <diego@zzamboni.org> 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 =prettify-symbols-alist= (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 <dwm+orgmode@wakatara.com> >> 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... =] >> >> >> >> Of course, I'd want the code highlighting especially to work that way, >> though... =] Less concerned with whether it works in export modes for the >> moment, more about display atm. >> >> >> >> thanks! >> >> Daryl. >> >> >> >> >> >> >> >> >> >> >> > >> >> -- >> Ihor Radchenko, >> PhD, >> Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) >> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong >> University, Xi'an, China >> Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg >> > [-- Attachment #1.2: Type: text/html, Size: 8416 bytes --] [-- Attachment #2: image.png --] [-- Type: image/png, Size: 62155 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tricking org-mode into using markdown conventions 2020-05-05 8:12 ` Daryl Manning @ 2020-05-05 8:42 ` Diego Zamboni 2020-05-05 8:46 ` Ihor Radchenko 1 sibling, 0 replies; 8+ messages in thread From: Diego Zamboni @ 2020-05-05 8:42 UTC (permalink / raw) To: Daryl Manning; +Cc: Org-mode [-- Attachment #1: Type: text/plain, Size: 420 bytes --] Hi Daryl, 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` ? > I am no expert in the Org internals, but a quick search shows the strings BEGIN/END_SRC are hardcoded in a few places, so it seems to me you are correct, there's probably no easy way to do this. --Diego [-- Attachment #2: Type: text/html, Size: 721 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tricking org-mode into using markdown conventions 2020-05-05 8:12 ` Daryl Manning 2020-05-05 8:42 ` Diego Zamboni @ 2020-05-05 8:46 ` Ihor Radchenko 2020-05-05 17:22 ` Berry, Charles via General discussions about Org-mode. 1 sibling, 1 reply; 8+ messages in thread From: Ihor Radchenko @ 2020-05-05 8:46 UTC (permalink / raw) To: Daryl Manning, Org-mode > 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 <dwm+orgmode@wakatara.com> 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 <diego@zzamboni.org> wrote: > >> Ihor, >> >> Awesome, thanks for the tip. Using your code, the following config (inside >> 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 >> "```")) ;; ⎡ ➤ 🖝 ➟ ➤ ✎ >> ("#+end_src" . ,(yant/str-to-glyph >> "```")) ;; ⎣ ✐ >> ("#+header:" . ,rasmus/ob-header-symbol) >> ("#+begin_quote" . ?«) >> ("#+end_quote" . ?»))))) >> (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 <yantar92@gmail.com> wrote: >> >>> > I did a quick test, and it seems >>> > that =prettify-symbols-alist= (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 "⇒⇒⇒") org-specific ,(format >>> "^\\(\\*\\{%d,%d\\}\\)\\(\\*\\)[^*]" (1- org-inlinetask-min-level) (1- >>> org-inlinetask-max-level)) (org-mode) 2) >>> (?╭ org-specific "^[ ]*#[+]NAME" (org-mode)) >>> (?╭ org-specific "^[ ]*#[+]name" (org-mode)) >>> (?├ org-specific "[ ]*#[+]begin_src" (org-mode)) >>> (?├ org-specific "[ ]*#[+]BEGIN_SRC" (org-mode)) >>> (?╰ org-specific "[ ]*#[+]end_src" (org-mode)) >>> (?╰ org-specific "[ ]*#[+]END_SRC" (org-mode)) >>> ((yant/str-to-glyph "📁📁📁") org-specific ":\\(ATTACH\\):" >>> (org-mode) 1) >>> ((yant/str-to-glyph "☠D") org-specific "\\<DEADLINE:" >>> (org-mode)) >>> ((yant/str-to-glyph "◴S") org-specific "\\<SCHEDULED:" >>> (org-mode)))) >>> >>> Diego Zamboni <diego@zzamboni.org> 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 =prettify-symbols-alist= (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 <dwm+orgmode@wakatara.com> >>> 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... =] >>> >> >>> >> Of course, I'd want the code highlighting especially to work that way, >>> though... =] Less concerned with whether it works in export modes for the >>> moment, more about display atm. >>> >> >>> >> thanks! >>> >> Daryl. >>> >> >>> >> >>> >> >>> >> >>> >> >>> > >>> >>> -- >>> Ihor Radchenko, >>> PhD, >>> Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) >>> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong >>> University, Xi'an, China >>> Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg >>> >> -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tricking org-mode into using markdown conventions 2020-05-05 8:46 ` Ihor Radchenko @ 2020-05-05 17:22 ` Berry, Charles via General discussions about Org-mode. 0 siblings, 0 replies; 8+ messages in thread From: Berry, Charles via General discussions about Org-mode. @ 2020-05-05 17:22 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Org-mode, Daryl Manning > On May 5, 2020, at 1:46 AM, Ihor Radchenko <yantar92@gmail.com> wrote: > >> 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. > True. However, if your interest is only in exporting a document with such markup, there is `org-export-before-processing-hook'. I haven't tried this but if you want to execute such src blocks, maybe polymode would work. HTH, Chuck > Best, > Ihor > > > Daryl Manning <dwm+orgmode@wakatara.com> 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 <diego@zzamboni.org> wrote: >> >>> Ihor, >>> >>> Awesome, thanks for the tip. Using your code, the following config (inside >>> 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 >>> "```")) ;; ⎡ ➤ 🖝 ➟ ➤ ✎ >>> ("#+end_src" . ,(yant/str-to-glyph >>> "```")) ;; ⎣ ✐ >>> ("#+header:" . ,rasmus/ob-header-symbol) >>> ("#+begin_quote" . ?«) >>> ("#+end_quote" . ?»))))) >>> (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 <yantar92@gmail.com> wrote: >>> >>>>> I did a quick test, and it seems >>>>> that =prettify-symbols-alist= (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 "⇒⇒⇒") org-specific ,(format >>>> "^\\(\\*\\{%d,%d\\}\\)\\(\\*\\)[^*]" (1- org-inlinetask-min-level) (1- >>>> org-inlinetask-max-level)) (org-mode) 2) >>>> (?╭ org-specific "^[ ]*#[+]NAME" (org-mode)) >>>> (?╭ org-specific "^[ ]*#[+]name" (org-mode)) >>>> (?├ org-specific "[ ]*#[+]begin_src" (org-mode)) >>>> (?├ org-specific "[ ]*#[+]BEGIN_SRC" (org-mode)) >>>> (?╰ org-specific "[ ]*#[+]end_src" (org-mode)) >>>> (?╰ org-specific "[ ]*#[+]END_SRC" (org-mode)) >>>> ((yant/str-to-glyph "📁📁📁") org-specific ":\\(ATTACH\\):" >>>> (org-mode) 1) >>>> ((yant/str-to-glyph "☠D") org-specific "\\<DEADLINE:" >>>> (org-mode)) >>>> ((yant/str-to-glyph "◴S") org-specific "\\<SCHEDULED:" >>>> (org-mode)))) >>>> >>>> Diego Zamboni <diego@zzamboni.org> 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 =prettify-symbols-alist= (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 <dwm+orgmode@wakatara.com> >>>> 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... =] >>>>>> >>>>>> Of course, I'd want the code highlighting especially to work that way, >>>> though... =] Less concerned with whether it works in export modes for the >>>> moment, more about display atm. >>>>>> >>>>>> thanks! >>>>>> Daryl. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>> >>>> -- >>>> Ihor Radchenko, >>>> PhD, >>>> Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) >>>> State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong >>>> University, Xi'an, China >>>> Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg >>>> >>> > > -- > Ihor Radchenko, > PhD, > Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) > State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China > Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg > > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-05-05 17:23 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-05-03 16:22 Tricking org-mode into using markdown conventions Daryl Manning 2020-05-03 16:39 ` Diego Zamboni 2020-05-04 4:15 ` Ihor Radchenko 2020-05-04 7:37 ` Diego Zamboni 2020-05-05 8:12 ` Daryl Manning 2020-05-05 8:42 ` Diego Zamboni 2020-05-05 8:46 ` Ihor Radchenko 2020-05-05 17:22 ` Berry, Charles via General discussions about Org-mode.
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).