@mejazbese21/obsidian-clipper-cli 1.6.4 → 1.6.6
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 +65 -122
- package/dist/cli.cjs +42 -21
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -1,173 +1,116 @@
|
|
|
1
|
-
Obsidian Web Clipper
|
|
1
|
+
# Obsidian Web Clipper CLI
|
|
2
2
|
|
|
3
|
-
-
|
|
4
|
-
- **[Documentation](https://help.obsidian.md/web-clipper)**
|
|
5
|
-
- **[Troubleshooting](https://help.obsidian.md/web-clipper/troubleshoot)**
|
|
3
|
+
Clip web pages to Obsidian-ready Markdown from terminal.
|
|
6
4
|
|
|
7
|
-
##
|
|
5
|
+
## Install
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @mejazbese21/obsidian-clipper-cli
|
|
9
|
+
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- **[Firefox Add-Ons](https://addons.mozilla.org/en-US/firefox/addon/web-clipper-obsidian/)** for Firefox and Firefox Mobile.
|
|
13
|
-
- **[Safari Extensions](https://apps.apple.com/us/app/obsidian-web-clipper/id6720708363)** for macOS, iOS, and iPadOS.
|
|
14
|
-
- **[Edge Add-Ons](https://microsoftedge.microsoft.com/addons/detail/obsidian-web-clipper/eigdjhmgnaaeaonimdklocfekkaanfme)** for Microsoft Edge.
|
|
11
|
+
## Usage
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
```bash
|
|
14
|
+
obsidian-clipper <url>
|
|
15
|
+
```
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
Example:
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
```bash
|
|
20
|
+
obsidian-clipper https://docs.equalsmoney.com/
|
|
21
|
+
```
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Default template used if no template given.
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
## Custom template
|
|
25
26
|
|
|
26
|
-
```
|
|
27
|
-
|
|
27
|
+
```bash
|
|
28
|
+
obsidian-clipper https://example.com/article -t template.json
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
## Save to file
|
|
31
32
|
|
|
32
|
-
```
|
|
33
|
-
|
|
33
|
+
```bash
|
|
34
|
+
obsidian-clipper https://example.com/article -o note.md
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
## Use saved HTML
|
|
37
38
|
|
|
39
|
+
```bash
|
|
40
|
+
obsidian-clipper https://example.com/article --html page.html
|
|
38
41
|
```
|
|
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
42
|
|
|
44
|
-
|
|
43
|
+
Use stdin:
|
|
45
44
|
|
|
45
|
+
```bash
|
|
46
|
+
cat page.html | obsidian-clipper https://example.com/article --html -
|
|
46
47
|
```
|
|
47
|
-
# Save to a file instead of printing
|
|
48
|
-
obsidian-clipper https://example.com/article -t template.json -o note.md
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
obsidian-clipper https://example.com/article -t template.json --html page.html
|
|
49
|
+
## Open in Obsidian
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
obsidian-clipper https://example.com/article
|
|
51
|
+
```bash
|
|
52
|
+
obsidian-clipper https://example.com/article --open --vault "My Vault"
|
|
53
|
+
```
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
## Template folder auto-match
|
|
56
|
+
|
|
57
|
+
```bash
|
|
57
58
|
obsidian-clipper https://example.com/article -t ./templates/
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
|
|
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. |
|
|
61
|
+
## Options
|
|
73
62
|
|
|
74
|
-
|
|
63
|
+
| Option | Use |
|
|
64
|
+
| ------------------ | --------------------- |
|
|
65
|
+
| `-t, --template` | template file/folder |
|
|
66
|
+
| `-o, --output` | save markdown file |
|
|
67
|
+
| `--html` | use local HTML |
|
|
68
|
+
| `--vault` | Obsidian vault name |
|
|
69
|
+
| `--open` | send to Obsidian |
|
|
70
|
+
| `--uri` | use obsidian:// URI |
|
|
71
|
+
| `--silent` | don’t focus Obsidian |
|
|
72
|
+
| `--property-types` | property type mapping |
|
|
73
|
+
| `-h, --help` | help |
|
|
75
74
|
|
|
76
|
-
|
|
75
|
+
## Build
|
|
77
76
|
|
|
78
|
-
```
|
|
77
|
+
```bash
|
|
79
78
|
npm run build:cli
|
|
80
79
|
```
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## Contribute
|
|
85
|
-
|
|
86
|
-
### Translations
|
|
87
|
-
|
|
88
|
-
You can help translate Web Clipper into your language. Submit your translation via pull request using the format found in the [/_locales](/src/_locales) folder.
|
|
81
|
+
Output:
|
|
89
82
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## Roadmap
|
|
95
|
-
|
|
96
|
-
In no particular order:
|
|
97
|
-
|
|
98
|
-
- [ ] Annotate highlights
|
|
99
|
-
- [ ] Template directory
|
|
100
|
-
- [ ] Sync settings across browsers
|
|
101
|
-
- [x] A separate icon for Web Clipper (1.6.3)
|
|
102
|
-
- [x] Template validation (1.1.0)
|
|
103
|
-
- [x] Template logic (if/for) (1.1.0)
|
|
104
|
-
- [x] Save images locally ([Obsidian 1.8.0](https://obsidian.md/changelog/2024-12-18-desktop-v1.8.0/))
|
|
105
|
-
- [x] Translate UI into more languages — help is welcomed
|
|
83
|
+
```bash
|
|
84
|
+
dist/cli.cjs
|
|
85
|
+
```
|
|
106
86
|
|
|
107
|
-
##
|
|
87
|
+
## Dev
|
|
108
88
|
|
|
109
|
-
|
|
89
|
+
Build extension:
|
|
110
90
|
|
|
111
|
-
```
|
|
91
|
+
```bash
|
|
112
92
|
npm run build
|
|
113
93
|
```
|
|
114
94
|
|
|
115
|
-
|
|
116
|
-
- `dist/` for the Chromium version
|
|
117
|
-
- `dist_firefox/` for the Firefox version
|
|
118
|
-
- `dist_safari/` for the Safari version
|
|
119
|
-
|
|
120
|
-
### Install the extension locally
|
|
121
|
-
|
|
122
|
-
For Chromium browsers, such as Chrome, Brave, Edge, and Arc:
|
|
123
|
-
|
|
124
|
-
1. Open your browser and navigate to `chrome://extensions`
|
|
125
|
-
2. Enable **Developer mode**
|
|
126
|
-
3. Click **Load unpacked** and select the `dist` directory
|
|
95
|
+
Run tests:
|
|
127
96
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
1. Open Firefox and navigate to `about:debugging#/runtime/this-firefox`
|
|
131
|
-
2. Click **Load Temporary Add-on**
|
|
132
|
-
3. Navigate to the `dist_firefox` directory and select the `manifest.json` file
|
|
133
|
-
|
|
134
|
-
If you want to run the extension permanently you can do so with the Nightly or Developer versions of Firefox.
|
|
135
|
-
|
|
136
|
-
1. Type `about:config` in the URL bar
|
|
137
|
-
2. In the Search box type `xpinstall.signatures.required`
|
|
138
|
-
3. Double-click the preference, or right-click and select "Toggle", to set it to `false`.
|
|
139
|
-
4. Go to `about:addons` > gear icon > **Install Add-on From File…**
|
|
140
|
-
|
|
141
|
-
For iOS Simulator testing on macOS:
|
|
142
|
-
|
|
143
|
-
1. Run `npm run build` to build the extension
|
|
144
|
-
2. Open `xcode/Obsidian Web Clipper/Obsidian Web Clipper.xcodeproj` in Xcode
|
|
145
|
-
3. Select the **Obsidian Web Clipper (iOS)** scheme from the scheme selector
|
|
146
|
-
4. Choose an iOS Simulator device and click **Run** to build and launch the app
|
|
147
|
-
5. Once the app is running on the simulator, open **Safari**
|
|
148
|
-
6. Navigate to a webpage and tap the **Extensions** button in Safari to access the Web Clipper extension
|
|
149
|
-
|
|
150
|
-
### Run tests
|
|
151
|
-
|
|
152
|
-
```
|
|
97
|
+
```bash
|
|
153
98
|
npm test
|
|
154
99
|
```
|
|
155
100
|
|
|
156
|
-
|
|
101
|
+
Watch tests:
|
|
157
102
|
|
|
158
|
-
```
|
|
103
|
+
```bash
|
|
159
104
|
npm run test:watch
|
|
160
105
|
```
|
|
161
106
|
|
|
162
|
-
##
|
|
107
|
+
## Links
|
|
163
108
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
- [lucide](https://github.com/lucide-icons/lucide) for icons
|
|
169
|
-
- [dompurify](https://github.com/cure53/DOMPurify) for sanitizing HTML
|
|
109
|
+
* GitHub: https://github.com/mohsingdp-ai/obsidian-clipper-cli
|
|
110
|
+
* Download: https://obsidian.md/clipper
|
|
111
|
+
* Docs: https://help.obsidian.md/web-clipper
|
|
112
|
+
* Troubleshoot: https://help.obsidian.md/web-clipper/troubleshoot
|
|
170
113
|
|
|
171
114
|
## License
|
|
172
115
|
|
|
173
|
-
|
|
116
|
+
MIT, except Obsidian trademarks/icons/marketing assets.
|
package/dist/cli.cjs
CHANGED
|
@@ -26405,15 +26405,16 @@ Markdown, and applies a template to produce a note with YAML frontmatter \u2014
|
|
|
26405
26405
|
same output as the Obsidian Web Clipper browser extension.
|
|
26406
26406
|
|
|
26407
26407
|
USAGE
|
|
26408
|
-
obsidian-clipper <url>
|
|
26408
|
+
obsidian-clipper <url> [options]
|
|
26409
26409
|
|
|
26410
26410
|
ARGUMENTS
|
|
26411
26411
|
<url> The page to clip (e.g. https://example.com/article)
|
|
26412
26412
|
|
|
26413
26413
|
OPTIONS
|
|
26414
|
-
-t, --template <path> Template JSON file, or a directory of templates
|
|
26415
|
-
|
|
26416
|
-
|
|
26414
|
+
-t, --template <path> Template JSON file, or a directory of templates.
|
|
26415
|
+
Optional \u2014 when omitted, a built-in "Clippings"
|
|
26416
|
+
template is used. With a directory, the template
|
|
26417
|
+
whose triggers match <url> is selected automatically.
|
|
26417
26418
|
-o, --output <path> Write the note to this .md file (default: stdout)
|
|
26418
26419
|
--html <path> Use HTML from a file instead of fetching <url>
|
|
26419
26420
|
(use "-" to read HTML from stdin)
|
|
@@ -26426,7 +26427,10 @@ OPTIONS
|
|
|
26426
26427
|
-h, --help Show this help
|
|
26427
26428
|
|
|
26428
26429
|
EXAMPLES
|
|
26429
|
-
# Print a clipped note
|
|
26430
|
+
# Print a clipped note using the built-in default template
|
|
26431
|
+
obsidian-clipper https://example.com/article
|
|
26432
|
+
|
|
26433
|
+
# Print a clipped note with your own template
|
|
26430
26434
|
obsidian-clipper https://example.com/article -t template.json
|
|
26431
26435
|
|
|
26432
26436
|
# Save the note to a file
|
|
@@ -26542,13 +26546,26 @@ function parseArgs(argv) {
|
|
|
26542
26546
|
printUsage();
|
|
26543
26547
|
process.exit(1);
|
|
26544
26548
|
}
|
|
26545
|
-
|
|
26546
|
-
console.error("Error: --template is required");
|
|
26547
|
-
printUsage();
|
|
26548
|
-
process.exit(1);
|
|
26549
|
-
}
|
|
26550
|
-
return { url, templatePath, outputPath, vault, open, silent, uri, propertyTypesPath, htmlPath };
|
|
26549
|
+
return { url, templatePath: templatePath || void 0, outputPath, vault, open, silent, uri, propertyTypesPath, htmlPath };
|
|
26551
26550
|
}
|
|
26551
|
+
var DEFAULT_TEMPLATE = {
|
|
26552
|
+
schemaVersion: "0.1.0",
|
|
26553
|
+
name: "Default",
|
|
26554
|
+
behavior: "create",
|
|
26555
|
+
noteNameFormat: "{{title}}",
|
|
26556
|
+
path: "Clippings",
|
|
26557
|
+
noteContentFormat: "{{content}}",
|
|
26558
|
+
properties: [
|
|
26559
|
+
{ name: "title", value: "{{title}}", type: "text" },
|
|
26560
|
+
{ name: "source", value: "{{url}}", type: "text" },
|
|
26561
|
+
{ name: "author", value: '{{author|split:", "|wikilink|join}}', type: "multitext" },
|
|
26562
|
+
{ name: "published", value: "{{published}}", type: "date" },
|
|
26563
|
+
{ name: "created", value: "{{date}}", type: "date" },
|
|
26564
|
+
{ name: "description", value: "{{description}}", type: "text" },
|
|
26565
|
+
{ name: "tags", value: "clippings", type: "multitext" }
|
|
26566
|
+
],
|
|
26567
|
+
triggers: []
|
|
26568
|
+
};
|
|
26552
26569
|
var templateFilePaths = /* @__PURE__ */ new Map();
|
|
26553
26570
|
function loadTemplatesFromDir(dirPath) {
|
|
26554
26571
|
const resolved = path.resolve(dirPath);
|
|
@@ -26567,19 +26584,23 @@ var linkedomParser = {
|
|
|
26567
26584
|
};
|
|
26568
26585
|
async function main() {
|
|
26569
26586
|
const args = parseArgs(process.argv);
|
|
26570
|
-
const resolvedTemplatePath = path.resolve(args.templatePath);
|
|
26571
|
-
const isDir = fs.statSync(resolvedTemplatePath).isDirectory();
|
|
26572
26587
|
let templates;
|
|
26573
26588
|
let template2;
|
|
26574
|
-
if (
|
|
26575
|
-
|
|
26576
|
-
if (templates.length === 0) {
|
|
26577
|
-
console.error(`Error: No .json template files found in ${args.templatePath}`);
|
|
26578
|
-
process.exit(1);
|
|
26579
|
-
}
|
|
26589
|
+
if (!args.templatePath) {
|
|
26590
|
+
template2 = DEFAULT_TEMPLATE;
|
|
26580
26591
|
} else {
|
|
26581
|
-
const
|
|
26582
|
-
|
|
26592
|
+
const resolvedTemplatePath = path.resolve(args.templatePath);
|
|
26593
|
+
const isDir = fs.statSync(resolvedTemplatePath).isDirectory();
|
|
26594
|
+
if (isDir) {
|
|
26595
|
+
templates = loadTemplatesFromDir(resolvedTemplatePath);
|
|
26596
|
+
if (templates.length === 0) {
|
|
26597
|
+
console.error(`Error: No .json template files found in ${args.templatePath}`);
|
|
26598
|
+
process.exit(1);
|
|
26599
|
+
}
|
|
26600
|
+
} else {
|
|
26601
|
+
const templateRaw = fs.readFileSync(resolvedTemplatePath, "utf-8");
|
|
26602
|
+
template2 = JSON.parse(templateRaw);
|
|
26603
|
+
}
|
|
26583
26604
|
}
|
|
26584
26605
|
let propertyTypes;
|
|
26585
26606
|
if (args.propertyTypesPath) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mejazbese21/obsidian-clipper-cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"description": "Command-line web clipper that turns web pages into Obsidian markdown notes, based on the official Obsidian Web Clipper.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/mohsingdp-ai/obsidian-clipper-cli.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/mohsingdp-ai/obsidian-clipper-cli#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/mohsingdp-ai/obsidian-clipper-cli/issues"
|
|
12
|
+
},
|
|
5
13
|
"bin": {
|
|
6
|
-
"obsidian-clipper": "./dist/cli.cjs"
|
|
14
|
+
"obsidian-clipper": "./dist/cli.cjs",
|
|
15
|
+
"obsidian-clipper-cli": "./dist/cli.cjs"
|
|
7
16
|
},
|
|
8
17
|
"publishConfig": {
|
|
9
18
|
"access": "public"
|