@bartificer/linkify 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,2 +1,70 @@
1
- # linkify
2
- JS API and CLI for converting URLs into links.
1
+ # `linkify` from Bartificer Creations
2
+
3
+ An MIT-licensed ES6 Javascript module for generating links in any format from a URL.
4
+
5
+ This code was written by [Bart Busschots](https://www.lets-talk.ie/contributor/bart) to speed up the creation of shownotes for the [Let's Talk Apple](https://www.lets-talk.ie/lta) and the [Security Bits](https://www.podfeet.com/blog/category/security-bits/) segments on the [NosillaCast](https://www.podfeet.com/blog/category/nosillacast/). It is released open-source as a courtesy to other podcasters and bloggers who regularly need to covert URLs into nicely formatted links.
6
+
7
+ Pull requests and issues are welcomed, but on the understanding that this is a volunteer-maintained package, and all responses will be at the maintainer's discression as and when they have time. Realistically, you won't hear back from days or weeks, and if life is very hectic, perhaps even months.
8
+
9
+ Given this reality, **do not use this repository for anything mission-critical!**.
10
+
11
+ ## Instalation
12
+
13
+ ```sh
14
+ npm install '@bartificer/linkifier';
15
+ ```
16
+
17
+ ## Examples
18
+
19
+ This is an ES6 module, so when used with NPM, your scripts must have the `.mjs` file extension (to force ES module mode).
20
+
21
+ ### Generate a Link from a URL Using all the Defaults
22
+
23
+
24
+ Create a file named `demo.mjs` with the following content:
25
+
26
+ ```javascript
27
+ // import the linkify module
28
+ import linkify from '@bartificer/linkify';
29
+
30
+ // generate a link from a URL using the default template
31
+ (async () => {
32
+ let link = await linkify.generateLink('https://pbs.bartificer.net/pbs128');
33
+ console.log(link);
34
+ })();
35
+ ```
36
+
37
+ Execute the script with `node`:
38
+
39
+ ```sh
40
+ node demo.mjs
41
+ ```
42
+
43
+ ### Using the Bundled Templates
44
+
45
+ The following demo code will generate a link using each of the bundled link templates:
46
+
47
+ ```javascript
48
+ // import the linkify module
49
+ import linkify from '@bartificer/linkify';
50
+
51
+ // get a list of all registered template names
52
+ const templateNames = linkify.templateNames;
53
+ console.log('registered templates:', templateNames);
54
+
55
+ // iterate over each tempalte with an example URL
56
+ (async () => {
57
+ let testURL = 'https://pbs.bartificer.net/pbs128';
58
+ for(let templateName of templateNames){
59
+ let link = await linkify.generateLink(testURL, templateName);
60
+ console.log(`- ${templateName}: ${link}`);
61
+ }
62
+ })();
63
+ ```
64
+
65
+ ### Real-World Examples
66
+
67
+ Two real-world scripts Bart users to build shownotes are included in [the `/example` folder in the GitHub repostitory](https://github.com/bartificer/linkify/tree/master/example):
68
+
69
+ 1. `clipboardURLToMarkdown.mjs` — the script Bart uses to convert links to Markdown for use in show notes. This script contains a real-world example of a custom template, and, of a large collection of custom transformers registered against specific domain names for dealing with their various quirks.
70
+ 2. `debugClipboardURL.mjs` — the script Bart uses to help develop custom transformers for any sites that need them.