gitbook-markdown
Advanced tools
Comparing version 0.5.3 to 1.0.0
@@ -1,10 +0,8 @@ | ||
var kramed = require("kramed"); | ||
var _ = require("lodash"); | ||
var htmlParser = require('gitbook-html'); | ||
module.exports = { | ||
summary: require("./summary"), | ||
glossary: require("./glossary"), | ||
langs: require("./langs"), | ||
readme: require("./readme"), | ||
page: require("./page") | ||
}; | ||
var toHTML = require('./tohtml'); | ||
var toMarkdown = require('./tomarkdown'); | ||
var page = require('./page'); | ||
module.exports = htmlParser.createParser(toHTML, toMarkdown); | ||
module.exports.page.prepare = page.prepare; |
var _ = require('lodash'); | ||
var kramed = require('kramed'); | ||
var annotate = require('kramed/lib/annotate/'); | ||
var RAW_START = "{% raw %}"; | ||
var RAW_END = "{% endraw %}"; | ||
var RAW_START = '{% raw %}'; | ||
var RAW_END = '{% endraw %}'; | ||
@@ -18,2 +17,3 @@ function escape(str) { | ||
// Add templating "raw" to code blocks | ||
function preparePage(src) { | ||
@@ -58,26 +58,4 @@ var lexed = annotate.blocks(src); | ||
function parsePage(src) { | ||
var options = _.extend({}, kramed.defaults, { | ||
mathjax: false, | ||
renderer: new kramed.Renderer({ | ||
langPrefix: 'lang-', | ||
smartypants: false, | ||
headerPrefix: '', | ||
headerAutoId: false, | ||
xhtml: false | ||
}) | ||
}); | ||
return { | ||
sections: [ | ||
{ | ||
type: "normal", | ||
content: kramed(src, options) | ||
} | ||
] | ||
}; | ||
} | ||
// Exports | ||
module.exports = parsePage; | ||
module.exports.prepare = preparePage; | ||
module.exports = { | ||
prepare: preparePage | ||
}; |
{ | ||
"name": "gitbook-markdown", | ||
"version": "0.5.3", | ||
"version": "1.0.0", | ||
"homepage": "https://www.gitbook.com", | ||
@@ -10,9 +10,10 @@ "description": "Parse markdown content for gitbook", | ||
"kramed": "0.5.5", | ||
"kramed-text-renderer": "0.2.1" | ||
"kramed-text-renderer": "0.2.1", | ||
"gitbook-html": "1.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "2.3.3" | ||
"mocha": "^2.3.3" | ||
}, | ||
"scripts": { | ||
"test": "export TESTING=true; mocha --reporter list" | ||
"test": "export TESTING=true; mocha --reporter list --bail" | ||
}, | ||
@@ -19,0 +20,0 @@ "repository": { |
@@ -1,2 +0,2 @@ | ||
# Magic | ||
## Magic | ||
Sufficiently advanced technology, beyond the understanding of the observer producing a sense of wonder. | ||
@@ -6,9 +6,9 @@ | ||
# PHP | ||
## PHP | ||
An atrocious language, invented for the sole purpose of inflicting pain and suffering amongst the proframming wizards of this world. | ||
# Clojure | ||
## Clojure | ||
Lisp re-invented for hipsters. | ||
# Go | ||
## Go | ||
Go Go Google [Wow](https://www.google.com) | ||
@@ -29,4 +29,4 @@ | ||
# Gitbook | ||
## Gitbook | ||
Awesome project. Really amazing, I'm really at a loss for words ... |
@@ -7,6 +7,10 @@ var fs = require('fs'); | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.md'), 'utf8'); | ||
var LEXED = glossary(CONTENT); | ||
describe('Glossary parsing', function () { | ||
var LEXED; | ||
describe('Glossary parsing', function () { | ||
before(function() { | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/GLOSSARY.md'), 'utf8'); | ||
LEXED = glossary(CONTENT); | ||
}); | ||
it('should only get heading + paragraph pairs', function() { | ||
@@ -23,5 +27,5 @@ assert.equal(LEXED.length, 5); | ||
it('should correctly convert it to text', function() { | ||
var text = glossary.toText(LEXED); | ||
assertObjectsEqual(glossary(text), LEXED); | ||
var text = glossary.toText(LEXED); | ||
assertObjectsEqual(glossary(text), LEXED); | ||
}); | ||
}); |
@@ -7,6 +7,10 @@ var fs = require('fs'); | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/LANGS.md'), 'utf8'); | ||
var LEXED = langs(CONTENT); | ||
describe('Languages parsing', function () { | ||
var LEXED; | ||
describe('Languages parsing', function () { | ||
before(function() { | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/LANGS.md'), 'utf8'); | ||
LEXED = langs(CONTENT); | ||
}); | ||
it('should detect paths and titles', function() { | ||
@@ -13,0 +17,0 @@ assert.equal(LEXED.length, 2); |
@@ -7,21 +7,18 @@ var fs = require('fs'); | ||
function loadPage (name, options) { | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/' + name + '.md'), 'utf8'); | ||
return page(CONTENT, options).sections; | ||
} | ||
var LEXED = loadPage('PAGE'); | ||
describe('Page parsing', function() { | ||
var LEXED; | ||
describe('Page parsing', function() { | ||
it('should detect sections', function() { | ||
assert.equal(LEXED.length, 1); | ||
before(function() { | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/PAGE.md'), 'utf8'); | ||
LEXED = page(CONTENT); | ||
}); | ||
it('should gen content for normal sections', function() { | ||
assert(LEXED[0].content); | ||
it('should gen content', function() { | ||
assert(LEXED.content); | ||
}); | ||
it('should not add id to headings', function() { | ||
assert.equal(page('# Hello').sections[0].content, '<h1>Hello</h1>\n'); | ||
assert.equal(page('# Hello {#test}').sections[0].content, '<h1 id="test">Hello </h1>\n'); | ||
assert.equal(page('# Hello').content, '<h1>Hello</h1>\n'); | ||
assert.equal(page('# Hello {#test}').content, '<h1 id="test">Hello </h1>\n'); | ||
}); | ||
@@ -28,0 +25,0 @@ |
@@ -7,8 +7,10 @@ var fs = require('fs'); | ||
describe('Readme parsing', function () { | ||
var LEXED; | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/README.md'), 'utf8'); | ||
var LEXED = readme(CONTENT); | ||
before(function() { | ||
var CONTENT = fs.readFileSync(path.join(__dirname, './fixtures/README.md'), 'utf8'); | ||
LEXED = readme(CONTENT); | ||
}); | ||
describe('Readme parsing', function () { | ||
it('should contain a title', function() { | ||
@@ -15,0 +17,0 @@ assert(LEXED.title); |
@@ -16,38 +16,48 @@ var fs = require('fs'); | ||
var LEXED = lex('SUMMARY.md'); | ||
describe('Summary parsing', function () { | ||
var LEXED; | ||
describe('Summary parsing', function () { | ||
before(function() { | ||
LEXED = lex('SUMMARY.md'); | ||
PART = LEXED.parts[0]; | ||
}); | ||
it('should detect chapters', function() { | ||
assert.equal(LEXED.chapters.length, 5); | ||
assert.equal(PART.articles.length, 5); | ||
}); | ||
it('should support articles', function() { | ||
assert.equal(LEXED.chapters[0].articles.length, 2); | ||
assert.equal(LEXED.chapters[1].articles.length, 0); | ||
assert.equal(LEXED.chapters[2].articles.length, 0); | ||
assert.equal(PART.articles[0].articles.length, 2); | ||
assert.equal(PART.articles[1].articles.length, 0); | ||
assert.equal(PART.articles[2].articles.length, 0); | ||
}); | ||
it('should detect paths and titles', function() { | ||
assert(LEXED.chapters[0].path); | ||
assert(LEXED.chapters[1].path); | ||
assert(LEXED.chapters[2].path); | ||
assert(LEXED.chapters[3].path); | ||
assert.equal(LEXED.chapters[4].path, null); | ||
assert(PART.articles[0].path); | ||
assert(PART.articles[1].path); | ||
assert(PART.articles[2].path); | ||
assert(PART.articles[3].path); | ||
assert.equal(PART.articles[4].path, null); | ||
assert(LEXED.chapters[0].title); | ||
assert(LEXED.chapters[1].title); | ||
assert(LEXED.chapters[2].title); | ||
assert(LEXED.chapters[3].title); | ||
assert(LEXED.chapters[4].title); | ||
assert(PART.articles[0].title); | ||
assert(PART.articles[1].title); | ||
assert(PART.articles[2].title); | ||
assert(PART.articles[3].title); | ||
assert(PART.articles[4].title); | ||
}); | ||
it('should normalize paths from .md', function() { | ||
assert.equal(LEXED.chapters[0].path,'chapter-1/README.md'); | ||
assert.equal(LEXED.chapters[1].path,'chapter-2/README.md'); | ||
assert.equal(LEXED.chapters[2].path,'chapter-3/README.md'); | ||
assert.equal(PART.articles[0].path,'chapter-1/README.md'); | ||
assert.equal(PART.articles[1].path,'chapter-2/README.md'); | ||
assert.equal(PART.articles[2].path,'chapter-3/README.md'); | ||
}); | ||
it('should part parts', function() { | ||
var l = lex('SUMMARY_PARTS.md'); | ||
assert.equal(l.parts.length, 3); | ||
}); | ||
it('should allow lists separated by whitespace', function() { | ||
var l = lex('SUMMARY_WHITESPACE.md'); | ||
assert.equal(l.chapters.length, 5); | ||
assert.equal(l.parts[0].articles.length, 5); | ||
}); | ||
@@ -57,14 +67,5 @@ | ||
var l = lex('SUMMARY_EMPTY.md'); | ||
assert.equal(l.chapters.length, 1); | ||
assert.equal(l.parts[0].articles.length, 1); | ||
}); | ||
it('should throw error for sublist entries', function() { | ||
assert.throws( | ||
function() { | ||
var l = lex('SUMMARY_SUBLIST.md'); | ||
}, | ||
"Invalid entry in the SUMMARY" | ||
); | ||
}); | ||
it('should correctly convert it to text', function() { | ||
@@ -71,0 +72,0 @@ var text = summary.toText(LEXED); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
14777
4
23
302
1
+ Addedgitbook-html@1.0.0
+ Addedabab@1.0.4(transitive)
+ Addedacorn@2.7.0(transitive)
+ Addedacorn-globals@1.0.9(transitive)
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedboolbase@1.0.0(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcheerio@0.20.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.21.0.3(transitive)
+ Addedcss-select@1.2.0(transitive)
+ Addedcss-what@2.1.3(transitive)
+ Addedcssom@0.3.8(transitive)
+ Addedcssstyle@0.2.37(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddom-serializer@0.1.1(transitive)
+ Addeddomelementtype@1.3.1(transitive)
+ Addeddomhandler@2.3.0(transitive)
+ Addeddomutils@1.5.1(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedentities@1.0.01.1.2(transitive)
+ Addedescodegen@1.14.3(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedestraverse@4.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfast-levenshtein@2.0.6(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedgitbook-html@1.0.0(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhtmlparser2@3.8.3(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjsdom@7.2.2(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedlevn@0.3.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addednth-check@1.0.2(transitive)
+ Addednwmatcher@1.4.4(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedoptionator@0.8.3(transitive)
+ Addedparse5@1.5.1(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedprelude-ls@1.1.2(transitive)
+ Addedpsl@1.13.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedq@1.5.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedreadable-stream@1.1.14(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedsymbol-tree@3.2.4(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addedtype-check@0.3.2(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
+ Addedwebidl-conversions@2.0.1(transitive)
+ Addedwhatwg-url-compat@0.6.5(transitive)
+ Addedword-wrap@1.2.5(transitive)
+ Addedxml-name-validator@2.0.1(transitive)