@luutuankiet/clipboard2markdown 0.2.1 → 0.2.2
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 +15 -7
- package/bin/cli.js +19 -3
- package/bin/diagrams.js +3 -2
- package/bin/excalidraw.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -37,13 +37,13 @@ For documents whose diagrams live as excalidraw.com share links (a screenshot pl
|
|
|
37
37
|
|
|
38
38
|
Privacy: this mode sends one read-only `GET` per link to `json.excalidraw.com` (the backend named by the link) and decrypts the scene in your browser with the key in the link's `#` fragment. Nothing you paste is sent. The HTML → MD and MD → HTML modes make no network requests at all.
|
|
39
39
|
|
|
40
|
-
**CLI for agents** (`
|
|
40
|
+
**CLI for agents** (`c2m diagrams`, Node 20+, any OS):
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
c2m diagrams expand doc.md [--write] # same output as the page
|
|
44
|
+
c2m diagrams strip doc.md [--write]
|
|
45
|
+
c2m diagrams show '<share url>' # or a local .excalidraw file
|
|
46
|
+
c2m diagrams edit '<share url>' --ops '[{"op":"rename","node":"auth","label":"Identity"}]'
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
`edit` patches the existing canvas (rename, add, connect, disconnect, relabel-edge, remove), keeps every untouched element exactly as it was, uploads the result and prints exactly one new share link. The old link keeps working. Node ids are the ones `show` prints. Uploading exists only in the CLI.
|
|
@@ -66,14 +66,22 @@ The Mermaid is deliberately lossy: positions, colours, fonts and arrow curves ar
|
|
|
66
66
|
|
|
67
67
|
## Command Line
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
Everything ships as one command, `clipboard2markdown`, also installed under the short name `c2m`. Run it without installing:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx -y @luutuankiet/clipboard2markdown --help
|
|
73
|
+
npx -y @luutuankiet/clipboard2markdown excalidraw diagram.json
|
|
74
|
+
npx -y @luutuankiet/clipboard2markdown diagrams show '<share url>'
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
or install it once:
|
|
70
78
|
|
|
71
79
|
```bash
|
|
72
80
|
npm install -g @luutuankiet/clipboard2markdown
|
|
73
81
|
c2m --help
|
|
74
82
|
```
|
|
75
83
|
|
|
76
|
-
`c2m` reads the clipboard, converts it (HTML to Markdown, or Markdown to HTML), and writes the result back. Clipboard conversion needs macOS. `c2m excalidraw` and `c2m
|
|
84
|
+
With no subcommand, `c2m` reads the clipboard, converts it (HTML to Markdown, or Markdown to HTML), and writes the result back. Clipboard conversion needs macOS. `c2m excalidraw` and `c2m diagrams` run anywhere Node 20+ runs. `c2m-diagrams` still works as an alias of `c2m diagrams`.
|
|
77
85
|
|
|
78
86
|
## Development
|
|
79
87
|
|
package/bin/cli.js
CHANGED
|
@@ -5,7 +5,8 @@ import { tmpdir } from 'os';
|
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { fileURLToPath } from 'url';
|
|
7
7
|
|
|
8
|
-
const HELP = `c2m -
|
|
8
|
+
const HELP = `clipboard2markdown (short name: c2m) - clipboard HTML <-> Markdown,
|
|
9
|
+
and Excalidraw diagrams for agents
|
|
9
10
|
|
|
10
11
|
Usage:
|
|
11
12
|
c2m HTML on the clipboard -> Markdown, plain text -> HTML
|
|
@@ -15,9 +16,15 @@ Usage:
|
|
|
15
16
|
c2m --version print the version
|
|
16
17
|
|
|
17
18
|
c2m excalidraw <file|-> JSON diagram -> excalidraw.com share link and
|
|
18
|
-
Mermaid preview (
|
|
19
|
+
Mermaid preview (see c2m excalidraw --help)
|
|
20
|
+
c2m diagrams <command> existing share links <-> Mermaid: expand, strip,
|
|
21
|
+
show, edit (see c2m diagrams --help)
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
Every command also runs without installing:
|
|
24
|
+
npx -y @luutuankiet/clipboard2markdown excalidraw diagram.json
|
|
25
|
+
|
|
26
|
+
Clipboard conversion needs macOS (it uses osascript); excalidraw and
|
|
27
|
+
diagrams run anywhere Node 20+ runs.
|
|
21
28
|
Exit codes: 0 converted, 1 empty clipboard, 2 conversion failed.
|
|
22
29
|
`;
|
|
23
30
|
|
|
@@ -143,6 +150,15 @@ if (isEntryPoint()) {
|
|
|
143
150
|
const { runExcalidraw } = await import('./excalidraw.js');
|
|
144
151
|
process.exit(await runExcalidraw(args.slice(1), { stdout: process.stdout, stderr: process.stderr }));
|
|
145
152
|
}
|
|
153
|
+
if (args[0] === 'diagrams') {
|
|
154
|
+
const { main } = await import('./diagrams.js');
|
|
155
|
+
try {
|
|
156
|
+
process.exit(await main(args.slice(1), { stdout: process.stdout, stderr: process.stderr }));
|
|
157
|
+
} catch (err) {
|
|
158
|
+
process.stderr.write('error: ' + (err && err.message ? err.message : err) + '\n');
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
146
162
|
|
|
147
163
|
if (args.includes('--help') || args.includes('-h')) {
|
|
148
164
|
process.stdout.write(HELP);
|
package/bin/diagrams.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// c2m
|
|
2
|
+
// c2m diagrams: Excalidraw share links <-> Mermaid, for agents. Reached through
|
|
3
|
+
// bin/cli.js (`c2m diagrams ...`) and, for older installs, as `c2m-diagrams`.
|
|
3
4
|
// Runs anywhere Node 20+ runs; no clipboard, no browser.
|
|
4
5
|
//
|
|
5
6
|
// stdout carries only the primary result (Markdown, Mermaid or the new link);
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
parseShareLink, normalizeScene,
|
|
14
15
|
} from '../src/diagrams/index.js';
|
|
15
16
|
|
|
16
|
-
const USAGE = `usage: c2m
|
|
17
|
+
const USAGE = `usage: c2m diagrams <command> [options]
|
|
17
18
|
|
|
18
19
|
expand <file.md> [--write] add a Mermaid reading copy under every excalidraw.com link
|
|
19
20
|
strip <file.md> [--write] remove every generated block
|
package/bin/excalidraw.js
CHANGED
|
@@ -105,7 +105,7 @@ WARNINGS
|
|
|
105
105
|
|
|
106
106
|
NOT SUPPORTED
|
|
107
107
|
images, frames, freedraw, Mermaid as input, editing an existing link (use
|
|
108
|
-
c2m
|
|
108
|
+
c2m diagrams edit for that), writing .excalidraw files.
|
|
109
109
|
`;
|
|
110
110
|
|
|
111
111
|
function readInput(target, stdin) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luutuankiet/clipboard2markdown",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Convert rich clipboard HTML from Jira, Confluence, Slack and Google apps into clean Markdown, and back.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
+
"clipboard2markdown": "bin/cli.js",
|
|
7
8
|
"c2m": "bin/cli.js",
|
|
8
9
|
"c2m-diagrams": "bin/diagrams.js"
|
|
9
10
|
},
|