This project is a Node.js application that converts Markdown content into an image using Puppeteer. The application renders the Markdown content as HTML, applies custom styles, and takes a screenshot to generate an image. The project is containerized using Docker for easy deployment.
- Convert Markdown content to styled HTML.
- Render HTML to an image using Puppeteer.
- Custom styles for various Markdown elements including blockquotes.
- Dockerized for easy deployment and consistent environment.
md2canvas/
├── fonts/
│ └── SmileySans.otf
├── node_modules/
├── views/
│ └── template.ejs
├── .dockerignore
├── Dockerfile
├── package-lock.json
├── package.json
└── server.js
- Node.js (v14 or later)
- Docker
-
Clone the repository:
git clone https://github.com/your-username/md2canvas.git cd md2canvas
-
Install dependencies:
npm install
-
Start the server:
node server.js
-
Send a POST request to the
/render
endpoint with the following JSON payload:{ "markdown": "# Hello World\nThis is a sample Markdown content.", "imageUrl": "https://example.com/image.png", "date": "Vol.1 2024-6-9", "logo_img": "https://example.com/logo.png", "qrcode_img": "https://example.com/qrcode.png" }
-
Build the Docker image:
docker build -t md2canvas:0.0.2 --output type=docker ..
-
Run the Docker container:
docker run -d --cap-add=SYS_ADMIN -p 3000:3000 --name md2canvas md2canvas:0.0.2
- Method: POST
- Description: Renders the Markdown content and returns an image.
- Request Body:
{ "markdown": "string", "imageUrl": "string", "date": "string", "logo_img": "string", "qrcode_img": "string" }
- Method: POST
- Description: Renders the Markdown content and returns the HTML.
- Request Body:
{ "markdown": "string", "imageUrl": "string", "date": "string", "logo_img": "string", "qrcode_img": "string" }
Feel free to submit issues and pull requests. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License.