Détail du package

@zkochan/remark

wooorm7MIT0.1.1

Markdown processor powered by plugins

markdown, markup, abstract, syntax

readme

remark

Build Status Coverage Status Inline docs Chat

remark recently changed its name from mdast. Read more about what changed and how to migrate »

remark is a markdown processor powered by plugins. Lots of tests. Node, io.js, and the browser. 100% coverage.

remark is not just another markdown to HTML compiler. It can generate, and reformat, markdown too. Powered by plugins to do all kinds of things: validate your markdown, add links for GitHub references, or add a table of contents.

The project has both an extensive JavaScript API for parsing, modifying, and compiling markdown, and a friendly Command Line Interface making it easy to validate, prepare, and compile markdown in a build step.

Table of Contents

Installation

npm:

npm install remark

Read more about alternative ways to install and use »

Usage

Load dependencies:

var remark = require('remark');
var html = require('remark-html');
var yamlConfig = require('remark-yaml-config');

Use plugins:

var processor = remark().use(yamlConfig).use(html);

Process the document:

var doc = processor.process([
    '---',
    'remark:',
    '  commonmark: true',
    '---',
    '',
    '2) Some *emphasis*, **strongness**, and `code`.'
].join('\n'));

Yields:

<ol start="2">
<li>Some <em>emphasis</em>, <strong>strongness</strong>, and <code>code</code>.</li>
</ol>

API

Get Started with the API »

remark.process(value[, options][, done])

Parse a markdown document, apply plugins to it, and compile it into something else.

Signatures:

  • doc = remark.process(value, options?, done?).

Parameters:

  • value (string) — Markdown document;

  • options (Object) — Settings:

  • done (function(Error?, string?)) — Callback invoked when the output is generated with either an error, or a result. Only strictly needed when asynchronous plugins are used.

All options (including the options object itself) can be null or undefined to default to their default values.

Returns:

string or null: A document. Formatted in markdown by default, or in whatever a plugin generates. The result is null if a plugin is asynchronous, in which case the callback done should’ve been passed (do not worry: plugin creators make sure you know its asynchronous).

remark.use(plugin[, options])

Change the way remark works by using a plugin.

Signatures:

  • processor = remark.use(plugin, options?);
  • processor = remark.use(plugins).

Parameters:

  • plugin (Function) — A Plugin;
  • plugins (Array.<Function>) — A list of Plugins;
  • options (Object?) — Passed to plugin. Specified by its documentation.

Returns:

Object: an instance of Remark: The returned object functions just like remark (it has the same methods), but caches the used plugins. This provides the ability to chain use calls to use more than one plugin, but ensures the functioning of the remark module does not change for other dependents.

CLI

Get Started with the CLI »

Install:

npm install --global remark

Use:

Usage: remark [options] <pathspec...>

Markdown processor powered by plugins

Options:

  -h, --help                output usage information
  -V, --version             output the version number
  -o, --output [path]       specify output location
  -c, --config-path <path>  specify configuration location
  -i, --ignore-path <path>  specify ignore location
  -s, --setting <settings>  specify settings
  -u, --use <plugins>       use transform plugin(s)
  -e, --ext <extensions>    specify extensions
  -w, --watch               watch for changes and reprocess
  -q, --quiet               output only warnings and errors
  -S, --silent              output only errors
  -f, --frail               exit with 1 on warnings
  -t, --tree                input and output syntax tree
  --file-path <path>        specify file path to process as
  --tree-out                output syntax tree
  --tree-in                 input syntax tree
  --no-stdout               disable writing to stdout
  --no-color                disable color in output
  --no-rc                   disable configuration from .remarkrc
  --no-ignore               disable ignore from .remarkignore

See also: man 1 remark, man 3 remark,
  man 3 remarkplugin, man 5 remarkrc,
  man 5 remarkignore, man 7 remarksetting,
  man 7 remarkconfig, man 7 remarkplugin.

Examples:

  # Process `readme.md`
  $ remark readme.md -o readme-new.md

  # Pass stdin(4) through remark, with settings, to stdout(4)
  $ remark --setting "setext: true, bullet: \"*\"" < readme.md > readme-new.md

  # Use a plugin (with options)
  $ npm install remark-toc
  $ remark readme.md --use "toc=heading:\"contents\"" -o

  # Rewrite markdown in a directory
  $ remark . -o

License

MIT © Titus Wormer

changelog

4.2.1 / 2016-04-12

  • Fix non-magic globs from matching all files (a4ec698)

4.2.0 / 2016-03-30

  • Add support for .remarkrc.js files (cd59707)
  • Fix list item continuation and fenced-code (b208e2d)

4.1.1 / 2016-02-17

  • Fix fatal error on structures for table-like nodes (7b39253)
  • Fix help links in error messages (7819a12)

4.1.0 / 2016-02-16

  • Remove redundant escaped emphasis markers in words (b9699bb)

4.0.0 / 2016-02-14

  • Update to make sure plug-ins are used over files (e445030)
  • Update unified (2e17441)
  • Add support for syntax tree input to remark(1) (86bb88e)
  • Remove support for Duo (480b01a)
  • Refactor how compiler picks visitors (bfb5812)
  • Rename link, src, href properties to url (801a1b6)
  • Remove undefined value for checked on list-items (d0452d3)
  • Rename horizontalRule to thematicBreak (67b36a0)
  • Add offsets to nodes when parsing in remark(3) (070d977)
  • Remove tableHeader definition (593bb82)

