From 8b4f22ed753ff91d3ee2a815eff9dcd8cce5f122 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 2 Aug 2016 12:07:06 -0700 Subject: [PATCH] Update marky-markdown wrapping fix. --- lib/main/build-site.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/main/build-site.js b/lib/main/build-site.js index 72ee89f84..e2bf63665 100644 --- a/lib/main/build-site.js +++ b/lib/main/build-site.js @@ -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.