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

remarkable

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remarkable - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

lib/rules_inline/sub.js

10

CHANGELOG.md

@@ -0,1 +1,11 @@

1.2.2 / 2014-10-29
------------------
- Fixed regression from 1.2.1 for data without tailing `\n`.
- Fixed blockquote line ranges.
- Added subscript/superscript support.
- Updated CommonMark spec and updated implementation.
- Other minor changes.
1.2.1 / 2014-10-28

@@ -2,0 +12,0 @@ ------------------

2

lib/configs/commonmark.js

@@ -17,3 +17,3 @@ // Commonmark default options

// or '' if input not changed
highlight: function (/*str, , lang*/) { return ''; },
highlight: function (/*str, lang*/) { return ''; },

@@ -20,0 +20,0 @@ maxNesting: 20 // Internal protection, recursion limit

@@ -17,3 +17,3 @@ // Remarkable default options

// or '' if input not changed
highlight: function (/*str, , lang*/) { return ''; },
highlight: function (/*str, lang*/) { return ''; },

@@ -20,0 +20,0 @@ maxNesting: 20 // Internal protection, recursion limit

@@ -17,3 +17,3 @@ // Remarkable default options

// or '' if input not changed
highlight: function (/*str, , lang*/) { return ''; },
highlight: function (/*str, lang*/) { return ''; },

@@ -20,0 +20,0 @@ maxNesting: 20 // Internal protection, recursion limit

'use strict';
var unescapeMd = require('./common/utils').unescapeMd;
//

@@ -63,4 +67,4 @@ // Parse link label

var code, level,
max = state.posMax,
href = '';
start = pos,
max = state.posMax;

@@ -74,12 +78,11 @@ if (state.src.charCodeAt(pos) === 0x3C /* < */) {

state.pos = pos + 1;
state.linkContent = href;
state.linkContent = unescapeMd(state.src.slice(start + 1, pos));
return true;
}
if (code === 0x5C /* \ */ && pos + 1 < max) {
pos++;
href += state.src[pos++];
pos += 2;
continue;
}
href += state.src[pos++];
pos++;
}

@@ -103,4 +106,3 @@

if (code === 0x5C /* \ */ && pos + 1 < max) {
pos++;
href += state.src[pos++];
pos += 2;
continue;

@@ -119,11 +121,11 @@ }

href += state.src[pos++];
pos++;
}
if (!href.length) { return false; }
if (start === pos) { return false; }
if (!state.parser.validateLink(href)) { return false; }
state.linkContent = unescapeMd(state.src.slice(start, pos));
if (!state.parser.validateLink(state.linkContent)) { return false; }
state.pos = pos;
state.linkContent = href;
return true;

@@ -138,3 +140,4 @@ }

function parseLinkTitle(state, pos) {
var title, code,
var code,
start = pos,
max = state.posMax,

@@ -146,3 +149,2 @@ marker = state.src.charCodeAt(pos);

pos++;
title = '';

@@ -156,12 +158,11 @@ // if opening marker is "(", switch it to closing marker ")"

state.pos = pos + 1;
state.linkContent = title;
state.linkContent = unescapeMd(state.src.slice(start + 1, pos));
return true;
}
if (code === 0x5C /* \ */ && pos + 1 < max) {
pos++;
title += state.src[pos++];
pos += 2;
continue;
}
title += state.src[pos++];
pos++;
}

@@ -168,0 +169,0 @@

@@ -22,2 +22,4 @@ // Inline parser

_rules.push(require('./rules_inline/emphasis'));
_rules.push(require('./rules_inline/sub'));
_rules.push(require('./rules_inline/sup'));
_rules.push(require('./rules_inline/links'));

@@ -53,3 +55,3 @@ _rules.push(require('./rules_inline/autolink'));

// - '{}$%@+=:' reserved for extentions
this.textMatch = /[\n\\`*_\[\]!&<{}$%@~+=:]/;
this.textMatch = /[\n\\`*_^\[\]!&<{}$%@~+=:]/;

