Skip to content

Commit

Permalink
Perform all steps in one script
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfhandl committed Jul 25, 2023
1 parent c0e2153 commit 9d834e1
Show file tree
Hide file tree
Showing 3 changed files with 7,395 additions and 6 deletions.
35 changes: 30 additions & 5 deletions odata-protocol/temp/clean.js → odata-protocol/temp/clean.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const basename = "odata-v4.01-os-part1-protocol"
import fs from "fs";
import { exec } from "child_process";

const fs = require("fs");
const basename = "odata-v4.01-os-part1-protocol"

const old = fs.readFileSync(`./${basename}.html`, "latin1");

Expand Down Expand Up @@ -55,10 +56,34 @@ const clean = old
.replace(/#ODataJSONRef/g, "#ODataJSON")
.replace(/#ODataURLRef/g, "#ODataURL")
.replace(/#VocCapabilities/g, "#ODataVocCap")
.replace(/#VocCore/g, "#ODataVocCore");
.replace(/#VocCore/g, "#ODataVocCore")
;

fs.writeFileSync(`./${basename}-clean.html`, clean, {encoding:"latin1"})

//TODO: call pandoc to generate raw markdown
const result = await pandoc(["--eol=lf", `./${basename}-clean.html`, `-o ${basename}-raw.md`]);

const raw = fs.readFileSync(`./${basename}-raw.md`, "utf8");

const final = raw
//TODO: post-process raw markdown
;

fs.writeFileSync(`./${basename}.md`, final, {encoding:"utf8"})

//TODO: post-process raw markdown
function pandoc(args, cwd) {
return new Promise((resolve) => {
exec(
`pandoc ${args.join(" ")}`,
{ cwd },
(error, stdout, stderr) => {
resolve({
code: error && error.code ? error.code : 0,
error,
stdout,
stderr,
});
}
);
});
}
Loading

0 comments on commit 9d834e1

Please sign in to comment.