Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Org-mode failed to highlight C++ source code when exporting html

I'm using org-mode V7.8.09. When I was trying to export the following c++ code block to html,

#+begin_src c++
  int a=1;
  int b=1;
  printf("%d\n", a+b);
#+end_src

it failed with message

org-babel-exp processing...
font-lock-fontify-keywords-region: Symbol's value as variable is void: font-lock-end-statement-face`

Interestingly, if I claim that it is python code, it exports successfully...

#+begin_src python
  int a=1;
  int b=1;
  printf("%d\n", a+b);
#+end_src

After I add (org-babel-do-load-languages 'org-babel-load-languages '((C . t))) in my init.el, the error message is gone and c++ codes can be exported to html successfully. But c++ codes are not highlighted, while python codes are highlighted fine.

like image 267
updogliu Avatar asked Jun 12 '12 06:06

updogliu


1 Answers

The package that you need load is emacs/lisp/org/ob-C.el

https://bitbucket.org/nobeira/dot.emacs.d/src/c6af5b1535b1/elisp/org-7.4/lisp/ob-C.el.

there is not C++ package

.emacs.el configuration file:

(org-babel-load-languages (C . t)))
(setq org-src-fontify-natively t)

org document:

#+BEGIN_SRC cpp   :includes <stdio.h> :exports both
 int a=1;
 int b=1;
 printf("%d\n", a+b);
#+END_SRC

for me work (fontify and running) ONLY with cpp source_name

Candido

like image 102
candido Avatar answered Oct 02 '22 09:10

candido