summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-asciidoc/lib
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gitbook-asciidoc/lib')
-rwxr-xr-xpackages/gitbook-asciidoc/lib/glossary.js10
-rwxr-xr-xpackages/gitbook-asciidoc/lib/langs.js10
-rwxr-xr-xpackages/gitbook-asciidoc/lib/page.js16
-rwxr-xr-xpackages/gitbook-asciidoc/lib/readme.js12
-rwxr-xr-xpackages/gitbook-asciidoc/lib/summary.js38
-rw-r--r--packages/gitbook-asciidoc/lib/utils/convert.js10
6 files changed, 48 insertions, 48 deletions
diff --git a/packages/gitbook-asciidoc/lib/glossary.js b/packages/gitbook-asciidoc/lib/glossary.js
index c32199c..90ec61f 100755
--- a/packages/gitbook-asciidoc/lib/glossary.js
+++ b/packages/gitbook-asciidoc/lib/glossary.js
@@ -4,21 +4,21 @@ var cheerio = require('cheerio');
var convert = require('./utils/convert');
function parseGlossary(src) {
- var html = convert(src);
+ var html = convert(src);
var $ = cheerio.load(html);
var entries = [];
$("h2").each(function() {
- var $h2 = $(this);
+ var $h2 = $(this);
var $p = $h2.next().find("p");
- var entry = {};
+ var entry = {};
- entry.name = $h2.text();
+ entry.name = $h2.text();
entry.description = $p.text();
- entries.push(entry);
+ entries.push(entry);
});
return entries;
diff --git a/packages/gitbook-asciidoc/lib/langs.js b/packages/gitbook-asciidoc/lib/langs.js
index 672dbd9..3b6257e 100755
--- a/packages/gitbook-asciidoc/lib/langs.js
+++ b/packages/gitbook-asciidoc/lib/langs.js
@@ -3,16 +3,16 @@ var parseEntries = require("./summary").entries;
var parseLangs = function(content) {
- return parseEntries(content);
+ return parseEntries(content);
};
function langsToText(langs) {
var bl = "\n";
- var content = "= Languages"+bl+bl;
+ var content = "= Languages"+bl+bl;
- _.each(langs, function(lang) {
- content = content + ". link:"+lang.path+"["+lang.title+"]"+bl;
- });
+ _.each(langs, function(lang) {
+ content = content + ". link:"+lang.path+"["+lang.title+"]"+bl;
+ });
return content;
}
diff --git a/packages/gitbook-asciidoc/lib/page.js b/packages/gitbook-asciidoc/lib/page.js
index 2bcfe61..ac9d7b0 100755
--- a/packages/gitbook-asciidoc/lib/page.js
+++ b/packages/gitbook-asciidoc/lib/page.js
@@ -4,14 +4,14 @@ var _ = require('lodash');
var convert = require('./utils/convert');
function parsePage(src) {
- return {
- sections: [
- {
- type: "normal",
- content: convert(src)
- }
- ]
- };
+ return {
+ sections: [
+ {
+ type: "normal",
+ content: convert(src)
+ }
+ ]
+ };
}
module.exports = parsePage;
diff --git a/packages/gitbook-asciidoc/lib/readme.js b/packages/gitbook-asciidoc/lib/readme.js
index bdcd3d3..e8b73fa 100755
--- a/packages/gitbook-asciidoc/lib/readme.js
+++ b/packages/gitbook-asciidoc/lib/readme.js
@@ -4,13 +4,13 @@ var cheerio = require('cheerio');
var convert = require('./utils/convert');
function parseReadme(src) {
- var html = convert(src);
- var $ = cheerio.load(html);
+ var html = convert(src);
+ var $ = cheerio.load(html);
- return {
- title: $("h1:first-child").text().trim(),
- description: $("div.paragraph").first().text().trim()
- };
+ return {
+ title: $("h1:first-child").text().trim(),
+ description: $("div.paragraph").first().text().trim()
+ };
}
diff --git a/packages/gitbook-asciidoc/lib/summary.js b/packages/gitbook-asciidoc/lib/summary.js
index 8ba30de..2c9ada0 100755
--- a/packages/gitbook-asciidoc/lib/summary.js
+++ b/packages/gitbook-asciidoc/lib/summary.js
@@ -6,38 +6,38 @@ var convert = require('./utils/convert');
// parse a ul list and return list of chapters recursvely
function parseList($ul, $) {
- var articles = [];
+ var articles = [];
- $ul.children("li").each(function() {
- var article = {};
+ $ul.children("li").each(function() {
+ var article = {};
- var $li = $(this);
- var $p = $li.children("p");
+ var $li = $(this);
+ var $p = $li.children("p");
- article.title = $p.text();
+ article.title = $p.text();
- // Parse link
- var $a = $p.children("a");
- if ($a.length > 0) {
- article.title = $a.first().text();
- article.path = $a.attr("href").replace(/\\/g, '/').replace(/^\/+/, '')
- }
+ // Parse link
+ var $a = $p.children("a");
+ if ($a.length > 0) {
+ article.title = $a.first().text();
+ article.path = $a.attr("href").replace(/\\/g, '/').replace(/^\/+/, '')
+ }
- // Sub articles
- var $sub = $li.children(".olist").children("ol");
- article.articles = parseList($sub, $);
+ // Sub articles
+ var $sub = $li.children(".olist").children("ol");
+ article.articles = parseList($sub, $);
- articles.push(article);
- });
+ articles.push(article);
+ });
- return articles;
+ return articles;
}
function parseSummary(src) {
var chapters = parseEntries(src);
return {
- chapters: chapters
+ chapters: chapters
};
}
diff --git a/packages/gitbook-asciidoc/lib/utils/convert.js b/packages/gitbook-asciidoc/lib/utils/convert.js
index 8a19638..4fb45bd 100644
--- a/packages/gitbook-asciidoc/lib/utils/convert.js
+++ b/packages/gitbook-asciidoc/lib/utils/convert.js
@@ -5,17 +5,17 @@ var processor = null;
var useExtensions = true;
if (useExtensions) {
- processor = asciidoctor.Asciidoctor(true);
+ processor = asciidoctor.Asciidoctor(true);
} else {
- processor = asciidoctor.Asciidoctor();
+ processor = asciidoctor.Asciidoctor();
}
var convert = function(content) {
- var options = opal.hash2(['attributes'], {'attributes': 'showtitle'});
+ var options = opal.hash2(['attributes'], {'attributes': 'showtitle'});
- var html = processor.$convert(content, options);
- return html;
+ var html = processor.$convert(content, options);
+ return html;
};
module.exports = convert;