0

I would like to set a new face in org-mode for pandoc citation syntax which looks like this:

[@bibtexkey{555-563}]

Custom face:

(defface pandoc-citation-face
  '((t :foreground "yellow"))
  "Face for pandoc citation syntax")

None of the attempts below worked:

(font-lock-add-keywords 'org-mode
      '(("\[@.+?\]" . pandoc-citation-face)))

(defun org-add-my-extra-markup ()
  (add-to-list 'org-font-lock-extra-keywords
               `(("\[@.+?\]" . pandoc-citation-face))))

(add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
(defun org-add-my-extra-markup ()
  (add-to-list 'org-font-lock-extra-keywords
               `(,(rx (group "[@")
                      (group (+? anything))
                      (group "]"))
                 (2 '(face pandoc-citation)))))

(add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-markup)
1

This works for me.

(defface pandoc-citation-face
  '((t :foreground "yellow"))
  "Face for pandoc citation syntax")

(font-lock-add-keywords
 nil
 '(("\\[@.+?\\]" 0 'pandoc-citation-face)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.