Last active
October 9, 2015 22:01
-
-
Save julian-boolean/b547a79fe85785376d8b to your computer and use it in GitHub Desktop.
This file contains 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
/*Indent everything under h1,h2,h3 and h4 tags with indent width relative to order of headers. | |
<h1>ffoooo</h1> | |
<p> stuff | |
<pre> | |
<h2> | |
<p> level 2 stuff | |
<h3> | |
<h4>level 3 stuff | |
<p> level 4 stuff. | |
<h3> | |
<p> back to level 3 | |
<h1> | |
<p>all the way back to level 1. | |
<h3> | |
<p>level 2,even thought the tag is h3 | |
etc... | |
*/ | |
[1,2,3,4].forEach(function(num){ | |
var nodeType = 'h' + num; | |
$(nodeType).each(function(){ | |
var $ul = $('<ul class="nobullet">').insertAfter($(this)); | |
$ul.nextUntil(nodeType).wrapAll('<li>').parent().appendTo($ul); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment