summaryrefslogtreecommitdiffstats
path: root/lib/parse/page.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@friendco.de>2014-04-02 16:40:47 -0700
committerAaron O'Mullan <aaron.omullan@friendco.de>2014-04-02 16:40:51 -0700
commit3adcd77ae42f48b6811609bab5d0cfefed9eac76 (patch)
tree9c7239251c0b7843dc7fef99af96bca740577720 /lib/parse/page.js
parent4bdcfd07a97de370aead0cbb8a9707568c9e4138 (diff)
downloadgitbook-3adcd77ae42f48b6811609bab5d0cfefed9eac76.zip
gitbook-3adcd77ae42f48b6811609bab5d0cfefed9eac76.tar.gz
gitbook-3adcd77ae42f48b6811609bab5d0cfefed9eac76.tar.bz2
Merge sections together, fixes #7
Diffstat (limited to 'lib/parse/page.js')
-rw-r--r--lib/parse/page.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/parse/page.js b/lib/parse/page.js
index 09670b8..505d70f 100644
--- a/lib/parse/page.js
+++ b/lib/parse/page.js
@@ -70,6 +70,19 @@ function parsePage(src) {
.filter(function(section) {
return !_.isEmpty(section);
})
+ .reduce(function(sections, section) {
+ var last = _.last(sections);
+
+ // Merge normal sections together
+ if(last && last.type === section.type && last.type === 'normal') {
+ last.push.apply(last, [{'type': 'hr'}].concat(section));
+ } else {
+ // Add to list of sections
+ sections.push(section);
+ }
+
+ return sections;
+ }, [])
.map(function(section) {
// Generate a uniqueId to identify this section in our code
var id = _.uniqueId('gitbook_');