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; 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 :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.
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-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.
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.

%3 osbe org-special-block-extras Blocks to write Blocks to write osbe--Blocks to write Links to cite Links to cite osbe--Links to cite Switches on any block Switches on any block osbe--Switches on any block Keys in Emacs Keys in Emacs osbe--Keys in Emacs Make your own Make your own osbe--Make your own Options Options osbe--Options Callouts note · tip · important · warning · caution Callouts note · tip · important · warning · caution Blocks to write--Callouts note · tip · important · warning · caution Folding & framing box · details · solution · spoiler · parallel Folding & framing box · details · solution · spoiler · parallel Blocks to write--Folding & framing box · details · solution · spoiler · parallel Remarks margin · tooltip · remark Remarks margin · tooltip · remark Blocks to write--Remarks margin · tooltip · remark Colour red · blue · … · highlight Colour red · blue · … · highlight Blocks to write--Colour red · blue · … · highlight Maths & proofs math · align · calc · tree Maths & proofs math · align · calc · tree Blocks to write--Maths & proofs math · align · calc · tree Graphs graph Graphs graph Blocks to write--Graphs graph Glossaries documentation Glossaries documentation Blocks to write--Glossaries documentation doc:𝒳 show:𝒳 doc:𝒳 show:𝒳 Links to cite--doc:𝒳 show:𝒳 kbd:C-x_C-s kbd:C-x_C-s Links to cite--kbd:C-x_C-s Badges badge · melpa · github-* Badges badge · melpa · github-* Links to cite--Badges badge · melpa · github-* Every block, as a link Every block, as a link Links to cite--Every block, as a link :when · :noexport :when · :noexport Switches on any block--:when · :noexport :let · :ignore :let · :ignore Switches on any block--:let · :ignore :boxed · :folded :boxed · :folded Switches on any block--:boxed · :folded :verbatim :verbatim Switches on any block--:verbatim C-c C-c C-c C-c Keys in Emacs--C-c C-c C-c ' C-c ' Keys in Emacs--C-c ' C-c C-v C-d C-c C-v C-d Keys in Emacs--C-c C-v C-d eldoc eldoc Keys in Emacs--eldoc org-defblock org-defblock Make your own--org-defblock org-deflink org-deflink Make your own--org-deflink org-deftag org-deftag Make your own--org-deftag org-thread-blockcall org-thread-blockcall Make your own--org-thread-blockcall org-defblock-evaluate-switches org-defblock-evaluate-switches Options--org-defblock-evaluate-switches org-special-block-add-html-extra org-special-block-add-html-extra Options--org-special-block-add-html-extra org-docs-libraries org-docs-libraries Options--org-docs-libraries

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