REST-mobiledoc is an Express.js-based API that converts HTML and Markdown content into the Mobiledoc format. This project provides a simple and efficient way to transform content for use in Mobiledoc-compatible editors or content management systems.
We created REST-mobiledoc to bridge the gap between common content formats (HTML and Markdown) and the Mobiledoc format. This tool is particularly useful for developers and content creators who need to:
- Migrate existing content to Mobiledoc-based systems
- Provide a conversion layer in their content pipeline
- Easily transform user-generated content into a Mobiledoc-compatible format
By offering this as a REST API, we've made it easy to integrate into various workflows and applications, regardless of the programming language or platform they use.
Sorry, there is no free docker image hosting. I don't use DockerHub. You can build the image yourself and run it locally. To run the docker image, you can use the following command:
docker build -t rest-mobiledoc .
docker run -p 3000:3000 -d --name rest-mobiledoc ghcr.io/yourusername/rest-mobiledoc:latest
- Convert HTML to Mobiledoc
- Convert Markdown to Mobiledoc
- RESTful API interface
- Swagger documentation for easy API exploration
- Comprehensive error handling
- Fully tested with Jest
To set up REST-mobiledoc in your local development environment, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/REST-mobiledoc.git cd REST-mobiledoc
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
The server will start running at
http://localhost:3000
. You can access the Swagger documentation athttp://localhost:3000/api-docs
.
To run the test suite:
npm test
The API exposes a single endpoint:
POST /
Request body:
{
"source": "html" | "markdown",
"payload": "Your content here"
}
Response:
{
"result": {
"version": "0.3.1",
"markups": [],
"atoms": [],
"cards": [],
"sections": [
// Mobiledoc sections here
]
}
}
For detailed API documentation, refer to the Swagger UI available at /api-docs
when running the server.
Once the server is running, you can access the API documentation by visiting:
http://localhost:3000/api-docs
This will open the Swagger UI, where you can see detailed information about the API endpoints, try out the API directly from the browser, and see example requests and responses.
The API has one main endpoint:
POST /
: Convert HTML or Markdown to Mobiledoc
To use the API, send a POST request to the root URL (/
) with a JSON body containing:
source
: Either "html" or "markdown"payload
: The content to be converted
Example request body:
{
"source": "markdown",
"payload": "# Hello, world!\n\nThis is a test."
}
The API will respond with the converted Mobiledoc content.
Here's an example of how to use the API with curl:
curl -X POST https://api.joat.tools \
-H "Content-Type: application/json" \
-d '{
"source": "markdown",
"payload": "# Welcome to REST-mobiledoc\n\nThis is a sample Markdown document.\n\n## Features\n\n- Converts Markdown to Mobiledoc\n- Easy to use API\n- Lightweight and fast"
}'
This command sends a POST request to the API with a Markdown payload. The API should respond with the converted Mobiledoc content.
We welcome contributions to REST-mobiledoc! Here's how you can contribute:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the existing coding style.
If you encounter any problems or have feature requests, please file an issue on the GitHub issue tracker.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Express.js for the web framework
- Marked for Markdown parsing
- JSDOM for HTML parsing
- Jest for testing
- Swagger for API documentation
Thank you to all contributors who have helped shape and improve REST-mobiledoc!