Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitbook-markdown

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbook-markdown - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

26

lib/page.js
var _ = require('lodash');
var kramed = require('kramed');
var hljs = require('highlight.js');

@@ -8,2 +7,26 @@

var RAW_START = "{% raw %}";
var RAW_END = "{% endraw %}";
var CODEBLOCKS = {
md: /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/,
fences: /`([^`]+)`/g
};
function preparePage(src) {
// GFM Fences
src = src.replace(CODEBLOCKS.fences, function(all) {
return RAW_START+all+RAW_END;
});
// Normal codeblocks
src += "~0";
src = src.replace(CODEBLOCKS.md, function(all, m1, m2) {
all = all.slice(0, -m2.length);
return RAW_START+all+RAW_END+m2;
});
src = src.replace(/~0/, "");
return src;
}
function parsePage(src) {

@@ -38,1 +61,2 @@ var options = _.extend({}, kramed.defaults, {

module.exports = parsePage;
module.exports.prepare = preparePage;

2

package.json
{
"name": "gitbook-markdown",
"version": "0.2.4",
"version": "0.3.0",
"homepage": "https://www.gitbook.com",

@@ -5,0 +5,0 @@ "description": "Parse markdown content for gitbook",

@@ -22,2 +22,14 @@ var fs = require('fs');

});
it('should escape codeblocks in preparation', function() {
assert.equal(page.prepare("Hello `world`"), "Hello {% raw %}`world`{% endraw %}");
assert.equal(
page.prepare("Hello\n\n\n\tworld\n\thello\n\n\ntest"),
"Hello\n{% raw %}\n\n\tworld\n\thello\n\n\n{% endraw %}test"
);
assert.equal(
page.prepare("Hello\n\n\n\tworld\n\thello\n\n\n"),
"Hello\n{% raw %}\n\n\tworld\n\thello\n\n\n{% endraw %}"
);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc