How to highlight syntax for embedded source code Org-src_lang {}?

Is there any syntax way to highlight the built-in Org-mode source code that is marked src_ruby{Array.new} ?

Does the Org-mode option have a default option? Or is there any other way to do this?

+6
source share
3 answers

enter image description here

 (font-lock-add-keywords 'org-mode '(("\\(src_\\)\\([^[{]+\\)\\(\\[:.*\\]\\){\\([^}]*\\)}" (1 '(:foreground "black" :weight 'normal :height 10)) ; src_ part (2 '(:foreground "cyan" :weight 'bold :height 75 :underline "red")) ; "lang" part. (3 '(:foreground "#555555" :height 70)) ; [:header arguments] part. (4 'org-code) ; "code..." part. ))) 
+4
source

UPDATE: The correct answer to this specific question follows fooobar.com/questions/959108 / .... The answer presented here is related to this question. Syntax highlighting in the # + begin_src block in emacs orgmode does not work

Do you mean the syntax for allocating source blocks in a buffer?

 #+BEGIN_SRC ruby Array.new #+END_SRC 

You need to install (setq org-src-fontify-natively t)

Link: http://orgmode.org/worg/org-contrib/babel/examples/fontify-src-code-blocks.html

+14
source
  (defun org-fontify-inline-src-block (limit)
   "Fontify inline source block."
   (when (re-search-forward org-babel-inline-src-block-regexp limit t)
     (add-text-properties
      (match-beginning 1) (match-end 0)
      '(font-lock-fontified t face (t (: foreground "# 008ED1": background "#FFFFEA"))))
     (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
     t))

add to org-set-font-lock-defaults function in org.el

  ;;  Drawers
 '(org-fontify-drawers)
 ;;  Inline source block
 '(org-fontify-inline-src-block)
+1
source

Source: https://habr.com/ru/post/959108/


All Articles