4

Is it possible to get syntax highlight for HTML code within a #+BEGIN_EXPORT HTML environment block in org-mode?

I know it is possible to highlight HTML within a #+BEGIN_SRC block using ob-browser. Is there a way to "extend" such highlighting to other blocks as well?

2
  • 1
    It sounds like this might not be exactly what you want, but if you set (setq org-src-fontify-natively t) in your config, then html in a #+BEGIN_SRC html block should have highlighting. There is a nice setup here for dealing with org-mode source code blocks: github.com/danielmai/.emacs.d/blob/master/…
    – elethan
    Dec 10, 2015 at 2:36
  • Yp, within #+BEGIN_SRC is not a problem... I was wondering about #+BEGIN_HTML. But thanks for the link
    – Daniel
    Dec 10, 2015 at 9:37

1 Answer 1

3

The problem lies on the arbitrariness with which Org Mode deals with case sensitivity. I was used to having a #+BEGIN_HTML block in Org Mode 8, and that didn't trigger the syntax highlighting. Had I used lowercases as in #+begin_html, things might have looked different.

Now, with Org Mode 9, one can get HTML highlight with any of:

#+begin_export html
<div>  
</div>
#+end_export

#+BEGIN_EXPORT html
<div>  
</div>
#+END_EXPORT

But not with:

#+BEGIN_EXPORT HTML
<div>  
</div>
#+END_EXPORT

Here's a screenshot:

html_highlighting

2
  • This does not appear to work in the current version, I get no highlighting regardless how I type it. Any idea for how it can be made to work, or where in the Org Mode source I should look to figure it out myself? I'm running Org Mode from the git repo, org-version currently reports version 9.7-pre (release_9.6.7-555-ga1ef64).
    – njlarsson
    Jul 16 at 12:31
  • Cannot reproduce on 9.6.1. Did it use to work before and stopped working now? I get syntax highlight without issues. With that said, a lot is currently changing under the hood on org-mode and the org element API, and I've had org-roam breaking and some org-exports as well. Would not exclude the possibility of a bug
    – Daniel
    Jul 17 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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