Update marky-markdown wrapping fix.

This commit is contained in:
John-David Dalton
2016-08-02 12:07:06 -07:00
parent 669b76bf99
commit 8b4f22ed75

View File

@@ -33,10 +33,16 @@ function build(type) {
$a.replaceWith($a.html());
});
// Fix marky-markdown wrapping of sibling anchors.
$('h3 ~ a').each(function() {
var $a = $(this);
$a.nextAll('p').first().append($a);
// Fix marky-markdown wrapping around headers.
$('p:empty + h3').prev().remove();
$('h3 ~ p:empty').each(function() {
var $p = $(this),
node = this.previousSibling;
while ((node = node.previousSibling) && node.name != 'h3' && node.name != 'p') {
$p.prepend(node.nextSibling);
}
});
// Append YAML front matter.