#StackBounty: #org-mode #org-export #org-babel #literate-programming Generate different markup for not-tangled code blocks in org-mode

Bounty: 100

Is there a way in org-mode’s HTML export to make it so that code blocks that have :tangle no will appear differently? Even adding a different HTML class will do, as one can then probably add some CSS to alter their appearance (e.g. grey background or whatever).

Longer version / context:

I’m using org-mode (and its org-babel) to keep code and documentation together in a single file. Specifically, as in this question, I have

(require 'org)
(org-babel-load-file (expand-file-name "~/emacs/config/init.org"))

so that init.org can generate both an init.el file (for consumption by Emacs), and an init.html file (for consumption by me, when I want to make sense of my config again). In this file, I have some sections that I don’t want to be part of init.el (e.g. either I decided against them, or they’re simplified versions given first for understanding, before the “real” code, etc). For them, instead of something like

#+BEGIN_SRC emacs-lisp
(require 'cc-mode)

I have:

#+BEGIN_SRC emacs-lisp :tangle no
(require 'cc-mode)

and everything works fine: the code no longer runs on startup, as it’s no longer part of the generated init.el. However, the code still shows up in init.html (as I want it to) when I export from the org file, but unfortunately there’s no longer any indication that this section is not going be tangled.

I imagine that in the HTML file, instead of


if I could persuade org-mode / org-babel export to add another class, then I’d know how to solve the rest.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.