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

remark

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark - npm Package Compare versions

Comparing version 3.2.2 to 3.2.3

6

history.md

@@ -5,2 +5,8 @@ <!--remark setext-->

3.2.3 / 2016-02-07
==================
* Fix entities in shortcut and collapsed references ([`bb1683a`](https://github.com/wooorm/remark/commit/bb1683a))
* Fix subdomains for literal URLs in remark(3) ([`8ff7ab4`](https://github.com/wooorm/remark/commit/8ff7ab4))
3.2.2 / 2016-01-21

@@ -7,0 +13,0 @@ ==================

106

lib/stringify.js

@@ -290,12 +290,14 @@ /**

/**
* Check if a string starts with HTML entity.
* Returns the length of HTML entity that is a prefix of
* the given string (excluding the ampersand), 0 if it
* does not start with an entity.
*
* @example
* startsWithEntity('&copycat') // true
* startsWithEntity('&foo &amp &bar') // false
* entityPrefixLength('&copycat') // 4
* entityPrefixLength('&foo &amp &bar') // 0
*
* @param {string} value - Value to check.
* @return {boolean} - Whether `value` starts an entity.
* @param {string} value - Input string.
* @return {number} - Length of an entity.
*/
function startsWithEntity(value) {
function entityPrefixLength(value) {
var prefix;

@@ -307,3 +309,3 @@

if (value.charAt(0) !== AMPERSAND) {
return false;
return 0;
}

@@ -313,6 +315,20 @@

return decode(prefix).length !== prefix.length;
return prefix.length - decode(prefix).length;
}
/**
* Checks if a string starts with HTML entity.
*
* @example
* startsWithEntity('&copycat') // true
* startsWithEntity('&foo &amp &bar') // false
*
* @param {string} value - Value to check.
* @return {number} - Whether `value` starts an entity.
*/
function startsWithEntity(value) {
return entityPrefixLength(value) > 0;
}
/**
* Check if `character` is a valid alignment row character.

@@ -820,2 +836,36 @@ *

/**
* Shortcut and collapsed link references need no escaping
* and encoding during the processing of child nodes (it
* must be implied from identifier).
*
* This toggler turns encoding and escaping off for shortcut
* and collapsed references.
*
* Implies `enterLink`.
*
* @param {Compiler} compiler - Compiler instance.
* @param {LinkReference} node - LinkReference node.
* @return {Function} - Exit state.
*/
compilerPrototype.enterLinkReference = function (compiler, node) {
var encode = compiler.encode;
var escape = compiler.escape;
var exitLink = compiler.enterLink();
if (
node.referenceType === 'shortcut' ||
node.referenceType === 'collapsed'
) {
compiler.encode = compiler.escape = encodeNoop;
return function () {
compiler.encode = encode;
compiler.escape = escape;
exitLink();
};
} else {
return exitLink;
}
};
/**
* Visit a node.

@@ -1816,19 +1866,21 @@ *

/**
* For shortcut reference links, the contents is also an
* identifier, and for identifiers extra backslashes do
* matter.
* For shortcut and collapsed reference links, the contents
* is also an identifier, so we need to restore the original
* encoding and escaping that were present in the source
* string.
*
* This function takes an escaped value from shortcut's children
* and an identifier and removes extra backslashes.
* This function takes the unescaped & unencoded value from
* shortcut's child nodes and the identifier and encodes
* the former according to the latter.
*
* @example
* unescapeShortcutLinkReference('a\\*b', 'a*b')
* // 'a*b'
* copyIdentifierEncoding('a*b', 'a\\*b*c')
* // 'a\\*b*c'
*
* @param {string} value - Escaped and stringified link value.
* @param {string} identifier - Link identifier, in one of its
* equivalent forms.
* @return {string} - Link value with some characters unescaped.
* @param {string} value - Unescaped and unencoded stringified
* link value.
* @param {string} identifier - Link identifier.
* @return {string} - Encoded link value.
*/
function unescapeShortcutLinkReference(value, identifier) {
function copyIdentifierEncoding(value, identifier) {
var index = 0;

@@ -1876,2 +1928,5 @@ var position = 0;

) {
if (identifier.charAt(position) === AMPERSAND) {
position += entityPrefixLength(identifier.slice(position));
}
position += 1;

@@ -1917,9 +1972,12 @@ }

var self = this;
var exitLink = self.enterLink();
var exitLinkReference = self.enterLinkReference(self, node);
var value = self.all(node).join(EMPTY);
exitLink();
exitLinkReference();
if (node.referenceType == 'shortcut') {
value = unescapeShortcutLinkReference(value, node.identifier);
if (
node.referenceType === 'shortcut' ||
node.referenceType === 'collapsed'
) {
value = copyIdentifierEncoding(value, node.identifier);
}

@@ -1926,0 +1984,0 @@

{
"name": "remark",
"version": "3.2.2",
"version": "3.2.3",
"description": "Markdown processor powered by plugins",

@@ -5,0 +5,0 @@ "license": "MIT",

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