Last active
May 19, 2018 14:48
-
-
Save V-ed/68e05155a373aed7e8426ef49d956f7d to your computer and use it in GitHub Desktop.
Makes the <pre> element indent at the level of the children and not at the document's level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("pre.code").each(function () { | |
var html = $(this).html(); | |
var blankLen = (html.split('\n')[0].match(/^[\s\t]+/)[0]).length; | |
$(this).html($.trim(html.replace(eval("/^[\s\t]{" + blankLen + "}/gm"), ""))); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is taken and modified from this StackOverflow answer. Long live StackOverflow!