feat(1019-squares-of-a-sorted-array): add py3 solution

This commit is contained in:
2022-04-03 20:34:00 +05:30
parent 2b889c6f89
commit eb41db0efa
3 changed files with 46 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env zx
import Turndown from "turndown";
import * as cheerio from "cheerio";
import { client, gql } from "./graphql.mjs";
const langExt = { python3: "py", nodejs: "js", cpp: "cpp" };
@@ -35,14 +36,12 @@ const questionDir = `${questionIdPadded}_${q.titleSlug}`;
const solutionDir = `${questionDir}/${language}`;
const solutionFilePath = `${solutionDir}/solution.${langExt[language]}`;
const $ch = cheerio.load(q.content);
$ch("pre").wrapInner("<code></code>");
const td = new Turndown({});
td.addRule("pre-code", {
filter: "pre",
replacement(content) {
return "```\n" + content + "```";
},
});
const mdBody = td.turndown(q.content);
const mdBody = td.turndown($ch("body").html());
await $`mkdir -p ${solutionDir}`;
await $`touch ${solutionFilePath}`;