开发者

How to get htmlize.el work for project publishing in Emacs org-mode?

开发者 https://www.devze.com 2023-01-28 07:43 出处:网络
I want to publish a project in Emacs org-mode, which contains several .html files. There are some python code examples in them that I wanna highlight.

I want to publish a project in Emacs org-mode, which contains several .html files. There are some python code examples in them that I wanna highlight. But htmlize.el won't do that for me. Strangely, when exporting single .html file (using C-c C-e h), the code examples are highlighted . So how could I get htmlize.el work for开发者_StackOverflow社区 project publishing?


In your org-publish-project-alist, set the htmlized-source property to non-nil:

(setq org-publish-project-alist
      '(("my-project"
           :base-directory ...
           :htmlized-source t
             ...
       )))

See the Publishing action section of the Org-mode manual.


You have to put your code inside #+BEGIN_SRC and #+END_SRC . For example

* My python code
#+BEGIN_SRC python
def foo():
  if bar == 1:
     bar = 2
  else: 
     bar = 3
#+END_SRC


using htmlize.el to highlight your code in orgfile, just add codes listed here to your .emacs file:

(require 'htmlize)

Notes: please make sure htmlize.el in your load-path

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号