summaryrefslogtreecommitdiffstats
path: root/lib/parse/page.js
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@friendco.de>2014-03-31 15:03:04 -0700
committerAaron O'Mullan <aaron.omullan@friendco.de>2014-03-31 15:03:06 -0700
commita8e0de86e94686757f809d1e987e2e025ab8d35d (patch)
treec93333f3c4d3b8562207b67d2232f878a7efb9aa /lib/parse/page.js
parent6261d42b955bfad9dab3ed6c2faebce956c64eb2 (diff)
downloadgitbook-a8e0de86e94686757f809d1e987e2e025ab8d35d.zip
gitbook-a8e0de86e94686757f809d1e987e2e025ab8d35d.tar.gz
gitbook-a8e0de86e94686757f809d1e987e2e025ab8d35d.tar.bz2
Generate a unique Id for each section
Diffstat (limited to 'lib/parse/page.js')
-rw-r--r--lib/parse/page.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/parse/page.js b/lib/parse/page.js
index 7c188eb..6481e65 100644
--- a/lib/parse/page.js
+++ b/lib/parse/page.js
@@ -56,6 +56,9 @@ function parsePage(src) {
return section;
})
.map(function(section) {
+ // Generate a uniqueId to identify this section in our code
+ var id = _.uniqueId('gitbook_');
+
// Transform given type
if(section.type === 'exercise') {
var nonCodeNodes = _.reject(section, {
@@ -67,6 +70,7 @@ function parsePage(src) {
});
return {
+ id: id,
type: section.type,
content: render(nonCodeNodes),
code: {
@@ -79,6 +83,7 @@ function parsePage(src) {
// Render normal pages
return {
+ id: id,
type: section.type,
content: render(section)
};