/org-src-emph

Custom emphasis of substrings of Org source blocks

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

org-src-emph: Custom emphasis of substrings of Org source blocks

Introduction

This Emacs package provides the Org source block header argument :emph. The value of :emph is a list ’(BEG END FACE) consisting of two regexps BEG and END and a face specification FACE.

BEG and END are the regular expressions matching the beginning and the end of the region to be emphasized with FACE.

Supported are currently:

  1. Highlighting of the Org buffer itself
  2. HTML-Export

This package is inspired by the following two https://emacs.stackexchange.com questions:

  1. Emphasize text snippets in source blocks
  2. Noweb references in sh blocks breaks the syntax highlighting

Installation

  1. Put the file org-src-emph.el anywhere in your load-path.
  2. Optionally byte-compile org-src-emph.el.
  3. Add (require 'org-src-emph) into your init file.

Usage Examples

C++ example

#+BEGIN_SRC C++ :emph '(("°" "°" 'bold))
  std::cout << "°These words are highlighted.°\n";
#+END_SRC

Shell: Avoid highlighting of Noweb-references as infile-documents

#+NAME: F
#+BEGIN_SRC sh
"Noweb source!"
#+END_SRC

#+BEGIN_SRC sh :noweb yes :emph '(("<<" ">>"))
  #!bash
  if [[ "$1" == "Noweb reference" ]]; then
      echo <<F()>>
  else
      echo "nothing" 
  fi
  echo "Finish"
#+END_SRC