htmltoadf 0.1.3 → 0.1.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 CHANGED
@@ -16,25 +16,30 @@ The library can be used in several different ways:
16
16
 
17
17
  ----
18
18
 
19
- ```toml
20
- [dependencies]
21
- htmltoadf = "0.1.3"
22
- ```
19
+ <img src="./screenshot-light.png" width=350/><img src="./screenshot-dark.png" width=350/>
20
+
21
+ ----
22
+ ## Demo
23
+
24
+ See demo of the tool running as a WASM library entirely in the client here:
25
+ https://wouterken.github.io/htmltoadf/
26
+
27
+ ----
23
28
 
24
29
  ## CLI
25
30
  ### Binaries
26
31
  ### Install Binary from Crates.io with `cargo install`
27
32
  ```
28
33
  $ cargo install htmltoadf
29
- installing htmltoadf v0.1.3 (/usr/src/html2adf)
34
+ installing htmltoadf v0.1.4 (/usr/src/html2adf)
30
35
  Updating crates.io index
31
36
  Downloading crates ...
32
37
  Downloaded lock_api v0.4.6
33
38
  --snip--
34
- Compiling htmltoadf v0.1.3
39
+ Compiling htmltoadf v0.1.4
35
40
  Finished release [optimized] target(s) in 1m 42s
36
41
  Installing ~/.cargo/bin/htmltoadf
37
- Installed package `htmltoadf v0.1.3` (executable `html2adf`)
42
+ Installed package `htmltoadf v0.1.4` (executable `html2adf`)
38
43
  ```
39
44
 
40
45
  ### Download Binary file from Github
@@ -44,15 +49,15 @@ https://github.com/wouterken/htmltoadf/releases/tag/0.1.2
44
49
  ### Docker Image
45
50
  **Docker Repo:**
46
51
 
47
- https://hub.docker.com/repository/docker/wouterken/html2adf
52
+ https://hub.docker.com/r/wouterken/html2adf
48
53
 
49
54
  **Usage**
50
55
 
51
56
  ```bash
52
- $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.2
57
+ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.4
53
58
  {"version":1,"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Hello world"},{"type":"text","text":"Test"}]}]}
54
59
 
55
- $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.2 | jq
60
+ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf:0.1.4 | jq
56
61
  {
57
62
  "version": 1,
58
63
  "type": "doc",
@@ -79,7 +84,17 @@ $ echo "<h1>Hello world<p>Test</p></h1>" | docker run --rm -i wouterken/html2adf
79
84
 
80
85
  ## Lib
81
86
 
82
- ### Example Code
87
+ ### Example Rust Code
88
+
89
+ **Cargo.toml**
90
+
91
+ ```toml
92
+ [dependencies]
93
+ htmltoadf = "0.1.4"
94
+ ```
95
+
96
+ **Code**
97
+
83
98
  ```rust
84
99
  use htmltoadf::convert_html_str_to_adf_str;
85
100
  use serde_json::json;
@@ -108,20 +123,86 @@ assert_eq!(expected, converted);
108
123
  ```
109
124
 
110
125
  ### WASM
111
- *TODO*
126
+
127
+ Install package from [npm](https://www.npmjs.com/package/htmltoadf)
128
+
129
+ ```javascript
130
+ import init, {convert} from "htmltoadf";
131
+ init()
132
+ .then(() => {
133
+ alert(convert("<h1>Hello from WebAssembly</h1>"))
134
+ });
135
+ ```
136
+
112
137
  ### FFI
113
- *TODO*
138
+ First compile the code as a library, e.g.:
139
+
140
+ ```bash
141
+ cargo build --lib --release
142
+ ```
143
+
144
+ Then you can link to the library dynamic from any environment that supports a FFI.
145
+ **It is important to copy the dynamic library from the release directory, and provide a relative link to the library file from the FFI**
146
+ E.g.
147
+
148
+ #### Ruby
149
+ ```ruby
150
+ require 'ffi'
151
+
152
+ module HTMLToADF
153
+ extend FFI::Library
154
+ ffi_lib 'libhtmltoadf'
155
+ attach_function :convert, [ :string ], :string
156
+ end
157
+
158
+ puts HTMLToADF.convert("<h1>Hello from Ruby</h1>")
159
+ ```
160
+
161
+ #### Node/JavaScript
162
+ ```javascript
163
+ var ffi = require('ffi-napi');
164
+
165
+ var htmltoadf = ffi.Library('libhtmltoadf', {
166
+ 'convert': [ 'string', [ 'string' ] ]
167
+ });
168
+ console.log(htmltoadf.convert("<h1>Hello from Node!</h1>"));
169
+
170
+ ```
171
+
172
+ #### Python
173
+ ```python
174
+ from cffi import FFI
175
+ ffi = FFI()
176
+ lib = ffi.dlopen("libhtmltoadf")
177
+ ffi.cdef("char * convert(char *);")
178
+ print(ffi.string(lib.convert(b"<h1>Hello from Python!</h1>")))
179
+
180
+ ```
114
181
 
115
182
  ## Implemented features
116
183
  This converter only implements a subset of possible mappings between HTML and ADF.
117
- The following conversions are implemented:
118
- * Headings
119
- * Images
120
- * Lists (ordered and unordered)
121
- * Tables
122
- * Text and Paragraphs
123
- * Code
124
-
184
+ The following features are implemented:
185
+ - [x] Headings
186
+ - [x] Images
187
+ - [x] Lists (ordered and unordered)
188
+ - [x] Tables
189
+ - [x] Text and Paragraphs
190
+ - [x] Code
191
+ - [ ] Fuzz Tests
192
+ - [ ] Support for named CSS colors
193
+ - [ ] Smart image sizing
194
+ - [ ] Inline Cards
195
+ - [ ] Panels
196
+ - [ ] Emoji
197
+ - [ ] In built JSON Schema Validation
198
+
199
+ ## Release Process
200
+ * Increment version number in .toml and README
201
+ * Compile binaries and create release
202
+ * Build and push Docker image
203
+ * Build and push WASM NPM package
204
+ * Update dependency in demo page
205
+ * Push to VCS
125
206
 
126
207
  ## Testing
127
208
  Run `cargo test` from the repository root.
package/htmltoadf_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "htmltoadf",
3
3
  "description": "An HTML to Atlassian Document Format (ADF) converter",
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",