3.2.3 / 2016-02-07

  • Fix entities in shortcut and collapsed references (bb1683a)
  • Fix subdomains for literal URLs in remark(3) (8ff7ab4)

3.2.2 / 2016-01-21

  • Refactor internal ignore API in remark(1) (c94c7df)

3.2.1 / 2016-01-19

  • Fix empty list-item bug in remark(3) (8a62652)
  • Add support for default arguments to remark(1) (9ab6dc8)
  • Fix injecting virtual files on remark(1) (397028a)
  • Add natural-language validation (d1c52a3)

3.2.0 / 2016-01-10

  • Fix void list-items in remark(3) (6a42de4)
  • Add Gitter badge to readme.md (4cc1109)
  • Fix tables without final newline in remark(3) (fd2f281)

3.1.3 / 2016-01-04

  • Fix table without body support to remark(3) (9a3bc47)
  • Refactor output of -h, --help in remark(1) (1d36801)
  • Add docs for fileglob support in remark(1) (f9f9a36)

3.1.2 / 2016-01-03

  • Fix globs to files without extension in remark(1) (20e253f)

3.1.1 / 2016-01-02

  • Update copyright date references to 2016 (48151aa)
  • Fix stdin(4) detection on Windows (c2562bc)
  • Add remark-license, remark-vdom to list of plugins (6ca52bb)

3.1.0 / 2015-12-31

  • Add support for injecting plugins into remark(1) (4e65d70)

3.0.1 / 2015-12-27

  • Fix files without extension in remark(1) (6d8bcd5)
  • Refactor remark(1) examples in docs to be valid (fb0cbe8)
  • Add remark-textr to list of plugins (098052a)
  • Update list of plugins with renames (caf5232)

3.0.0 / 2015-12-25

  • Add migration guide and temporary warnings (269f521)
  • Update list of plugins with project renames (fb0fea9)
  • Rename mdast to remark (38fe53d)
  • Fix bug where blockquotes had trailing spaces (a51f112)
  • Refactor support for entities (0c7b649)
  • Refactor code-style (3dc2485)
  • Add documentation for interfacing with the parser (7a5d16d)
  • Fix footnote definitions without spacing (46714b2)
  • Fix empty alt value for imageReference, image (698d569)
  • Fix unclosed angle-bracketed definition (acebf81)
  • Add escaping to compiler (d1fe019)
  • Fix handling of definitions in commonmark-mode (b7d6e53)
  • Fix handling of list-item bullets in gfm-mode (6e74759)
  • Refactor to remove regexes (25a26f2)

2.3.2 / 2015-12-21

  • Fix missing link in history.md (49453f7)

2.3.1 / 2015-12-21

  • Fix package.json files not loading on mdast(1) (1ef6e05)

2.3.0 / 2015-12-01

  • Refactor to prefer prefixed plug-ins in mdast(1) (44d4daa)
  • Fix recursive plugins key handling in mdast(1) (4bb02b2)
  • Add getting-started documentation (a20d9d0)
  • Fix stdout(4) and stderr(4) usage (501a377)

2.2.2 / 2015-11-21

  • Fix premature reporting (a82d018)
  • Remove distribution files from version control (f068edd)
  • Remove support for bower (61162be)

2.2.1 / 2015-11-20

  • Fix silent exit when without .mdastignore file (7233fb2)

2.2.0 / 2015-11-19

  • Update dependencies (c2aca8f)
  • Refactor to externalise file finding (517d483)
  • Refactor to make node to encode optional (03c3361)
  • Add version to library, distribution files (e245a43)
  • Remove output to stdout(4) when watching (594a45f)
  • Remove variable capturing groups from regexes (c17228c)

2.1.0 / 2015-10-05

  • Fix pipes inside code in tables (baad536)
  • Add processing of just the changed watched file to mdast(1) (e3748d2)
  • Add error when pedantic is used with incompatible options (3326a89)

2.0.0 / 2015-09-20

  • Update unified (3dec23f)
  • Update AUTHORS with recent contributors (49ec46f)
  • Add support for watching files for changes to mdast(1) (b3078f9)
  • Fix stdin detection in child-processes (8f1d7f1)
  • Add list of tools built with mdast (d7ad2ac)

1.2.0 / 2015-09-07

  • Fix bug where colour on mdast(1) persisted (ca2c53a)
  • Add support for loading global plugins (5e2d32e)
  • Add more mdastplugin(3) examples (8664a03)
  • Move all info output of mdast(1) to stderr(4) (daed42f)
  • Refactor miscellaneous docs (72412af)

1.1.0 / 2015-08-21

  • Fix typo in man-page (d435999)
  • Update list of plug-ins (4add9e6)
  • Refactor to externalise reporter (8c80af9)
  • Refactor mdast(1) to externalise to-vfile (69629d5)

1.0.0 / 2015-08-12

Nothing much changed, just that mdast is now officially stable! Thanks all for the 100 stars :wink:.

The pre-stable change-log was removed from the working-copy. View the changelog at 1.0.0