Skip to content

Commit 165d5a9

Browse files
author
Wouter Coppieters
committed
Added input, output and version options to CLI
1 parent e03c6b4 commit 165d5a9

File tree

6 files changed

+213
-26
lines changed

6 files changed

+213
-26
lines changed

Cargo.lock

Lines changed: 127 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "htmltoadf"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
edition = "2021"
55
license = "MIT"
66
description = "An HTML to Atlassian Document Format (ADF) converter"
@@ -27,6 +27,7 @@ lazy_static = "1.4.0"
2727
serde_json = {version ="1.0.59", features = ["preserve_order"]}
2828
regex = "1.5.4"
2929
wasm-bindgen = "0.2"
30+
clap = { version = "3.0", features = ["derive"] }
3031

3132
[target.'cfg(target_arch = "wasm32")'.dependencies]
3233
parking_lot_core = "=0.8.0"

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ RUN cargo install --path .
88
FROM debian:buster-slim
99
COPY --from=builder /usr/local/cargo/bin/html2adf /usr/local/bin/html2adf
1010

11-
CMD ["html2adf"]
11+
ENTRYPOINT ["html2adf"]
12+
CMD []

README.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,48 @@ https://wouterken.github.io/htmltoadf/
2828

2929
## CLI
3030
### Binaries
31+
32+
The htmltoadf tool includes an html2adf binary.
33+
34+
#### Usage
35+
36+
```bash
37+
$ html2adf -h
38+
```
39+
40+
```
41+
htmltoadf 0.1.6
42+
An HTML to Atlassian Document Format (ADF) converter
43+
44+
USAGE:
45+
html2adf [OPTIONS] [INPATH]
46+
47+
ARGS:
48+
<INPATH> The path to the file to read
49+
50+
OPTIONS:
51+
-h, --help Print help information
52+
-o, --outpath <OUTPATH>
53+
-V, --version Print version information
54+
```
55+
3156
### Install Binary from Crates.io with `cargo install`
3257
```
3358
$ cargo install htmltoadf
34-
installing htmltoadf v0.1.5 (/usr/src/html2adf)
59+
installing htmltoadf v0.1.6 (/usr/src/html2adf)
3560
Updating crates.io index
3661
Downloading crates ...
3762
Downloaded lock_api v0.4.6
3863
--snip--
39-
Compiling htmltoadf v0.1.5
64+
Compiling htmltoadf v0.1.6
4065
Finished release [optimized] target(s) in 1m 42s
4166
Installing ~/.cargo/bin/htmltoadf
42-
Installed package `htmltoadf v0.1.5` (executable `html2adf`)
67+
Installed package `htmltoadf v0.1.6` (executable `html2adf`)
4368
```
4469

4570
### Download Binary file from Github
4671
Pre-built binaries can be downloaded from here:
47-
https://github.com/wouterken/htmltoadf/releases/tag/0.1.5
72+
https://github.com/wouterken/htmltoadf/releases/tag/0.1.6
4873

4974
### Docker Image
5075
**Docker Repo:**
@@ -54,10 +79,10 @@ https://hub.docker.com/r/wouterken/html2adf
5479
**Usage**
5580

5681
```bash
57-
$ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.5
82+
$ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.6
5883
{"version":1,"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Hello world"},{"type":"text","text":"Test"}]}]}
5984

60-
$ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.5 | jq
85+
$ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.6 | jq
6186
{
6287
"version": 1,
6388
"type": "doc",
@@ -90,7 +115,7 @@ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf
90115

91116
```toml
92117
[dependencies]
93-
htmltoadf = "0.1.5"
118+
htmltoadf = "0.1.6"
94119
```
95120

96121
**Code**
@@ -143,6 +168,8 @@ cargo build --lib --release
143168

144169
Then you can link to the library dynamic from any environment that supports a FFI.
145170
**It is important to copy the dynamic library from the release directory, and provide a relative link to the library file from the FFI**
171+
172+
146173
E.g.
147174

148175
#### Ruby

docs/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
position: relative;
4141
flex: 1 1 50%;
4242
min-width: 300px;
43+
min-height: 200px;
4344
}
4445

4546
.btn-toggle{
@@ -78,7 +79,7 @@
7879

7980
</style>
8081
<script defer type="module">
81-
import init, {convert} from "https://unpkg.com/htmltoadf@0.1.5/htmltoadf.js";
82+
import init, {convert} from "https://unpkg.com/htmltoadf@0.1.6/htmltoadf.js";
8283

8384
let editor;
8485

@@ -132,8 +133,9 @@ <h1>Header 1</h1>
132133
inputRaw.value = editor.getContent()
133134
output(editor.getContent())
134135
})
135-
136-
136+
editor.on('init', () => {
137+
editor.setContent(INITIAL_CONTENT)
138+
})
137139
}
138140
})
139141

@@ -160,7 +162,6 @@ <h1>Header 1</h1>
160162

161163
init().then(() => {
162164
inputRaw.value = INITIAL_CONTENT
163-
editor.setContent(INITIAL_CONTENT)
164165
output(INITIAL_CONTENT)
165166
})
166167
</script>

0 commit comments

Comments
 (0)