-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.ts
More file actions
24 lines (17 loc) · 772 Bytes
/
index.ts
File metadata and controls
24 lines (17 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as fs from "fs";
import * as core from "@actions/core";
const htmlFile = core.getInput("html-file");
core.info("Input file:" + htmlFile);
const html = fs.readFileSync(htmlFile, "utf8");
const TurndownService = require("turndown");
const TurndownPluginGfm = require("turndown-plugin-gfm");
const turndownService = new TurndownService();
const markdown = turndownService.use(TurndownPluginGfm.gfm).turndown(html);
core.debug("Generated markdown:" + markdown);
core.setOutput("markdown-content", markdown);
const Path = require("path");
const markdownFile =
Path.parse(htmlFile).dir + "/" + Path.parse(htmlFile).name + ".md";
fs.writeFileSync(markdownFile, markdown);
core.info("Output file:" + markdownFile);
core.setOutput("markdown-file", markdownFile);