diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-20 14:00:28 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-12-22 12:32:14 +0100 |
commit | 21fe8961d7ac91a49c49c28052fc2de4f251f409 (patch) | |
tree | 31b5f5b19a70a67ba6c4bd9e9432f31be66084b2 /packages/gitbook-html/lib/dom.js | |
parent | 677032ead533b9d21cb9d8a752cb3671a0cbeb52 (diff) | |
download | gitbook-21fe8961d7ac91a49c49c28052fc2de4f251f409.zip gitbook-21fe8961d7ac91a49c49c28052fc2de4f251f409.tar.gz gitbook-21fe8961d7ac91a49c49c28052fc2de4f251f409.tar.bz2 |
Cleanup html before parsing summary
Diffstat (limited to 'packages/gitbook-html/lib/dom.js')
-rw-r--r-- | packages/gitbook-html/lib/dom.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/gitbook-html/lib/dom.js b/packages/gitbook-html/lib/dom.js index df4de90..d8f7c84 100644 --- a/packages/gitbook-html/lib/dom.js +++ b/packages/gitbook-html/lib/dom.js @@ -23,8 +23,22 @@ function textNode($el) { }, ''); } +// Cleanup a dom +// Remove all divs +function cleanup($el, $) { + $el.find('div').each(function() { + var $div = $(this); + cleanup($div, $); + + $div.replaceWith($div.html()); + }); + + return $el; +} + module.exports = { parse: parse, textNode: textNode, - root: root + root: root, + cleanup: cleanup }; |