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

mdast

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast - npm Package Compare versions

Comparing version 0.1.10 to 0.1.11

78

cli.js

@@ -78,3 +78,4 @@ #!/usr/bin/env node

' --options output available settings',
' -o, --option <option> specify settings',
' -o, --output <path> specify output location',
' -O, --option <option> specify settings',
' -u, --use <plugin> specify plugins',

@@ -84,10 +85,10 @@ '',

'',
'# Note that bash does not allow reading/writing to the ' +
'same through pipes',
'# Note that bash does not allow reading and writing to the',
'# same file through pipes',
'',
'# Pass `Readme.md` through mdast',
'$ ' + command + ' Readme.md > Readme-new.md',
'$ ' + command + ' Readme.md -o Readme.md',
'',
'# Pass stdin through mdast, with options',
'$ cat Readme.md | ' + command + ' -option ' +
'# Pass stdin through mdast, with options, to stdout',
'$ cat Readme.md | ' + command + ' --option ' +
'"setext, bullet: *" > Readme-new.md',

@@ -102,6 +103,13 @@ '',

/**
* Fail w/ help message.
* Fail w/ `exception`.
*
* @param {null|string|Error} exception
*/
function fail() {
process.stderr.write(help() + '\n');
function fail(exception) {
if (!exception) {
exception = help();
}
process.stderr.write((exception.stack || exception) + '\n');
process.exit(1);

@@ -174,5 +182,7 @@ }

expectPlugin,
expectOutput,
expectAST,
plugins,
options,
output,
files;

@@ -188,7 +198,6 @@

function program(value) {
var ast,
var doc,
parser,
local,
npm,
fn;
fn;

@@ -202,14 +211,11 @@ if (!value.length) {

local = resolve(cwd, plugin);
npm = resolve(cwd, 'node_modules', plugin);
if (exists(local) || exists(local + '.js')) {
fn = require(local);
} else if (exists(npm)) {
fn = require(npm);
} else {
process.stderr.write(
'Invalid unfound plugin `' + plugin + '`.\n'
);
process.exit(1);
try {
fn = require(resolve(cwd, 'node_modules', plugin));
} catch (exception) {
fail(exception);
}
}

@@ -220,9 +226,19 @@

ast = parser.parse(value, options);
doc = parser.parse(value, options);
if (expectAST) {
process.stdout.write(JSON.stringify(ast, null, 2));
doc = JSON.stringify(doc, null, 2);
} else {
process.stdout.write(mdast.stringify(ast, options));
doc = mdast.stringify(doc, options);
}
if (output) {
fs.writeFile(output, doc, function (exception) {
if (exception) {
fail(exception);
}
});
} else {
process.stdout.write(doc);
}
}

@@ -261,6 +277,8 @@ }

argv.forEach(function (argument) {
if (argument === '--option' || argument === '-o') {
if (argument === '--option' || argument === '-O') {
expectOption = true;
} else if (argument === '--use' || argument === '-u') {
expectPlugin = true;
} else if (argument === '--output' || argument === '-o') {
expectOutput = true;
} else if (expectPlugin) {

@@ -272,2 +290,6 @@ argument.split(',').forEach(function (plugin) {

expectPlugin = false;
} else if (expectOutput) {
output = argument;
expectOutput = false;
} else if (expectOption) {

@@ -315,3 +337,3 @@ argument

if (expectOption) {
if (expectOption || expectPlugin || expectOutput) {
fail();

@@ -324,4 +346,3 @@ } else if (!expextPipeIn && !files.length) {

) {
process.stderr.write('mdast currently expects one file.\n');
process.exit(1);
fail('mdast currently expects one file.');
}

@@ -332,4 +353,3 @@

if (exception) {
process.stderr.write(exception.message + '\n');
process.exit(1);
fail(exception);
}

@@ -336,0 +356,0 @@

0.1.11 / 2015-01-25
==================
* Remove `backpedal` from `tokenizeBlock` in `lib/parse.js`
* Merge branch 'feature/simplify-escapes'
* Add support for `escape` node
* Fix fixtures for new escape node
* Add new `escape` node to `doc/Nodes.md`
* Add test support for new `escape` node
* Add docs for `--output`, `-o` CLI flags to `Readme.md`
* Add `--output`, `-o` CLI flags
* Add tests for `--output` CLI flag
* Add docs for `mdast.use()` to `Readme.md`
* Add `build.js` to `.gitignore`, `.npmignore`, `bower.json` ignore
0.1.10 / 2015-01-24

@@ -3,0 +18,0 @@ ==================

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

add = eat($0);
add = eat('');

@@ -745,4 +745,2 @@ token = add({

eat.backpedal($0);
/*

@@ -1099,3 +1097,3 @@ * Add the table header to table's children.

function tokenizeEscape(eat, $0, $1) {
eat($0)(this.renderRaw('text', $1));
eat($0)(this.renderRaw('escape', $1));
}

@@ -1574,3 +1572,4 @@

match,
matched;
matched,
valueLength;

@@ -1638,18 +1637,3 @@ self = this;

/**
* Add `subvalue` back to `value`.
*
* @param {string} subvalue
*/
function backpedal(subvalue) {
value = subvalue + value;
}
/*
* Expose `backpedal` on `eat`.
*/
eat.backpedal = backpedal;
/*
* Iterate over `value`, and iterate over all

@@ -1678,7 +1662,12 @@ * block-expressions. When one matches, invoke

if (match) {
valueLength = value.length;
method.apply(self, [eat].concat(match));
matched = true;
matched = valueLength !== value.length;
break;
/* istanbul ignore else */
if (matched) {
break;
}
}

@@ -1685,0 +1674,0 @@ }

@@ -29,10 +29,4 @@ 'use strict';

var EXPRESSION_ESCAPE,
EXPRESSION_DIGIT,
EXPRESSION_WHITES_PACE,
EXPRESSION_TRAILING_NEW_LINES;
var EXPRESSION_TRAILING_NEW_LINES;
EXPRESSION_ESCAPE = /[\\`*{}\[\]()#+\-._>]/g;
EXPRESSION_DIGIT = /\d/;
EXPRESSION_WHITES_PACE = /\s/;
EXPRESSION_TRAILING_NEW_LINES = /\n+$/g;

@@ -602,21 +596,13 @@

compilerPrototype.text = function (token) {
return token.value.replace(EXPRESSION_ESCAPE, function ($0, index) {
if (
(
$0 === DOT &&
!EXPRESSION_DIGIT.test(token.value.charAt(index - 1))
) ||
(
(
$0 === DASH ||
$0 === PLUS
) &&
!EXPRESSION_WHITES_PACE.test(token.value.charAt(index - 1))
)
) {
return $0;
}
return token.value;
};
return '\\' + $0;
});
/**
* Stringify escaped text.
*
* @param {Object} token
* @return {string}
*/
compilerPrototype.escape = function (token) {
return '\\' + token.value;
};

@@ -623,0 +609,0 @@

{
"name": "mdast",
"version": "0.1.10",
"version": "0.1.11",
"description": "Speedy Markdown parser/stringifier for multipurpose analysis",

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

@@ -136,3 +136,3 @@ # ![mdast](https://cdn.rawgit.com/wooorm/mdast/master/logo.svg)

- `ast` (`Object`) — An AST as returned by [mdast.parse](#mdastparsevalue-options);
- `ast` (`Object`) — An AST as returned by [`mdast.parse()`](#mdastparsevalue-options);
- `options` (`Object`) — Optional options:

@@ -155,2 +155,13 @@ - `setext` (`boolean`, default: `false`). See [Setext Headings](doc/Options.md#setext-headings);

### [mdast](#api).use([plugin](#function-pluginast))
Creates a version of **mdast** which uses the given `plugin` to modify the AST after [`mdast.parse()`](#mdastparsevalue-options) is invoked.
The returned object functions just like **mdast** (it also has `use`, `parse`, and `stringify` methods), but caches the `use`d plugins.
This provides the ability to chain `use` calls to use multiple plugins, but ensures the functioning of **mdast** does not change for other dependants.
#### function plugin\([ast](doc/Nodes.md#node)\)
A plugin is a simple function which is invoked each time a document is [`mdast.parse()`](#mdastparsevalue-options)d. A plugin should change the [ast](doc/Nodes.md#node) to add or remove nodes.
## CLI

@@ -177,3 +188,4 @@

--options output available settings
-o, --option <option> specify settings
-o, --output <path> specify output location
-O, --option <option> specify settings
-u, --use <plugin> specify plugins

@@ -183,9 +195,10 @@

# Note that bash does not allow reading/writing to the same through pipes
# Note that bash does not allow reading and writing to the
# same file through pipes
# Pass `Readme.md` through mdast
$ mdast Readme.md > Readme-new.md
$ mdast Readme.md -o Readme.md
# Pass stdin through mdast, with options
$ cat Readme.md | mdast -option "setext, bullet: *" > Readme-new.md
# Pass stdin through mdast, with options, to stdout
$ cat Readme.md | mdast --option "setext, bullet: *" > Readme-new.md

@@ -192,0 +205,0 @@ # Use an npm module

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