@@ -56,0 +58,0 @@ // By default CommonMark allows too much in links

@@ -243,2 +243,10 @@ 'use strict';

rules.sub = function(tokens, idx/*, options*/) {
return '<sub>' + escapeHtml(tokens[idx].content) + '</sub>';
};
rules.sup = function(tokens, idx/*, options*/) {
return '<sup>' + escapeHtml(tokens[idx].content) + '</sup>';
};
rules.hardbreak = function (tokens, idx, options) {

@@ -245,0 +253,0 @@ return options.xhtmlOut ? '<br />\n' : '<br>\n';

@@ -119,3 +119,3 @@ // Block quotes

state.parentType = oldParentType;
lines[1] = state.lines;
lines[1] = state.line;

@@ -122,0 +122,0 @@ // Restore original tShift; this might not be necessary since the parser

@@ -58,2 +58,7 @@ // fences (``` lang, ~~~ lang)

if (state.tShift[nextLine] - state.blkIndent >= 4) {
// closing fence should be indented less than 4 spaces
continue;
}
pos = state.skipChars(pos, marker);

@@ -60,0 +65,0 @@

@@ -7,3 +7,3 @@ // heading (#, ##, ...)

module.exports = function heading(state, startLine, endLine, silent) {
var ch, level,
var ch, level, tmp,
pos = state.bMarks[startLine] + state.tShift[startLine],

@@ -28,23 +28,12 @@ max = state.eMarks[startLine];

// skip spaces before heading text
pos = state.skipSpaces(pos);
if (silent) { return true; }
// Now pos contains offset of first heared char
// Let's cut tails like ' ### ' from the end of string
max = state.skipCharsBack(max, 0x20/* space */, pos);
max = state.skipCharsBack(max, 0x23/* # */, pos);
if (max < state.eMarks[startLine] &&
state.src.charCodeAt(max) === 0x23/* # */ &&
state.src.charCodeAt(max - 1) === 0x5C/* \ */) {
max++;
tmp = state.skipCharsBack(max, 0x23/* # */, pos);
if (tmp > pos && state.src.charCodeAt(tmp - 1) === 0x20/* space */) {
max = tmp;
}
// ## Foo ####
// ^^^
max = state.skipCharsBack(max, 0x20/* space */, pos);
if (silent) { return true; }
state.line = startLine + 1;

@@ -51,0 +40,0 @@

@@ -60,2 +60,3 @@ // Parser state class

if (ch === 0x0A || pos === len - 1) {
if (ch !== 0x0A) { pos++; }
this.bMarks.push(start);

@@ -62,0 +63,0 @@ this.eMarks.push(pos);

@@ -8,2 +8,3 @@ // Process ~~deleted text~~

pos,
stack,
max = state.posMax,

@@ -15,9 +16,5 @@ start = state.pos,

if (state.src.charCodeAt(start) !== 0x7E/* ~ */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 4 >= max) { return false; }
if (state.src.charCodeAt(start + 1) !== 0x7E/* ~ */) { return false; }
// make del lower a priority tag with respect to links, same as <em>;
// this code also prevents recursion
if (silent && state.isInLabel) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

@@ -34,4 +31,4 @@

while (pos < max && state.src.charCodeAt(pos) === 0x7E/* ~ */) { pos++; }
if (pos !== start + 2) {
// sequence of 3+ markers taking as literal, same as in a emphasis
if (pos > start + 3) {
// sequence of 4+ markers taking as literal, same as in a emphasis
state.pos += pos - start;

@@ -43,2 +40,3 @@ if (!silent) { state.pending += state.src.slice(start, pos); }

state.pos = start + 2;
stack = 1;

@@ -53,2 +51,10 @@ while (state.pos + 1 < max) {

// closing '~~'
stack--;
} else if (nextChar !== 0x20 && nextChar !== 0x0A) {
// opening '~~'
stack++;
} // else {
// // standalone ' ~~ ' indented with spaces
//}
if (stack <= 0) {
found = true;

@@ -55,0 +61,0 @@ break;

@@ -64,8 +64,4 @@ // Process *this* and _that_

if (marker !== 0x5F/* _ */ && marker !== 0x2A /* * */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
// skip emphasis in links because it has lower priority, compare:
// [foo *bar]()*
// [foo `bar]()`
if (silent && state.isInLabel) { return false; }
res = scanDelims(state, start);

@@ -114,2 +110,6 @@ startCount = res.delims;

}
if (res.can_open) { stack.push(count); }
state.pos += count;
continue;
}

@@ -116,0 +116,0 @@

@@ -1,2 +0,2 @@

// Proceess html entity - &#123;, &#xAF;, &quot;, ...
// Process html entity - &#123;, &#xAF;, &quot;, ...

@@ -3,0 +3,0 @@ 'use strict';

@@ -8,2 +8,3 @@ // Process ++inserted text++

pos,
stack,
max = state.posMax,

@@ -15,9 +16,5 @@ start = state.pos,

if (state.src.charCodeAt(start) !== 0x2B/* + */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 4 >= max) { return false; }
if (state.src.charCodeAt(start + 1) !== 0x2B/* + */) { return false; }
// make ins lower a priority tag with respect to links, same as <em>;
// this code also prevents recursion
if (silent && state.isInLabel) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

@@ -42,2 +39,3 @@

state.pos = start + 2;
stack = 1;

@@ -52,2 +50,10 @@ while (state.pos + 1 < max) {

// closing '++'
stack--;
} else if (nextChar !== 0x20 && nextChar !== 0x0A) {
// opening '++'
stack++;
} // else {
// // standalone ' ++ ' indented with spaces
//}
if (stack <= 0) {
found = true;

@@ -54,0 +60,0 @@ break;

@@ -1,8 +0,9 @@

// Process ++inserted text++
// Process ==highlighted text==
'use strict';
module.exports = function mark(state, silent) {
module.exports = function del(state, silent) {
var found,
pos,
stack,
max = state.posMax,

@@ -14,9 +15,5 @@ start = state.pos,

if (state.src.charCodeAt(start) !== 0x3D/* = */) { return false; }
if (silent) { return false; } // don't run any pairs in validation mode
if (start + 4 >= max) { return false; }
if (state.src.charCodeAt(start + 1) !== 0x3D/* = */) { return false; }
// make ins lower a priority tag with respect to links, same as <em>;
// this code also prevents recursion
if (silent && state.isInLabel) { return false; }
if (state.level >= state.options.maxNesting) { return false; }

@@ -41,2 +38,3 @@

state.pos = start + 2;
stack = 1;

@@ -50,3 +48,11 @@ while (state.pos + 1 < max) {

if (lastChar !== 0x20 && lastChar !== 0x0A) {
// closing '++'
// closing '=='
stack--;
} else if (nextChar !== 0x20 && nextChar !== 0x0A) {
// opening '=='
stack++;
} // else {
// // standalone ' == ' indented with spaces
//}
if (stack <= 0) {
found = true;

@@ -53,0 +59,0 @@ break;

@@ -1,2 +0,2 @@

// Skip text characters for text token, place those to pendibg buffer
// Skip text characters for text token, place those to pending buffer
// and increment current pos

@@ -3,0 +3,0 @@

{
"name": "remarkable",
"version": "1.2.1",
"version": "1.2.2",
"description": "Markdown parser, done right. Commonmark support, extensions, syntax plugins, high speed - all in one.",

@@ -21,5 +21,9 @@ "keywords": [

"main": "index.js",
"scripts": {
"test": "make test"
},
"dependencies": {
"argparse": "~ 0.1.15",
"autolinker": "~ 0.12.3"
"autolinker": "~ 0.12.3",
"coveralls": "^2.11.2"
},

@@ -26,0 +30,0 @@ "devDependencies": {

@@ -5,2 +5,3 @@ # remarkable

[![NPM version](https://img.shields.io/npm/v/remarkable.svg)](https://www.npmjs.org/package/remarkable)
[![Coverage Status](https://img.shields.io/coveralls/jonschlinkert/remarkable.svg)](https://coveralls.io/r/jonschlinkert/remarkable?branch=dev)

@@ -31,11 +32,7 @@ > Markdown parser done right. Fast and easy to extend.

**browser:**
**browser (CDN):**
The following CDN's host remarkable:
- [jsDeliver CDN](http://www.jsdelivr.com/#!remarkable "jsDelivr CDN")
- [jsDeliver](http://www.jsdelivr.com/#!remarkable "jsDelivr CDN")
If you add remarkable to a CDN, please [let us know](https://github.com/jonschlinkert/remarkable/issues) or do PR to add it to the readme!
## Usage

@@ -47,3 +44,3 @@

console.log(md.parse('# Remarkable rulezz!'));
console.log(md.render('# Remarkable rulezz!'));
// => <h1>Remarkable rulezz!</h1>

@@ -55,4 +52,4 @@ ```

By default remarkable is configured to be similar to GFM, but with HTML disabled. This is easy to change
if you prefer to use different settings.
By default remarkable is configured to be similar to GFM, but with HTML disabled.
This is easy to change if you prefer to use different settings.

@@ -77,3 +74,3 @@ There are two ways to define options.

// or '' if the source string is not changed
highlight: function (/*str, , lang*/) { return ''; }
highlight: function (/*str, lang*/) { return ''; }
});

@@ -99,5 +96,6 @@

**Note:** To achieve the best possible performance, don't modify a `Remarkable` instance on
the fly. If you need multiple configurations it's best to create multiple instances and initialize
each with a configuration that is ideal for that instance.
**Note:** To achieve the best possible performance, don't modify a `Remarkable`
instance on the fly. If you need multiple configurations it's best to create
multiple instances and initialize each with a configuration that is ideal for
that instance.

@@ -107,4 +105,4 @@

Remarkable offers some "presets" as a convenience to quickly enable/disable active syntax rules and options
for common use cases.
Remarkable offers some "presets" as a convenience to quickly enable/disable
active syntax rules and options for common use cases.

@@ -122,3 +120,3 @@ #### commonmark

Enable everything with the `full` preset:
Enable all available rules (but still with default options, if not set):

@@ -128,2 +126,9 @@ ```js

var md = new Remarkable('full');
// Or with options:
var md = new Remarkable('full', {
html: true,
linkify: true,
typographer: true
});
```

@@ -164,11 +169,15 @@

- [Tables](https://help.github.com/articles/github-flavored-markdown/#tables) (GFM)
- [\<del>](https://help.github.com/articles/github-flavored-markdown/#strikethrough) (GFM strikethrough) - `~~deleted text~~`
- [\<del>](https://help.github.com/articles/github-flavored-markdown/#strikethrough)
(GFM strikethrough) - `~~deleted text~~`
Disabled by default:
- [\<sup](http://johnmacfarlane.net/pandoc/README.html#superscripts-and-subscripts) - `19^th^`
- [\<sub>](http://johnmacfarlane.net/pandoc/README.html#superscripts-and-subscripts) - `H~2~0`
- __\<ins>__ - `++inserted text++` (experimental)
- __\<mark>__ - `==marked text==` (experimental)
__*__ Experimental extentions can be changed later for something like [Critic Markup](http://criticmarkup.com/), but you will
still be able to use old-style rules via external plugins if you prefer.
__*__ Experimental extentions can be changed later for something like
[Critic Markup](http://criticmarkup.com/), but you will still be able to use
old-style rules via external plugins if you prefer.

@@ -175,0 +184,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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