Repository navigation
Versions and Upgrading
| Version | Published | Notes |
|---|---|---|
| 1.0.0 to 1.1.16 | 2016-05-09 to 2018-04-28 | CommonJS, callback only, on request, url-regex, hogan.js and parse-domain. Deprecated. |
| 2.0.0-beta.1 | 2026-09-27 | The 2.0.0 prerelease. Deprecated with the 1.x message. |
| 2.0.0 | 2026-09-27 | TypeScript rewrite, ES module and CommonJS builds, Node 20 or later. latest. |
Every 1.x version, and 2.0.0-beta.1 with them, carries the deprecation message 1.x is unmaintained; 2.0.0 is a TypeScript rewrite with the same answers, see the CHANGELOG (read from the registry on 2026-09-29, 41 versions in all). The next tag still points to 2.0.0-beta.1, so install without a tag, or with @latest. In the week to 2026-09-27 npm counted 168 downloads of 2.0.0, 133 of 2.0.0-beta.1 and 60 of 1.1.16; 544 in the month and 1,511 in the year to that day.
The 1.x call still works in 2.0.0, from require():
const linkReplacer = require('markdown-plain-link-replacer');
linkReplacer.replacePlainLinks(markdown, newMarkdown => { /* ... */ }, template);What you may need to change:
- Node 20 or later.
- Deep imports such as
markdown-plain-link-replacer/lib/...no longer resolve; import the package by its name. - A template that is not a string, or does not compile, now throws a
TypeErrorat the call (API reference). In 1.1.16 a number or an object deleted the link, and an unclosed tag or section never called back. - Without a callback, 2.0.0 returns a Promise. 1.1.16 threw
callback is not a functionor left an unhandled rejection.
The answers themselves changed in the ways below. For a new project, prefer the Promise form: await replacePlainLinks(markdown, {template, timeout, signal}).
1.1.16 still installs from npm and runs on Node 24.18.0. These calls went to both versions against the same local pages, 1.1.16 through its callback (each line is the input, then what came back, both as JSON strings):
"Source: https://en.wikipedia.org/wiki/Bespin" => "Source: \"[Bespin](https://en.wikipedia.org/wiki/Bespin)\", *wikipedia.org*"
" http://starwars.wikia.com/wiki/Bespin " => " [Bespin](http://starwars.wikia.com/wiki/Bespin) from wikia.com "
"See https://docs.example.com/guide." => "See https://docs.example.com/guide."
"Release: https://example.com/colon" => "Release: \"[version 2](https://example.com/colon)\", *example.com*"
"Tom: https://example.com/amp" => "Tom: \"[Tom & Jerry](https://example.com/amp)\", *example.com*"
"Tricky: https://example.com/tricky" => "Tricky: \"[Array[0] *star* _under_ `tick`](https://example.com/tricky)\", *example.com*"
"Tom & Jerry, see https://example.com/" => "Tom & Jerry, see \"[Example Domain](https://example.com/)\", *example.com*"
"`https://example.com/`" => "`\"[Page](https://example.com/`)\", *example.com*"
The README examples (the first two lines) give the same answer in both versions. Then, line by line, 2.0.0 differs:
- A link followed by a period was left by 1.1.16; 2.0.0 replaced
See https://docs.example.com/guide.(How links are replaced). - 1.1.16 read the title
Release notes: version 2asversion 2; 2.0.0 keeps the whole title, because a colon is not a separator in get-title-at-url 3. - 1.1.16's default template HTML-escaped the title (
Tom & Jerry); 2.0.0's writesTom & Jerry. - 1.1.16 wrote markdown characters in a title as they were, so
[0]and*star*broke the link text, and it dropped<b>; 2.0.0 escapes them with backslashes. - 1.1.16 HTML-decoded the whole text (
&became&outside any link); 2.0.0 leaves the text as written. - 1.1.16 replaced a link inside a code span, taking the closing backtick into the address; 2.0.0 leaves code alone.
The repository records 1.1.16's answers in test/golden/1.1.16.json: 154 calls and 18 command line runs, captured on 2026-09-27 against a local server by test/golden/capture-1.1.16.cjs. For this wiki the capture script ran again on 2026-09-29, once against 1.1.16 installed from npm and once against 2.0.0, and each run was compared with the file.
1.1.16 today: 154 of 154 calls and 18 of 18 command line runs identical to the recording, in every recorded detail (answer, callback timing, requests).
2.0.0: the script needed four changes to its copies, none to the cases: 2.0.0's bin path, a dependency list that tolerates the packages 2.0.0 dropped, a proxy agent for fetch, and a test server that serves tunnelled http: requests in plain HTTP. The repository's ai-docs/notes/2026-09-29-github-wiki.md has the details. Compared with the recording:
- 54 calls give the same answer, and 55 more the same apart from the link's title. 2.0.0 reads titles with get-title-at-url 3, which kept the test pages'
Page /pagewhere 1.1.16 readPage. - 45 answers differ in other ways. Four of them differ only in that title too (an upper-case
HTTP://link and three custom templates). Each of the other 41 is a line of the CHANGELOG:- trailing punctuation, brackets and quotes kept out of links: 10 cases;
- links in code, autolinks, and reference definitions spaced other than
[1]: url, left alone: 6; - calls without a callback, or with a string for one: 4;
- a throwing callback, now an uncaught exception instead of an unhandled rejection: 2;
- templates that are not strings or do not compile, which now throw: 4;
- addresses 1.1.16 crashed on or never answered for (IPv4,
localhost, an unknown top-level domain,www.and//without a scheme): 5; - non-ASCII and emoji paths, now looked up: 2;
- a user name and password, now left: 1;
- the text and a link's
&, no longer HTML-decoded: 2; - title reading (markdown characters escaped,
text/plainand an SVG-only title giving no title, gzip decoded): 4; - a page that never answers, now left after the timeout where 1.1.16 never called back: 1.
- 145 calls call back at the same moment relative to the return (after it), and 116 make the same requests in the same order, 10 more the same requests in another order. The rest request less (a repeated link is looked up once, skipped links are never requested) or differently (trailing punctuation no longer in the address).
- Of the 18 command line runs, 3 are identical and 6 more identical apart from the title. The other 9:
--help,-hand--versionprint 2.0.0's text; a missing file,-iwithout a value and an unknown option exit 1 with a message where 1.1.16 printedundefined;www.example.com/pageand an IPv4 link no longer crash; and with no argument 2.0.0 waits for standard input, which the capture never closes.
exit 0
Script to replace a text link (ie http://whatever) with the title at the links webpage in markdown.
Usage
$ markdown-plain-link-replacer "<markdown>"
Example
$ markdown-plain-link-replacer " http://starwars.wikia.com/wiki/Bespin "
That was 1.1.16's --help; its -h printed nothing, www.example.com/page exited 1 with Error: Invalid url, and http://192.0.2.10/page with TypeError: Cannot read properties of null (reading 'domain'). 2.0.0's command is on Commands.
This wiki describes markdown-plain-link-replacer 2.0.0 and was last updated on 2026-09-30. The library is MIT licensed. Report problems in the issues. On npm: markdown-plain-link-replacer.
Using it
The releases
Contributing
Elsewhere