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 <yanta...@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 <di...@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+orgm...@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: yanta...@gmail.com, ihor_radche...@alumni.sutd.edu.sg
>

Reply via email to