Socket
Socket
Sign inDemoInstall

remark-stringify

Package Overview
Dependencies
25
Maintainers
5
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.4 to 7.0.0

types/index.d.ts

16

lib/visitors/code.js

@@ -11,2 +11,4 @@ 'use strict'

var space = ' '
var tilde = '~'
var graveAccent = '`'

@@ -60,3 +62,9 @@ // Stringify code.

// Without (needed) fences.
if (!info && !options.fences && value) {
if (
!info &&
!options.fences &&
value &&
value.charAt(0) !== lineFeed &&
value.charAt(value.length - 1) !== lineFeed
) {
// Throw when pedantic, in a list item which isn’t compiled using a tab.

@@ -78,2 +86,8 @@ if (

// Backticks in the info string don’t work with backtick fenced code.
// Backticks (and tildes) are fine in tilde fenced code.
if (marker === graveAccent && info.indexOf(graveAccent) !== -1) {
marker = tilde
}
fence = repeat(marker, Math.max(streak(value, marker) + 1, 3))

@@ -80,0 +94,0 @@

@@ -8,4 +8,6 @@ 'use strict'

var space = ' '
var graveAccent = '`'
var graveAccentChar = '`'
var lineFeed = 10 // '\n'
var space = 32 // ' '
var graveAccent = 96 // '`'

@@ -29,12 +31,28 @@ // Stringify inline code.

var value = node.value
var ticks = repeat(graveAccent, streak(value, graveAccent) + 1)
var ticks = repeat(graveAccentChar, streak(value, graveAccentChar) + 1)
var start = ticks
var end = ticks
var head = value.charCodeAt(0)
var tail = value.charCodeAt(value.length - 1)
var wrap = false
var index
var length
if (value.charAt(0) === graveAccent) {
start += space
if (head === graveAccent || tail === graveAccent) {
wrap = true
} else if (value.length > 2 && ws(head) && ws(tail)) {
index = 1
length = value.length - 1
while (++index < length) {
if (!ws(value.charCodeAt(index))) {
wrap = true
break
}
}
}
if (value.charAt(value.length - 1) === graveAccent) {
end = space + end
if (wrap) {
start += ' '
end = ' ' + end
}

@@ -44,1 +62,5 @@

}
function ws(code) {
return code === lineFeed || code === space
}

2

lib/visitors/link.js

@@ -15,3 +15,3 @@ 'use strict'

// Expression for a protocol:
// See <http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax>.
// See <https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Generic_syntax>.
var protocol = /^[a-z][a-z+.-]+:\/?/i

@@ -18,0 +18,0 @@

{
"name": "remark-stringify",
"version": "6.0.4",
"description": "Markdown compiler for remark",
"version": "7.0.0",
"description": "remark plugin to compile Markdown",
"license": "MIT",
"keywords": [
"unified",
"remark",
"plugin",
"markdown",
"mdast",
"markdown",
"abstract",

@@ -24,4 +29,6 @@ "syntax",

"index.js",
"lib"
"lib",
"types/index.d.ts"
],
"types": "types/index.d.ts",
"dependencies": {

@@ -39,13 +46,6 @@ "ccount": "^1.0.0",

"state-toggle": "^1.0.0",
"stringify-entities": "^1.0.1",
"stringify-entities": "^2.0.0",
"unherit": "^1.0.4",
"xtend": "^4.0.1"
},
"devDependencies": {
"tape": "^4.9.1",
"unified": "^7.0.0",
"unist-builder": "^1.0.3",
"unist-util-visit": "^1.4.0",
"wcwidth": "^1.0.1"
},
"scripts": {

@@ -52,0 +52,0 @@ "test": "tape test.js"

@@ -1,14 +0,16 @@

# remark-stringify [![Travis][build-badge]][build-status] [![Coverage][coverage-badge]][coverage-status] [![Downloads][dl-badge]][dl] [![Size][size-badge]][size] [![Chat][chat-badge]][chat]
# remark-stringify
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Chat][chat-badge]][chat]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[Compiler][] for [**unified**][unified].
Stringifies [**mdast**][mdast] syntax trees to markdown.
Used in the [**remark** processor][processor] but can be used on its own as
well.
Can be [extended][extend] to change how markdown is parsed.
Stringifies [**mdast**][mdast] syntax trees to Markdown.
Used in the [**remark** processor][remark] but can be used on its own as well.
Can be [extended][extend] to change how Markdown is compiled.
* * *
**Announcing the unified collective! 🎉
[Read more about it on Medium »][announcement]**
## Sponsors

@@ -46,4 +48,6 @@

## Installation
[**Read more about the unified collective on Medium »**][announcement]
## Install
[npm][]:

@@ -55,3 +59,3 @@

## Usage
## Use

@@ -61,9 +65,9 @@ ```js

var createStream = require('unified-stream')
var parse = require('remark-parse')
var toc = require('remark-toc')
var html = require('rehype-parse')
var rehype2remark = require('rehype-remark')
var stringify = require('remark-stringify')
var processor = unified()
.use(parse)
.use(toc)
.use(html)
.use(rehype2remark)
.use(stringify, {

@@ -79,6 +83,8 @@ bullet: '*',

[See **unified** for more examples »][unified]
## Table of Contents
* [API](#api)
* [processor.use(stringify\[, options\])](#processorusestringify-options)
* [processor().use(stringify\[, options\])](#processorusestringify-options)
* [stringify.Compiler](#stringifycompiler)

@@ -88,2 +94,3 @@ * [Extending the Compiler](#extending-the-compiler)

* [function visitor(node\[, parent\])](#function-visitornode-parent)
* [Contribute](#contribute)
* [License](#license)

@@ -93,14 +100,17 @@

### `processor.use(stringify[, options])`
[See **unified** for API docs »][unified]
Configure the `processor` to stringify [**mdast**][mdast] syntax trees
to markdown.
### `processor().use(stringify[, options])`
Configure the `processor` to stringify [**mdast**][mdast] syntax trees to
Markdown.
##### `options`
Options are passed directly, or passed later through [`processor.data()`][data].
Options can be passed directly, or passed later through
[`processor.data()`][data].
###### `options.gfm`
Stringify with the required escapes for GFM compatible markdown (`boolean`,
Stringify with the required escapes for GFM compatible Markdown (`boolean`,
default: `true`).

@@ -114,3 +124,3 @@

Stringify for CommonMark compatible markdown (`boolean`, default: `false`).
Stringify for CommonMark compatible Markdown (`boolean`, default: `false`).

@@ -130,10 +140,10 @@ * Compile adjacent blockquotes separately

* `true` — Entities are generated for special HTML characters
(`&` > `&amp;`) and non-ASCII characters (`©` > `&copy;`).
If named entities are not (widely) supported, numbered character
references are used (`’` > `&#x2019;`)
* `'numbers'` — Numbered entities are generated (`&` > `&#x26;`)
for special HTML characters and non-ASCII characters
* `'escape'` — Special HTML characters are encoded (`&` >
`&amp;`, `’` > `&#x2019;`), non-ASCII characters not (ö persists)
* `true` — Entities are generated for special HTML characters (`&` > `&amp;`)
and non-ASCII characters (`©` > `&copy;`).
If named entities are not (widely) supported, numbered character references
are used (`’` > `&#x2019;`)
* `'numbers'` — Numbered entities are generated (`&` > `&#x26;`) for special
HTML characters and non-ASCII characters
* `'escape'` — Special HTML characters are encoded (`&` > `&amp;`, `’` >
`&#x2019;`), non-ASCII characters not (ö persists)

@@ -143,4 +153,4 @@ ###### `options.setext`

Compile headings, when possible, in Setext-style (`boolean`, default: `false`).
Uses `=` for level one headings and `-` for level two headings. Other heading
levels are compiled as ATX (respecting `closeAtx`).
Uses `=` for level one headings and `-` for level two headings.
Other heading levels are compiled as ATX (respecting `closeAtx`).

@@ -159,3 +169,3 @@ ###### `options.closeAtx`

Create tables without spacing between pipes and content (`boolean`, default:
Create tables with a space between a pipe and content (`boolean`, default:
`true`).

@@ -165,4 +175,4 @@

Create tables with padding in each cell so that they are the same size
(`boolean`, default: `true`).
Create tables with more spaces so that all cells in a column align (`boolean`,
default: `true`).

@@ -173,15 +183,19 @@ ###### `options.stringLength`

table cell (`Function`, default: [`s => s.length`][string-length]).
Used to pad tables.
###### `options.fence`
Fence marker to use for code blocks (`'~'` or ``'`'``, default: ``'`'``).
Marker to use for fenced code blocks (`'~'` or ``'`'``, default: ``'`'``).
###### `options.fences`
Stringify code blocks without language with fences (`boolean`, default:
`false`).
Create code blocks with a fence instead of indentation if they have no info
string (`boolean`, default: `false`).
When `false`, code blocks are indented.
Code blocks with an info string are always fenced.
###### `options.bullet`
Bullet marker to use for unordered list items (`'-'`, `'*'`, or `'+'`,
Marker to use for the bullet of unordered list items (`'-'`, `'*'`, or `'+'`,
default: `'-'`).

@@ -191,6 +205,6 @@

How to indent the content from list items (`'tab'`, `'mixed'` or `'1'`,
default: `'tab'`).
Style of indentation for list items (`'tab'`, `'mixed'` or `'1'`, default:
`'tab'`).
* `'tab'`: use tab stops (4 spaces)
* `'tab'`: use a tab stops (4 spaces)
* `'1'`: use one space

@@ -201,4 +215,6 @@ * `'mixed'`: use `1` for tight and `tab` for loose list items

Whether to increment ordered list item bullets (`boolean`, default: `true`).
Increment ordered list item numbers (`boolean`, default: `true`).
When `false`, all list item numbers will be the same.
###### `options.rule`

@@ -212,7 +228,8 @@

Number of markers to use for thematic breaks / horizontal rules (`number`,
default: `3`). Should be `3` or more.
default: `3`).
Musts be `3` or more.
###### `options.ruleSpaces`
Whether to pad thematic break (horizontal rule) markers with spaces (`boolean`,
Place a space between thematic break (horizontal rule) markers (`boolean`,
default `true`).

@@ -230,12 +247,13 @@

Access to the raw [compiler][], if you need it.
Access to the [compiler][], if you need it.
## Extending the Compiler
If this plugin is used, it adds a [`Compiler`][compiler] constructor
to the `processor`. Other plugins can change and add visitors on
the compiler’s prototype to change how markdown is stringified.
If the `remark-stringify` plugin is used, it adds a [`Compiler`][compiler]
constructor function to the `processor`.
Other plugins can add visitors to its prototype to change how Markdown is
compiled.
The below plugin modifies a [visitor][] to add an extra blank line
before level two headings.
The below plugin modifies a [visitor][] to add an extra blank line before
headings with a rank of `2`.

@@ -260,3 +278,3 @@ ```js

An object mapping [node][] types to [`visitor`][visitor]s.
Map of types to [visitor][]s (`Object.<Function>`).

@@ -270,8 +288,23 @@ ### `function visitor(node[, parent])`

* `node` ([`Node`][node]) — Node to compile
* `parent` ([`Node`][node], optional) — Parent of `node`
* `parent` ([`Parent`][parent], optional) — Parent of `node`.
Not available on the root node
###### Returns
`string`, the compiled given `node`.
`string` — Compiled given `node`.
## Contribute
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
to get started.
See [`support.md`][support] for ways to get help.
Ideas for new plugins and tools can be posted in [`remarkjs/ideas`][ideas].
A curated list of awesome remark resources can be found in [**awesome
remark**][awesome].
This project has a [Code of Conduct][coc].
By interacting with this repository, organisation, or community you agree to
abide by its terms.
## License

@@ -283,13 +316,13 @@

[build-badge]: https://img.shields.io/travis/remarkjs/remark/master.svg
[build-badge]: https://img.shields.io/travis/remarkjs/remark.svg
[build-status]: https://travis-ci.org/remarkjs/remark
[build]: https://travis-ci.org/remarkjs/remark
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark.svg
[coverage-status]: https://codecov.io/github/remarkjs/remark
[coverage]: https://codecov.io/github/remarkjs/remark
[dl-badge]: https://img.shields.io/npm/dm/remark-stringify.svg
[downloads-badge]: https://img.shields.io/npm/dm/remark-stringify.svg
[dl]: https://www.npmjs.com/package/remark-stringify
[downloads]: https://www.npmjs.com/package/remark-stringify

@@ -300,2 +333,8 @@ [size-badge]: https://img.shields.io/bundlephobia/minzip/remark-stringify.svg

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg

@@ -305,2 +344,14 @@

[health]: https://github.com/remarkjs/.github
[contributing]: https://github.com/remarkjs/.github/blob/master/contributing.md
[support]: https://github.com/remarkjs/.github/blob/master/support.md
[coc]: https://github.com/remarkjs/.github/blob/master/code-of-conduct.md
[ideas]: https://github.com/remarkjs/ideas
[awesome]: https://github.com/remarkjs/awesome-remark
[license]: https://github.com/remarkjs/remark/blob/master/license

@@ -314,6 +365,6 @@

[processor]: https://github.com/remarkjs/remark
[data]: https://github.com/unifiedjs/unified#processordatakey-value
[remark]: https://github.com/remarkjs/remark/tree/master/packages/remark
[compiler]: https://github.com/unifiedjs/unified#processorcompiler

@@ -325,2 +376,4 @@

[parent]: https://github.com/syntax-tree/unist#parent
[extend]: #extending-the-compiler

@@ -330,6 +383,6 @@

[announcement]: https://medium.com/unifiedjs/collectively-evolving-through-crowdsourcing-22c359ea95cc
[markdown-table]: https://github.com/wooorm/markdown-table
[string-length]: https://github.com/wooorm/markdown-table#stringlengthcell
[announcement]: https://medium.com/unifiedjs/collectively-evolving-through-crowdsourcing-22c359ea95cc
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc