New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

remark-react

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-react - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

16

history.md

@@ -0,21 +1,23 @@

<!--lint disable no-multiple-toplevel-headings-->
# 2.1.0
* Only allows `http`, `mailto`, and `https` schemes for links.
* Only allows `http`, `mailto`, and `https` schemes for links.
# 2.0.0
* Update to Remark 4
* Update to Remark 4
# 0.3.0
* Added `mdastReactComponents` option #[9](https://github.com/mapbox/mdast-react/pull/9)
* React 0.14 support #[8](https://github.com/mapbox/mdast-react/pull/8)
* Added `mdastReactComponents` option #[9](https://github.com/mapbox/mdast-react/pull/9)
* React 0.14 support #[8](https://github.com/mapbox/mdast-react/pull/8)
# 0.2.0
* Support for Markdown footnotes
* Support for Markdown footnotes
# 0.1.2
* Fix sequential key ordering so that server-side renders
of Markdown will match client-side binding
* Fix sequential key ordering so that server-side renders
of Markdown will match client-side binding

@@ -7,56 +7,84 @@ 'use strict';

var compilers = require('./lib/compilers.js');
var toHAST = require('mdast-util-to-hast');
var sanitize = require('hast-util-sanitize');
var toH = require('hast-to-hyperscript');
try {
var createElement = require('react').createElement;
var globalCreateElement = require('react').createElement;
} catch (e) { }
var own = {}.hasOwnProperty;
var TABLE_ELEMENTS = ['table', 'thead', 'tbody', 'tfoot', 'tr'];
/**
* Attach an HTML compiler.
* Attach a react compiler.
*
* @param {MDAST} remark
* @param {Unified} processor - Instance.
* @param {Object?} [options]
* @param {Object?} [options.sanitize]
* - Sanitation schema.
* @param {Object?} [options.remarkReactComponents]
* - Components.
* @param {string?} [options.prefix]
* - Key prefix.
* @param {Function?} [options.createElement]
* - `h()`.
*/
function plugin(remark, options) {
var MarkdownCompiler = remark.Compiler;
var ancestor = MarkdownCompiler.prototype;
var proto;
var key;
function plugin(processor, options) {
var settings = options || {};
var createElement = settings.createElement || globalCreateElement;
var components = settings.remarkReactComponents || {};
/**
* Extensible prototype.
* Wrapper around `createElement` to pass
* components in.
*
* @param {string} name - Element name.
* @param {Object} props - Attributes.
* @return {ReactElement} - React element.
*/
function ReactCompilerPrototype() {}
function h(name, props, children) {
var component = own.call(components, name) ? components[name] : name;
ReactCompilerPrototype.prototype = ancestor;
/*
* Currently, a warning is triggered by react for
* *any* white-space in tables. So we remove the
* pretty lines for now:
* https://github.com/facebook/react/pull/7081
*/
if (children && TABLE_ELEMENTS.indexOf(name) !== -1) {
children = children.filter(function (child) {
return child !== '\n';
});
}
proto = new ReactCompilerPrototype();
return createElement(name, props, children);
}
proto.options.xhtml = false;
proto.options.sanitize = false;
proto.options.entities = 'true';
/**
* Extensible constructor.
*/
function ReactCompiler(file) {
file.extension = 'html';
function Compiler() {}
MarkdownCompiler.apply(this, [file, options]);
/**
* Compile MDAST to React.
*
* @param {Node} node - MDAST node.
* @return {ReactElement} - React element.
*/
function compile(node) {
var clean = sanitize({
type: 'element',
tagName: 'div',
properties: {},
children: toHAST(node).children
}, settings.sanitize);
this.reactKeyCounter = 0;
return toH(h, clean, settings.prefix);
}
ReactCompiler.prototype = proto;
Compiler.prototype.compile = compile;
/*
* Expose compilers.
*/
for (key in compilers) {
proto[key] = compilers[key];
}
proto.createElement = options && options.createElement || createElement;
remark.Compiler = ReactCompiler;
processor.Compiler = Compiler;
}

@@ -63,0 +91,0 @@

{
"name": "remark-react",
"description": "Compile Markdown to React with remark",
"version": "2.1.0",
"version": "3.0.0",
"author": {

@@ -9,19 +9,27 @@ "name": "Titus Wormer",

},
"contributors": [
"Tom MacWright <tom@macwright.org>",
"Titus Wormer <tituswormer@gmail.com>",
"Ciaran Wood <cyrzinsomnia@gmail.com>",
"Juho Vepsalainen <bebraw@gmail.com>",
"Jason Trill <jason@jasontrill.com>",
"Tsuyusato Kitsune <make.just.on@gmail.com>",
"Jeremy Stucki <jeremy@interactivethings.com>"
],
"dependencies": {
"repeat-string": "^1.5.2"
"hast-to-hyperscript": "^2.0.1",
"hast-util-sanitize": "^1.0.0",
"mdast-util-to-hast": "^1.0.0"
},
"devDependencies": {
"browserify": "^13.0.0",
"commonmark.json": "^0.23.0",
"eslint": "^2.2.0",
"esmangle": "^1.0.1",
"istanbul": "^0.4.2",
"jscs": "^2.10.1",
"jscs-jsdoc": "^1.3.1",
"remark": "^4.1.1",
"remark-comment-config": "^3.0.0",
"remark-github": "^4.0.1",
"remark-lint": "^3.0.0",
"jscs": "^3.0.0",
"jscs-jsdoc": "^2.0.0",
"remark": "^5.0.0",
"remark-cli": "^1.0.0",
"remark-github": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-toc": "^3.0.0",
"remark-yaml-config": "^3.0.0",
"mocha": "^2.4.5",

@@ -32,3 +40,2 @@ "vfile": "^1.3.1"

"index.js",
"lib/",
"LICENSE"

@@ -44,5 +51,2 @@ ],

"license": "MIT",
"peerDependencies": {
"remark": ">=0.25.0"
},
"repository": {

@@ -52,2 +56,3 @@ "type": "git",

},
"bugs": "https://github.com/mapbox/remark-react/issues",
"scripts": {

@@ -62,6 +67,4 @@ "build-md": "remark . --output --quiet",

"test-api": "mocha --check-leaks test/index.js",
"test-coverage": "istanbul cover _mocha -- --check-leaks test/index.js",
"test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test/index.js",
"test-travis": "npm run sub-install && npm run test-coveralls"
"test-coverage": "istanbul cover _mocha -- --check-leaks test/index.js"
}
}

@@ -26,4 +26,2 @@ # remark-react

* [Command line](#command-line)
* [Programmatic](#programmatic)

@@ -35,4 +33,2 @@

* [CommonMark](#commonmark)
* [Integrations](#integrations)

@@ -84,12 +80,14 @@

* `entities` (`true`, `'numbers'`, or `'escape'`, default: `true`)
— How to encode non-ASCII and HTML-escape characters: the default
generates named entities (`&` > `&amp;`); `'numbers'` generates
numbered entities (`&` > `&#x26;`), and `'escape'` only encodes
characters which are required by HTML to be escaped: `&`, `<`, `>`,
`"`, `'`, and `` ` ``, leaving non-ASCII characters untouched.
* `sanitize` (`object`, default: `undefined`)
— Sanitation schema to use. Passed to
[hast-util-sanitize](https://github.com/wooorm/hast-util-sanitize).
The default schema, if none is passed, adheres to GitHub’s sanitation
rules.
* `sanitize` (`boolean`, default: `false`)
— Whether or not to allow the use of HTML inside markdown.
* `prefix` (`string`, default: `h-`)
— React key.
* `createElement` (`Function`, default: `require('react').createElement`)
— Function to use to create elements.
* `remarkReactComponents` (`object`, default: `undefined`)

@@ -100,2 +98,3 @@ — Provides a way to override default elements (`<a>`, `<p>`, etc)

`<a>`, and `<MyParagraph>` instead of `<p>`:
```js

@@ -110,37 +109,2 @@ remarkReactComponents: {

You can define these in `.remarkrc` or `package.json` [files](https://github.com/wooorm/remark/blob/master/doc/remarkrc.5.md)
too. An example `.remarkrc` file could look as follows:
```json
{
"plugins": {
"react": {
"sanitize": false,
"xhtml": false,
"entities": "numbers"
}
},
"settings": {
"commonmark": true
}
}
```
Where the object at `plugins.react` are the options for **remark-react**.
The object at `settings` determines how **remark** parses markdown code.
Read more about the latter on [**remark**’s readme](https://github.com/wooorm/remark#remarkprocessvalue-options-done).
## CommonMark
> You still need to set `commonmark: true` in
> [**remark**’s options](https://github.com/wooorm/remark#remarkprocessvalue-options-done)
[CommonMark](http://commonmark.org) support is a goal but not (yet) a
necessity. There are some (roughly 115 of 550, relating to inline
precedence, lists, emphasis and strongness) issues which I’d like
to cover in the future. Note that this sounds like a lot, but they
have to do with obscure differences which do not often occur in the
real world. Read more on some of the reasoning in
[`doc/commonmark.md`](doc/commonmark.md).
## Integrations

@@ -153,12 +117,8 @@

* [**remark-github**](https://github.com/wooorm/remark-github), which generates
references to GitHub issues, PRs, users, and more;
* [**remark-github**](https://github.com/wooorm/remark-github), which
generates references to GitHub issues, PRs, users, and more;
* [**remark-comment-config**](https://github.com/wooorm/remark-comment-config)
and [**remark-yaml-config**](https://github.com/wooorm/remark-yaml-config),
which specify how HTML is compiled in the document itself;
* ...and [more](https://github.com/wooorm/remark/blob/master/doc/plugins.md#list-of-plugins).
All [**remark** nodes](https://github.com/wooorm/remark/blob/master/doc/nodes.md)
All [**remark** nodes](https://github.com/wooorm/mdast)
can be compiled to HTML. In addition, **remark-react** looks for an

@@ -165,0 +125,0 @@ `attributes` object on each node it compiles and adds the found properties

Sorry, the diff of this file is not supported yet

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