d674451070
Emorg org-mode requires [[file:path]] syntax for file links to be clickable. Updated both extract.mjs and scaffold-notes.mjs generators, and fixed all 200 existing note files.
66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
const roadmap = readFileSync(join(__dirname, "../org/study_deck_02/roadmap.org"), "utf8");
|
|
const dsaDir = join(__dirname, "../org/study_deck_02/dsa");
|
|
|
|
const topicSlug = (name) =>
|
|
name
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9]+/g, "-")
|
|
.replace(/(^-|-$)/g, "");
|
|
|
|
let currentTopic = "";
|
|
let count = 0;
|
|
|
|
for (const line of roadmap.split("\n")) {
|
|
const topicMatch = line.match(/^\* TODO (.+?) \[/);
|
|
if (topicMatch) {
|
|
currentTopic = topicSlug(topicMatch[1]);
|
|
continue;
|
|
}
|
|
|
|
const problemMatch = line.match(
|
|
/^\*\* TODO (\d+)\. (.+?) :(easy|medium|hard):/
|
|
);
|
|
if (problemMatch) {
|
|
const [, num, name, diff] = problemMatch;
|
|
const slug = name
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9]+/g, "-")
|
|
.replace(/(^-|-$)/g, "");
|
|
const code = `${num}-${slug}`;
|
|
const filePath = join(dsaDir, currentTopic, `${code}.org`);
|
|
|
|
if (existsSync(filePath)) continue;
|
|
|
|
const relPath = `../../roadmap.org::*${num}. ${name}`;
|
|
const content = `* TODO ${num}. ${name} :${diff}:
|
|
#+PROPERTY: STUDY_DECK_02
|
|
:PROPERTIES:
|
|
:NEETCODE: [[file:${relPath}][Roadmap]]
|
|
:END:
|
|
|
|
** TODO Approach
|
|
Write your approach here.
|
|
|
|
** TODO Python
|
|
#+begin_src python
|
|
|
|
#+end_src
|
|
|
|
** TODO C++
|
|
#+begin_src cpp
|
|
|
|
#+end_src
|
|
`;
|
|
writeFileSync(filePath, content);
|
|
count++;
|
|
}
|
|
}
|
|
|
|
console.log(`Created ${count} note files`);
|