org-special-block-extras: Write Once, Export Everywhere

⭐ The code lives at github.com/alhassy/org-special-block-extras —star it, or discuss it there!
Tired of repeating yourself when writing in Org-mode for LaTeX and HTML
exports? org-special-block-extras is your magical toolkit for
creating custom Org-mode blocks and links that work seamlessly
across backends —without diving into the dark arts of raw HTML or
LaTeX!
Reading in glare? —a pale colour soothes the eyes.
1. 🎁 What Does It Do?
- 🎨 Style with ease — add colors, badges, tooltips (from a dictionary, Emacs Help, or custom file), keystroke notations, inline editorial comments, or even colourful ASCII cows with fortune cookies.
- 📚 Glossary support — embed hoverable documentation with
doc:links and auto-generated glossaries. - 📦 Add interactive content: from collapsible detail sections and parallel columns to spoiler tags and equational proofs.
- 🎛 Switch any block:
:when (eq backend 'html),:noexport t,:let (N 7),:boxed "Title",:folded t, and:verbatim t, and:C-c_C-c ACTIONwork on every block —ours, yours, or Org's own src and quote blocks; see switches. Use badge-style links to embed GitHub stars, Reddit subs, or custom project metadata via
shields.io.- 🛠 Use
org-defblock,org-deflinkandorg-deftag—Org, extended as one extends Lisp: each is declared like acl-defun, with&optionaland&keyarguments; or, for the terse-minded, with a flattened arglist.- Create powerful custom blocks with
org-defblock: Define a block once and export to LaTeX and HTML effortlessly. With header-args support like:color red :signoff "Thanks!"for locally customised exports. Each block is also a link and a tag, for free; and:fontifysays how it looks in the buffer. - Use
org-deflinkto create custom links, as functions of their label and description. - Use
org-deftagto create custom tags, as functions of the Org sections they tag.
- Create powerful custom blocks with
🧱 Ready-to-Use Custom Blocks
| Block | Use Case |
|---|---|
details |
Foldable sections — perfect for hiding spoilers, proofs, or long explanations. |
parallel |
Display content in multiple columns — great for comparisons or saving space. |
margin |
Add subtle explanatory tooltips or side remarks — delightful for scholarly writing. |
box |
Emphasize content with nicely styled borders — great for callouts or side notes. |
spoiler |
Hide content visually until the reader chooses to see it — useful in teaching. |
tree |
Display proof trees and logical derivations — fantastic for formal logic. |
rename |
Automated text substitution — great for translation or glossary effects. |
stutter |
Repeat content multiple times — e.g., for emphasis or stylistic flair. |
solution |
Reveal answers in stages — perfect for educational content. |
org-demo |
Show Org markup alongside its rendered result — ideal for tutorials. |
math |
Display maths wherein red:𝒳 colours a symbol, as it colours prose. |
calc |
Step-by-step equational reasoning — beautiful for math walkthroughs. |
graph |
Draw nested Org lists as Graphviz diagrams — C-c C-c renders a PNG in place. |
note, tip, warning, … |
GitHub-style callouts —a coloured rule and a titled heading. |
highlight |
Colour a paragraph's background, rather than its text. |
package-docs |
A table of a package's public API, each name a doc: tooltip. |
style |
Page-wide CSS, verbatim; nothing outside HTML. |
Ready-to-Use Custom Links
| Link | Purpose |
|---|---|
doc:label |
Glossary tooltips —e.g., cl-loopThe Common Lisp ‘loop’ macro.
Valid clauses include:
For clauses:
for VAR from/upfrom/downfrom EXPR1 to/upto/downto/above/below EXPR2
[by EXPR3]
for VAR = EXPR1 then EXPR2
for VAR in/on/in-ref LIST [by FUNC]
for VAR across/across-ref ARRAY
for VAR being:
the elements of/of-ref SEQUENCE [using (index VAR2)]
the symbols [of OBARRAY]
the hash-keys/hash-values of HASH-TABLE [using (hash-values/hash-keys V2)]
the key-codes/key-bindings/key-seqs of KEYMAP [using (key-bindings VAR2)]
the overlays/intervals [of BUFFER] [from POS1] [to POS2]
the frames/buffers
the windows [of FRAME]
Iteration clauses:
repeat INTEGER
while/until/always/never/thereis CONDITION
Accumulation clauses:
collect/append/nconc/concat/vconcat/count/sum/maximize/minimize FORM
[into VAR]
Miscellaneous clauses:
with VAR = INIT
if/when/unless COND CLAUSE [and CLAUSE]... else CLAUSE [and CLAUSE...]
named NAME
initially/finally [do] EXPRS...
do EXPRS...
[finally] return EXPR
For more details, see Info node ‘(cl)Loop Facility’.
(fn CLAUSE...); our own terms, even <<<radio targets>>>, too |
kbd: |
Stylized keybindings with tooltips — e.g., kbd:C-x_C-e; in Emacs, 〔C-x C-e〕, click to run |
color: or red: |
Inline text colouring — supports both names and hex codes. |
highlight: |
Colour the background instead —so highlighted in Emacs too. |
palette: |
A button for readers to pick the page's background colour. |
toggle-details: |
A button to unfold, or fold, every details block at once. |
html-export-style: |
Pick a visual theme for HTML exports — one click, new style. |
badge: |
Embed project badges — e.g., GitHub stars, Reddit subs, versioning. |
fortune: |
Insert ASCII animals saying jokes or phrases — joy in your docs! |
octoicon: |
GitHub-style icons — for styling and linking like a pro. |
link-here: |
Local anchors — create navigable sections anywhere. |
show: |
Show a variable value — dynamically insert content like your name or version. |
elisp: |
Make clickable actions — buttons that run Emacs Lisp. |
💡 Ideal For
- 🧑🏫 Educators building interactive lessons and glossaries
- 🧑💻 Developers documenting APIs with style
- 📚 Writers crafting scholarly or explorable documents
- ✨ Emacsers who want rich export without leaving Org-mode
- ✏️ Bloggers wanting powerful interactivity
- This is the reason I made this package.
- 1️⃣ Anyone who wants to keep Org-mode as the single source of truth for rich exports
🪄 Just load the package, write in Org, and let defblock handle the
rest. Now your Org-mode documents are not just structured —they're
spectacular.
Write rich Org-mode documents — one source, many formats.
The org-special-block-extras package empowers you to define and use
custom blocks and links that make your Org files export beautifully
to both HTML and LaTeX, without ever writing raw HTML or LaTeX
again.
2. 🗺 The package at a glance
Every node below leads to its section; hover, or tap, one for its gist. The map is itself a graph
block —an Org list, coloured by #+name: tables folded in its :TEMPLATES: drawer, and laid out radially by :layout twopi.
Life & Computing Science by Musa Al-hassy is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License