remark-inline-links
Advanced tools
Comparing version 3.0.4 to 3.1.0
21
index.js
@@ -9,19 +9,18 @@ 'use strict'; | ||
function inlineLinks() { | ||
function inlineLinks(options) { | ||
return transformer; | ||
} | ||
/* Transformer. */ | ||
function transformer(tree) { | ||
var reference = referenceFactory(tree); | ||
function transformer(tree) { | ||
var reference = referenceFactory(tree, options); | ||
remove(tree, 'definition'); | ||
remove(tree, 'definition'); | ||
visit(tree, 'imageReference', reference); | ||
visit(tree, 'linkReference', reference); | ||
visit(tree, 'imageReference', reference); | ||
visit(tree, 'linkReference', reference); | ||
} | ||
} | ||
/* Factory to transform a reference based on `definitions`. */ | ||
function referenceFactory(tree) { | ||
var definitions = getDefinitions(tree); | ||
function referenceFactory(tree, options) { | ||
var definitions = getDefinitions(tree, options); | ||
@@ -52,5 +51,5 @@ return reference; | ||
parent.children.splice(index, 1, replacement); | ||
parent.children[index] = replacement; | ||
} | ||
} | ||
} |
{ | ||
"name": "remark-inline-links", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"description": "Transform references and definitions into normal links and images", | ||
@@ -15,4 +15,4 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/remark-inline-links", | ||
"bugs": "https://github.com/wooorm/remark-inline-links/issues", | ||
"repository": "remarkjs/remark-inline-links", | ||
"bugs": "https://github.com/remarkjs/remark-inline-links/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
@@ -34,4 +34,4 @@ "contributors": [ | ||
"nyc": "^11.0.0", | ||
"remark": "^7.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark": "^8.0.0", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
@@ -65,4 +65,6 @@ "tape": "^4.4.0", | ||
"remarkConfig": { | ||
"plugins": ["preset-wooorm"] | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
} | ||
} |
# remark-inline-links [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat] | ||
[**remark**][remark] plug-in to transform references and definitions | ||
into normal links and images. | ||
[**remark**][remark] plugin to transform references and definitions into normal | ||
links and images. | ||
@@ -51,15 +51,35 @@ ## Installation | ||
### `remark().use(inlineLinks)` | ||
### `remark().use(inlineLinks[, options])` | ||
Transform references and definitions into normal links and images. | ||
##### Options | ||
###### `options.commonmark` | ||
`boolean`, default: `false` — Turn on to use CommonMark handling of duplicate | ||
definitions: use the first definition, ignore duplicate definitions. | ||
The default behaviour is to prefer the last found duplicate definition. | ||
## Related | ||
* [`remark-reference-links`](https://github.com/wooorm/remark-reference-links) | ||
— Reverse, thus rewriting normal links and images into references | ||
and definitions | ||
* [`remark-bookmarks`](https://github.com/ben-eb/remark-bookmarks) | ||
— Link manager | ||
* [`remark-reference-links`](https://github.com/remarkjs/remark-reference-links) | ||
— Reverse of `remark-inline-links`, thus rewriting normal links and images | ||
into references and definitions | ||
* [`remark-defsplit`](https://github.com/eush77/remark-defsplit) | ||
— Practically the same as `remark-reference-links`, but with | ||
URI-based identifiers instead of numerical ones | ||
* [`remark-unlink`](https://github.com/eush77/remark-unlink) | ||
— Remove all links, references and definitions | ||
## Contribute | ||
See [`contribute.md` in `remarkjs/remarkjs`][contribute] for ways to get | ||
started. | ||
This organisation has a [Code of Conduct][coc]. By interacting with this | ||
repository, organisation, or community you agree to abide by its terms. | ||
## License | ||
@@ -71,13 +91,13 @@ | ||
[build-badge]: https://img.shields.io/travis/wooorm/remark-inline-links.svg | ||
[build-badge]: https://img.shields.io/travis/remarkjs/remark-inline-links.svg | ||
[build-status]: https://travis-ci.org/wooorm/remark-inline-links | ||
[build-status]: https://travis-ci.org/remarkjs/remark-inline-links | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/remark-inline-links.svg | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-inline-links.svg | ||
[coverage-status]: https://codecov.io/github/wooorm/remark-inline-links | ||
[coverage-status]: https://codecov.io/github/remarkjs/remark-inline-links | ||
[chat-badge]: https://img.shields.io/gitter/room/wooorm/remark.svg | ||
[chat-badge]: https://img.shields.io/gitter/room/remarkjs/Lobby.svg | ||
[chat]: https://gitter.im/wooorm/remark | ||
[chat]: https://gitter.im/remarkjs/remark | ||
@@ -90,2 +110,6 @@ [license]: LICENSE | ||
[remark]: https://github.com/wooorm/remark | ||
[remark]: https://github.com/remarkjs/remark | ||
[contribute]: https://github.com/remarkjs/remark/blob/master/contributing.md | ||
[coc]: https://github.com/remarkjs/remark/blob/master/code-of-conduct.md |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
7258
113
42