feat(1019-squares-of-a-sorted-array): add py3 solution
This commit is contained in:
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user