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

remark-yaml-config

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-yaml-config - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0-alpha.1

27

history.md

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

---
remark:
setext: true
---
<!--remark setext-->

@@ -31,23 +28,1 @@ <!--lint disable no-multiple-toplevel-headings-->

==================
* Update dependencies, dev-dependencies ([101004f](https://github.com/wooorm/remark-yaml-config/commit/101004f))
0.2.1 / 2015-07-12
==================
* Remove peer-dependencies ([cdc9072](https://github.com/wooorm/remark-yaml-config/commit/cdc9072))
0.2.0 / 2015-06-13
==================
* Remove `.npmignore` in favour of `files` in `package.json` ([4e793f4](https://github.com/wooorm/remark-yaml-config/commit/4e793f4))
* Add mdast-lint as a dev-dependency ([0a18b6b](https://github.com/wooorm/remark-yaml-config/commit/0a18b6b))
* Refactor to use `file` for throwing errors ([5428eeb](https://github.com/wooorm/remark-yaml-config/commit/5428eeb))
* Refactor lint targets ([8988d83](https://github.com/wooorm/remark-yaml-config/commit/8988d83))
* Add `.editorconfig` ([039028e](https://github.com/wooorm/remark-yaml-config/commit/039028e))
* Remove superfluous comments ([216735d](https://github.com/wooorm/remark-yaml-config/commit/216735d))
* Update mdast, mdast-yaml ([05b9890](https://github.com/wooorm/remark-yaml-config/commit/05b9890))
* Update browserify, eslint, jscs-jsdoc ([2f092fe](https://github.com/wooorm/remark-yaml-config/commit/2f092fe))
0.1.0 / 2015-03-28
==================

62

index.js

@@ -17,46 +17,54 @@ /**

var yaml = require('remark-yaml');
var jsYAML = require('js-yaml');
/**
* No-operation.
*/
function noop() {}
/**
* Wrapper factory.
*
* @param {Function} method - Type to wrap.
* @return {Function} - Wrapper.
* @param {Function} original - Spied on function.
* @return {Function} - Spy.
*/
function factory(method) {
var callback = method || noop;
function factory(original) {
/**
* Replacer for tokeniser or visitor.
*
* @param {Node|Function} node - Node, when visitor,
* or `eat`.
* @return {*} - Result of the spied on function.
*/
function replacement(node) {
var self = this;
var result = original.apply(self, arguments);
var marker = result && result.type ? result : node;
var data;
return function (node, instance) {
var config = node.yaml && node.yaml.remark;
try {
data = jsYAML.safeLoad(marker.value);
data = data && data.remark;
if (config) {
try {
instance.setOptions(config);
} catch (exception) {
instance.file.fail(exception.message, node);
if (data) {
self.setOptions(data);
}
} catch (exception) {
self.file.fail(exception.message, marker);
}
callback.apply(this, arguments);
};
return result;
}
replacement.locator = original.locator;
return replacement;
}
/**
* Modify remark to parse/stringify YAML.
* Modify remark to read configuration from comments.
*
* @param {Remark} remark - Instance.
* @param {Object?} [options] - Plug-in configuration.
*/
function attacher(remark, options) {
var settings = options || {};
function attacher(remark) {
var parser = remark.Parser.prototype.blockTokenizers;
var compiler = remark.Compiler.prototype.visitors;
settings.onparse = factory(settings.onparse);
settings.onstringify = factory(settings.onstringify);
remark.use(yaml, settings);
parser.yamlFrontMatter = factory(parser.yamlFrontMatter);
compiler.yaml = factory(compiler.yaml);
}

@@ -63,0 +71,0 @@

{
"name": "remark-yaml-config",
"version": "2.0.2",
"version": "3.0.0-alpha.1",
"description": "Configure remark with YAML front-matter",

@@ -14,6 +14,16 @@ "license": "MIT",

"dependencies": {
"remark-yaml": "^2.0.0"
"js-yaml": "^3.5.2"
},
"repository": "wooorm/remark-yaml-config",
"author": "Titus Wormer <tituswormer@gmail.com>",
"repository": {
"type": "git",
"url": "https://github.com/wooorm/remark-yaml-config.git"
},
"bugs": "https://github.com/wooorm/remark-yaml-config/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
],
"engines": {
"node": ">=0.10.0"
},
"files": [

@@ -23,3 +33,3 @@ "index.js"

"devDependencies": {
"browserify": "^12.0.0",
"browserify": "^13.0.0",
"eslint": "^1.0.0",

@@ -30,7 +40,9 @@ "esmangle": "^1.0.0",

"jscs-jsdoc": "^1.0.0",
"remark": "^3.0.0",
"remark-github": "^2.0.0",
"remark": "^4.0.0-alpha.2",
"remark-comment-config": "^3.0.0-alpha.1",
"remark-github": "^4.0.1",
"remark-lint": "^2.0.0",
"remark-toc": "^2.0.0",
"remark-slug": "^4.0.0",
"remark-usage": "^2.0.0",
"remark-validate-links": "^2.0.2",
"tape": "^4.0.0"

@@ -37,0 +49,0 @@ },

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

# remark-yaml-config [![Build Status](https://img.shields.io/travis/wooorm/remark-yaml-config.svg)](https://travis-ci.org/wooorm/remark-yaml-config) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/remark-yaml-config.svg)](https://codecov.io/github/wooorm/remark-yaml-config)
# remark-yaml-config [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

@@ -7,3 +7,3 @@ Configure **remark** with YAML front-matter.

[npm](https://docs.npmjs.com/cli/install)
[npm][npm-install]:

@@ -14,22 +14,18 @@ ```bash

**remark-yaml-config** is also available for [duo](http://duojs.org/#getting-started),
and as an AMD, CommonJS, and globals module, [uncompressed and
compressed](https://github.com/wooorm/remark-yaml-config/releases).
**remark-yaml-config** is also available as an AMD, CommonJS, and
globals module, [uncompressed and compressed][releases].
## Table of Contents
## Usage
* [Usage](#usage)
Dependencies:
* [API](#api)
```javascript
var remark = require('remark');
var config = require('remark-yaml-config');
```
* [remark.use(yamlConfig, options)](#remarkuseyamlconfig-options)
Process:
* [License](#license)
## Usage
```javascript
var yamlConfig = require('remark-yaml-config');
var remark = require('remark').use(yamlConfig);
var input = [
var doc = remark().use(config).process([
'---',

@@ -45,12 +41,7 @@ 'remark:',

''
].join('\n');
var tree = remark.parse(input);
].join('\n'));
```
Stringifying the document yields:
Yields:
```javascript
var doc = remark.stringify(tree);
```
```markdown

@@ -60,3 +51,3 @@ ---

commonmark: true
bullet: '*'
bullet: "*"
---

@@ -71,22 +62,29 @@

### [remark](https://github.com/wooorm/remark#api).[use](https://github.com/wooorm/remark#remarkuseplugin-options)(yamlConfig, options)
### `remark.use(yamlConfig)`
Passes the [configuration](https://github.com/wooorm/remark/blob/master/doc/Options.md)
found in YAML front-matter (under the `remark` key) to **remark**.
Passes the [configuration][remark-config] found in YAML front-matter
(under the `remark` key) to **remark**.
This is especially useful if you’re using **remark**’s [CLI](https://github.com/wooorm/remark#cli),
which allows multiple documents to be processed in one go, but you’d like
certain files to have different formatting.
## License
**Signatures**
[MIT][license] © [Titus Wormer][author]
* `remark = remark.use(yamlConfig, options?)`.
<!-- Definitions -->
**Parameters**
[travis-badge]: https://img.shields.io/travis/wooorm/remark-yaml-config.svg
* `yamlConfig` — This plugin;
* `options` (`Object?`) — Passed to [remark-yaml](https://github.com/wooorm/remark-yaml#remarkuseyaml-options).
[travis]: https://travis-ci.org/wooorm/remark-yaml-config
## License
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-yaml-config.svg
[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)
[codecov]: https://codecov.io/github/wooorm/remark-yaml-config
[npm-install]: https://docs.npmjs.com/cli/install
[releases]: https://github.com/wooorm/remark-yaml-config/releases
[license]: LICENSE
[author]: http://wooorm.com
[remark-config]: https://github.com/wooorm/remark/blob/master/doc/remarksetting.7.md
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