c++ - org-mode 导出 html 时无法高亮 C++ 源代码

标签 c++ emacs org-mode

我使用的是 org-mode V7.8.09。当我尝试将以下 c++ 代码块导出到 html 时,

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

消息失败

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

有趣的是,如果我声称它是 python 代码,它会成功导出...

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

在我添加 (org-babel-do-load-languages 'org-babel-load-languages '((C . t))) 之后在我的init.el ,错误信息消失,c++代码可以成功导出为html。但是c++代码没有高亮,而python代码高亮很好。

最佳答案

你需要加载的包是emacs/lisp/org/ob-C.el

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

没有 C++ 包

.emacs.el 配置文件:

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

组织文件:

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

对我来说只能使用 cpp source_name 工作(字体化和运行)

念念不忘

关于c++ - org-mode 导出 html 时无法高亮 C++ 源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10991704/

相关文章:

emacs - 在 Emacs org-mode 中评估代码块时如何输入密码?

c++ - 这个 C++ 编译器优化的名称是什么(在其自身实例上调用对象自己的构造函数),它是如何工作的?

emacs - Emacs ORG 模式如何工作?

c++ - 从 Char 数组中删除前两个字符

vim - emacs 等同于 vim 重新映射,例如:nnoremap dd g0dg$

emacs - 在 emacs 中的 term-mode 中,退格在 ssh 中不起作用

haskell - Emacs 在 haskell 模式下挂起,并调用了 lower-haskell-load-file

org-mode - 如何隐藏一些文本不被 org-publish-* 函数发布?

c++ - Windows 上 QT4 的 Poppler 库

c++ - 为什么析构函数会无休止地调用自身(导致堆栈溢出)?