Projects About AlBasmala
build status

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

Article image
  

Ξ  

⭐ The code lives at github.com/alhassy/org-special-block-extras —star it, or discuss it there!

org-special-block-extras-badge.svg

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 ACTION work 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-deflink and org-deftag —Org, extended as one extends Lisp: each is declared like a cl-defun, with &optional and &key arguments.
    • 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 :fontify says how it looks in the buffer.
    • Use org-deflink to create custom links, as functions of their label and description.
    • Use org-deftag to create custom tags, as functions of the Org sections they tag.

🧱 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.
stutter Repeat content multiple times — e.g., for emphasis or stylistic flair.
solution Reveal answers in stages — perfect for educational content.
math Display maths wherein red:𝒳 colours a symbol; calculational proofs, with hints.
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.

Ready-to-Use Custom Links

Link Purpose
doc:label Glossary tooltips —e.g., cl-loop; 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.
badge: Embed project badges — e.g., GitHub stars, Reddit subs, versioning.
fortune: Insert ASCII animals saying jokes or phrases — joy in your docs!
<<X>> Permalinks — Org's own targets, made a visible 🔗 in HTML.
elisp: Make clickable actions — buttons that run Emacs Lisp.

Org's own elisp: links evaluate Lisp; e.g., [[elisp:(find-file user-init-file)][Init]] is a “link button” that visits our init file. Yet they do not export the value of their expression; for that, Org's own inline src blocks serve: src_elisp[:results raw]{user-full-name} exports as Musa Al-hassy on my machine, and src_elisp{(* 2 (+ 3 4))} as 14. As for any Babel code, Org asks before running a stranger's Lisp; see org-confirm-babel-evaluate.


💡 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


Generated by Emacs and Org-mode (•̀ᴗ•́)و
Creative Commons License
Life & Computing Science by Musa Al-hassy is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License