generated from marcizhu/readme-chess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
29 lines (20 loc) · 976 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { convert2img } = require("mdimg");
const fs = require("fs");
const axios = require('axios');
(async () => {
const res = await axios.get("https://raw.githubusercontent.com/milaabl/readme-chess/master/README.md");
fs.writeFileSync("./node_modules/mdimg/template/css/github.css", `@import "https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.min.css";
@import "https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.1.0/github-markdown-light.min.css";
.markdown-body {
padding: 0;
}`)
const data = res.data;
const readmeTextContents = data.split('<!-- BEGIN CHESS BOARD -->')[1].split('<!-- END CHESS BOARD -->')[0].replaceAll(`"img`, `"https://raw.githubusercontent.com/milaabl/readme-chess/master/img`);
fs.writeFileSync('./file.md', readmeTextContents);
await convert2img({
mdFile: "./file.md",
outputFilename: "./chess.png",
cssTemplate: "github",
width: 500
});
})();