htmltoadf

htmltoadf is an HTML to Atlassian Document Format (ADF) converter written in Rust.
The library can be used in several different ways:
- As a command line binary (either directly on a compatible host or using Docker)
- Included as a library within a Rust project
- Called from a different language or environment (e.g. C, JavaScript, Ruby, PHP, .NET etc.) using FFI
- Called as a Web Assembly (wasm) module
Demo
See demo of the tool running as a WASM library entirely in the client here: https://wouterken.github.io/htmltoadf/
CLI
Binaries
The htmltoadf tool includes an html2adf binary.
Usage
htmltoadf 0.1.6
An HTML to Atlassian Document Format (ADF) converter
USAGE:
html2adf [OPTIONS] [INPATH]
ARGS:
<INPATH> The path to the file to read
OPTIONS:
-h, --help Print help information
-o, --outpath <OUTPATH>
-V, --version Print version information
Install Binary from Crates.io with cargo install
$ cargo install htmltoadf
installing htmltoadf v0.1.6 (/usr/src/html2adf)
Updating crates.io index
Downloading crates ...
Downloaded lock_api v0.4.6
--snip--
Compiling htmltoadf v0.1.6
Finished release [optimized] target(s) in 1m 42s
Installing ~/.cargo/bin/htmltoadf
Installed package `htmltoadf v0.1.6` (executable `html2adf`)
Download Binary file from Github
Pre-built binaries can be downloaded from here: https://github.com/wouterken/htmltoadf/releases/tag/0.1.6
Docker Image
Docker Repo:
https://hub.docker.com/r/wouterken/html2adf
Usage
|
} } } } }
| |
{
{
{
}
{
}
}
}
Lib
Example Rust Code
Cargo.toml
[]
= "0.1.6"
Code
use convert_html_str_to_adf_str;
use json;
let converted = convert_html_str_to_adf_str;
let expected = json!.to_string;
assert_eq!;
WASM
Install package from npm
import init from "htmltoadf";
.;
FFI
First compile the code as a library, e.g.:
Then you can link to the library dynamic from any environment that supports a FFI. It is important to copy the dynamic library from the release directory, and provide a relative link to the library file from the FFI E.g.
Ruby
extend FFI::Library
ffi_lib
attach_function :convert, [ :string ], :string
end
puts HTMLToADF.convert()
Node/JavaScript
var ffi = require;
var htmltoadf = ffi.;
console.log;
Python
=
=
Implemented features
This converter only implements a subset of possible mappings between HTML and ADF. The following features are implemented:
- Headings
- Images
- Lists (ordered and unordered)
- Tables
- Text and Paragraphs
- Code
- Fuzz Tests
- Support for named CSS colors
- Smart image sizing
- Inline Cards
- Panels
- Emoji
- In built JSON Schema Validation
Release Process
- Increment version number in .toml and README
- Compile binaries and create release
- Build and push Docker image
- Build and push WASM NPM package
- Push crate
- Update dependency in demo page
- Push to VCS
Testing
Run cargo test
from the repository root.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/wouterken/htmltoadf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.