Skip to content

Instantly share code, notes, and snippets.

@chriscauley
chriscauley / nuke-space.js
Last active February 16, 2023 22:10
Nuke white space in <pre><code> tags
/*
Removes the minimum leading whitespace for each line in a pre > code tag.
Also optionally escapes html if you include the "nuke-html" class
When writing HTML snippets for slides or blogs, it's a pain to have to do this:
</div> <!-- original indentation level -->
<pre><code class="html">&lt;ul class="demo"&gt;
&lt;li&gt;No order here&lt;/li&gt;
&lt;li&gt;Or here&lt;/li&gt;
&lt;li&gt;Or here&lt;/li&gt;