summaryrefslogtreecommitdiffstats
path: root/lib/parse
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2014-08-11 09:42:18 -0700
committerAaron O'Mullan <aaron.omullan@gmail.com>2014-08-11 09:42:18 -0700
commitd216661f2743385ea760b9993fdd46968e37ee42 (patch)
treede00bb67ffe5728f6175beb1ee0328354aa4f624 /lib/parse
parent74f95f4d0d404e6df533d056a5acab60623407c8 (diff)
parent50dfee99b6880da4be442bd43f475ae87a565c46 (diff)
downloadgitbook-d216661f2743385ea760b9993fdd46968e37ee42.zip
gitbook-d216661f2743385ea760b9993fdd46968e37ee42.tar.gz
gitbook-d216661f2743385ea760b9993fdd46968e37ee42.tar.bz2
Merge pull request #403 from GitbookIO/version/1.0.0
Version 1.0.0
Diffstat (limited to 'lib/parse')
-rw-r--r--lib/parse/git.js56
-rw-r--r--lib/parse/index.js3
-rw-r--r--lib/parse/page.js10
3 files changed, 6 insertions, 63 deletions
diff --git a/lib/parse/git.js b/lib/parse/git.js
deleted file mode 100644
index 18a7cd3..0000000
--- a/lib/parse/git.js
+++ /dev/null
@@ -1,56 +0,0 @@
-var Q = require('q');
-var _ = require('lodash');
-var cp = require('child_process');
-var url = require('url');
-
-// Get the remote of a given repo
-function gitURL(path) {
- var d = Q.defer();
-
- cp.exec("git config --get remote.origin.url", {
- cwd: path,
- env: process.env,
- }, function(err, stdout, stderr) {
- if(err) {
- return d.reject(err);
- }
-
- return d.resolve(stdout);
- });
-
- return d.promise
- .then(function(output) {
- return output.replace(/(\r\n|\n|\r)/gm, "");
- });
-}
-
-// Poorman's parsing
-// Parse a git URL to a github ID : username/reponame
-function githubID(_url) {
- // Remove .git if it's in _url
- var sliceEnd = _url.slice(-4) === '.git' ? -4 : undefined;
-
- // Detect HTTPS repos
- var parsed = url.parse(_url);
- if(parsed.protocol === 'https:' && parsed.host === 'github.com') {
- return parsed.path.slice(1, sliceEnd);
- }
-
- // Detect SSH repos
- if(_url.indexOf('git@') === 0) {
- return _url.split(':', 2)[1].slice(0, sliceEnd);
- }
-
- // None found
- return null;
-}
-
-function titleCase(str) {
- return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
-}
-
-module.exports = {
- url: gitURL,
- githubID: githubID,
- titleCase: titleCase
-};
diff --git a/lib/parse/index.js b/lib/parse/index.js
index bb7779f..0ebb03a 100644
--- a/lib/parse/index.js
+++ b/lib/parse/index.js
@@ -5,6 +5,5 @@ module.exports = {
lex: require('./lex'),
progress: require('./progress'),
navigation: require('./navigation'),
- readme: require('./readme'),
- git: require('./git')
+ readme: require('./readme')
};
diff --git a/lib/parse/page.js b/lib/parse/page.js
index 6ef4a6d..ae71666 100644
--- a/lib/parse/page.js
+++ b/lib/parse/page.js
@@ -82,7 +82,7 @@ function parsePage(src, options) {
return {
id: section.id,
type: section.type,
- content: render(nonCodeNodes),
+ content: render(nonCodeNodes, options),
lang: lang,
code: {
base: ci(codeNodes[0].text),
@@ -104,9 +104,9 @@ function parsePage(src, options) {
if (question && (((node.type === 'list_end' || node.type === 'blockquote_end') && i === quizNodes.length - 1)
|| node.type === 'table' || (node.type === 'paragraph' && !foundFeedback))) {
quiz.push({
- base: render(question.questionNodes),
- solution: render(question.solutionNodes),
- feedback: render(question.feedbackNodes)
+ base: render(question.questionNodes, options),
+ solution: render(question.solutionNodes, options),
+ feedback: render(question.feedbackNodes, options)
});
}
@@ -143,7 +143,7 @@ function parsePage(src, options) {
return {
id: section.id,
type: section.type,
- content: render(nonQuizNodes),
+ content: render(nonQuizNodes, options),
quiz: quiz
};
}