@mejazbese21/obsidian-clipper-cli 1.6.3 → 1.6.4
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 +64 -0
- package/dist/cli.cjs +60 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,70 @@ Install the extension by downloading it from the official directory for your bro
|
|
|
17
17
|
|
|
18
18
|
Documentation is available on the [Obsidian Help site](https://help.obsidian.md/web-clipper), which covers how to use [highlighting](https://help.obsidian.md/web-clipper/highlight), [templates](https://help.obsidian.md/web-clipper/templates), [variables](https://help.obsidian.md/web-clipper/variables), [filters](https://help.obsidian.md/web-clipper/filters), and more.
|
|
19
19
|
|
|
20
|
+
## Command-line interface (CLI)
|
|
21
|
+
|
|
22
|
+
The same clipping engine is also available as a command-line tool. Give it a URL and a template, and it fetches the page, extracts the main content, converts it to Markdown, and prints an Obsidian-ready note — identical to what the browser extension produces.
|
|
23
|
+
|
|
24
|
+
### Install
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm install -g @mejazbese21/obsidian-clipper-cli
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or run it without installing:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
npx @mejazbese21/obsidian-clipper-cli <url> -t template.json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Quick start
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
obsidian-clipper https://example.com/article -t template.json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
A ready-to-use default **Clippings** template ships as [`template.json`](/template.json). Copy it, tweak the properties, and point `-t` at your own file. Run `obsidian-clipper --help` at any time for the full guide.
|
|
43
|
+
|
|
44
|
+
### Common uses
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
# Save to a file instead of printing
|
|
48
|
+
obsidian-clipper https://example.com/article -t template.json -o note.md
|
|
49
|
+
|
|
50
|
+
# Clip HTML you already saved (no network request); use "-" for stdin
|
|
51
|
+
obsidian-clipper https://example.com/article -t template.json --html page.html
|
|
52
|
+
|
|
53
|
+
# Send the note straight into an Obsidian vault
|
|
54
|
+
obsidian-clipper https://example.com/article -t template.json --open --vault "My Vault"
|
|
55
|
+
|
|
56
|
+
# Auto-match a template from a folder, by the URL it triggers on
|
|
57
|
+
obsidian-clipper https://example.com/article -t ./templates/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Options
|
|
61
|
+
|
|
62
|
+
| Option | Description |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| `-t, --template <path>` | Template JSON file, or a directory of templates (required). A directory auto-matches by URL triggers. |
|
|
65
|
+
| `-o, --output <path>` | Write the note to this `.md` file (default: stdout). |
|
|
66
|
+
| `--html <path>` | Use HTML from a file instead of fetching the URL (`-` reads stdin). |
|
|
67
|
+
| `--vault <name>` | Obsidian vault name (with `--open`). |
|
|
68
|
+
| `--open` | Send the note to Obsidian instead of printing it. |
|
|
69
|
+
| `--uri` | With `--open`, use the `obsidian://` URI scheme. |
|
|
70
|
+
| `--silent` | With `--uri`, don't steal focus from the terminal. |
|
|
71
|
+
| `--property-types <path>` | JSON mapping property names to types (`text`, `multitext`, `number`, `checkbox`, `date`, `datetime`). |
|
|
72
|
+
| `-h, --help` | Show the full usage guide. |
|
|
73
|
+
|
|
74
|
+
Templates, variables, and filters work exactly as they do in the extension — see the [templates](https://help.obsidian.md/web-clipper/templates), [variables](https://help.obsidian.md/web-clipper/variables), and [filters](https://help.obsidian.md/web-clipper/filters) docs.
|
|
75
|
+
|
|
76
|
+
### Build the CLI from source
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
npm run build:cli
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This bundles the CLI to `dist/cli.cjs`.
|
|
83
|
+
|
|
20
84
|
## Contribute
|
|
21
85
|
|
|
22
86
|
### Translations
|
package/dist/cli.cjs
CHANGED
|
@@ -26398,24 +26398,72 @@ var fs = __toESM(require("fs"));
|
|
|
26398
26398
|
var path = __toESM(require("path"));
|
|
26399
26399
|
function printUsage() {
|
|
26400
26400
|
const usage = `
|
|
26401
|
-
|
|
26401
|
+
obsidian-clipper \u2014 clip a web page into an Obsidian-ready Markdown note.
|
|
26402
26402
|
|
|
26403
|
-
|
|
26404
|
-
|
|
26405
|
-
|
|
26406
|
-
|
|
26407
|
-
|
|
26408
|
-
|
|
26409
|
-
|
|
26410
|
-
|
|
26411
|
-
|
|
26412
|
-
|
|
26413
|
-
|
|
26403
|
+
Fetches a URL (or reads saved HTML), extracts the main content, converts it to
|
|
26404
|
+
Markdown, and applies a template to produce a note with YAML frontmatter \u2014 the
|
|
26405
|
+
same output as the Obsidian Web Clipper browser extension.
|
|
26406
|
+
|
|
26407
|
+
USAGE
|
|
26408
|
+
obsidian-clipper <url> -t <template> [options]
|
|
26409
|
+
|
|
26410
|
+
ARGUMENTS
|
|
26411
|
+
<url> The page to clip (e.g. https://example.com/article)
|
|
26412
|
+
|
|
26413
|
+
OPTIONS
|
|
26414
|
+
-t, --template <path> Template JSON file, or a directory of templates
|
|
26415
|
+
(required). With a directory, the template whose
|
|
26416
|
+
triggers match <url> is selected automatically.
|
|
26417
|
+
-o, --output <path> Write the note to this .md file (default: stdout)
|
|
26418
|
+
--html <path> Use HTML from a file instead of fetching <url>
|
|
26419
|
+
(use "-" to read HTML from stdin)
|
|
26420
|
+
--vault <name> Obsidian vault name (used with --open)
|
|
26421
|
+
--open Send the note to Obsidian instead of printing it
|
|
26422
|
+
--uri With --open, use the obsidian:// URI scheme
|
|
26423
|
+
--silent With --uri, don't steal focus from your terminal
|
|
26424
|
+
--property-types <path> JSON object mapping property names to types
|
|
26425
|
+
(text | multitext | number | checkbox | date | datetime)
|
|
26426
|
+
-h, --help Show this help
|
|
26427
|
+
|
|
26428
|
+
EXAMPLES
|
|
26429
|
+
# Print a clipped note to the terminal
|
|
26430
|
+
obsidian-clipper https://example.com/article -t template.json
|
|
26431
|
+
|
|
26432
|
+
# Save the note to a file
|
|
26433
|
+
obsidian-clipper https://example.com/article -t template.json -o note.md
|
|
26434
|
+
|
|
26435
|
+
# Clip HTML you already saved (no network request)
|
|
26436
|
+
obsidian-clipper https://example.com/article -t template.json --html page.html
|
|
26437
|
+
|
|
26438
|
+
# Pipe HTML in from another command
|
|
26439
|
+
curl -sL https://example.com/article | obsidian-clipper https://example.com/article -t template.json --html -
|
|
26440
|
+
|
|
26441
|
+
# Send straight into an Obsidian vault
|
|
26442
|
+
obsidian-clipper https://example.com/article -t template.json --open --vault "My Vault"
|
|
26443
|
+
|
|
26444
|
+
# Let a folder of templates auto-match by URL
|
|
26445
|
+
obsidian-clipper https://example.com/article -t ./templates/
|
|
26446
|
+
|
|
26447
|
+
TEMPLATES
|
|
26448
|
+
A template is a JSON file describing the note: its name, save path, body
|
|
26449
|
+
format, and frontmatter properties. Values use {{variables}} (e.g. {{title}},
|
|
26450
|
+
{{content}}, {{url}}, {{date}}) and |filters (e.g. {{author|split:", "}}).
|
|
26451
|
+
A ready-to-use default "Clippings" template ships as template.json \u2014 copy and
|
|
26452
|
+
edit it to make your own.
|
|
26453
|
+
|
|
26454
|
+
LEARN MORE
|
|
26455
|
+
Templates: https://help.obsidian.md/web-clipper/templates
|
|
26456
|
+
Variables: https://help.obsidian.md/web-clipper/variables
|
|
26457
|
+
Filters: https://help.obsidian.md/web-clipper/filters
|
|
26414
26458
|
`.trim();
|
|
26415
26459
|
console.log(usage);
|
|
26416
26460
|
}
|
|
26417
26461
|
function parseArgs(argv) {
|
|
26418
26462
|
const args = argv.slice(2);
|
|
26463
|
+
if (args.length === 0) {
|
|
26464
|
+
printUsage();
|
|
26465
|
+
process.exit(0);
|
|
26466
|
+
}
|
|
26419
26467
|
let url = "";
|
|
26420
26468
|
let templatePath = "";
|
|
26421
26469
|
let outputPath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mejazbese21/obsidian-clipper-cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "Command-line web clipper that turns web pages into Obsidian markdown notes, based on the official Obsidian Web Clipper.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"obsidian-clipper": "./dist/cli.cjs"
|