import { parse, sort, stringify, Page } from "../Scrapbox書籍のformat@0.2.0/mod.ts"; import Parser from "../papaparse/mod.ts"; import type { ImportedLightPage } from "../scrapbox-jp%2Ftypes/rest.ts"; const ocrs = JSON.parse(await Deno.readTextFile(Deno.args[0])) as string[]; console.log(`creating the json file...`); // 目次を取り込む const csv = await Deno.readTextFile(Deno.args[1]); const { data } = Parser.parse(csv); // JSONを作る const pages: ImportedLightPage[] = []; for (const page of sort(parse(data))) { const lines = stringify(page, new Array(ocrs.length).fill(""), ocrs).split("\n"); pages.push({ title: lines[0], lines }); } await Deno.writeTextFile("scrapbox.json", JSON.stringify({ pages })); console.log("created the json file.");