Skip to content

Commit 3caa3e6

Browse files
committed
all of my updates that I have to stretch so far
1 parent 8ce90b6 commit 3caa3e6

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

lesson_02/package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lesson_02/quiz_java/src/Main.java

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Main.java (pseudocode)
2+
3+
/*
4+
Goal: Read a Markdown (.md) file, convert it to HTML, wrap it with GitHub-style
5+
CSS, and write out output.html — using the codedifferently-instructional library.
6+
*/
7+
8+
public class Main {
9+
public static void main(String[] args) {
10+
// ── 0) Gather Inputs ───────────────────────────────────────────────────────
11+
// Input A: path to markdown file (default: "README.md")
12+
// Input B: output file path (default: "output.html")
13+
// Input C (optional): use CDN CSS or local CSS; include code highlighting?
14+
15+
String mdPath = args.length > 0 ? args[0] : "README.md";
16+
String outputPath = args.length > 1 ? args[1] : "output.html";
17+
boolean useCdnCss = true; // tweak as needed
18+
boolean highlight = false; // tweak as needed
19+
20+
// ── 1) Read .md file ───────────────────────────────────────────────────────
21+
// read all text from mdPath into a String: markdownText
22+
// if file not found, print friendly message and exit.
23+
24+
String markdownText = /* readFile(mdPath) */ null; // TODO: implement
25+
26+
// ── 2) Convert Markdown → raw HTML ─────────────────────────────────────────
27+
// Use the codedifferently-instructional library here.
28+
// ex: MarkdownConverter.convert(markdownText) (adjust to real class/method)
29+
String htmlBody = /* CodedDifferentlyMarkdown.convert(markdownText) */ null; // TODO
30+
31+
// ── 3) Wrap HTML text inside a full HTML document ─────────────────────────
32+
// Build a template string:
33+
// - <!doctype html>, <html>, <head>, <meta charset>, <meta viewport>
34+
// - <link> to GitHub Markdown CSS (CDN or local)
35+
// - <article class="markdown-body"> {htmlBody} </article>
36+
// - (optional) include highlight.js CSS/JS if highlight == true
37+
38+
String pageHtml = buildPage(htmlBody, useCdnCss, highlight);
39+
40+
// ── 4) Write page → output file ───────────────────────────────────────────
41+
// write pageHtml to outputPath (UTF-8). On success, print where it is.
42+
43+
/* writeFile(outputPath, pageHtml) */ // TODO
44+
45+
// ── 5) Friendly done message ──────────────────────────────────────────────
46+
// "Wrote output.html — open it in your browser!"
47+
}
48+
49+
// ───────────────────── Helper methods (pseudocode) ──────────────────────────
50+
51+
// readFile(path): String
52+
// - open file at 'path'
53+
// - read all bytes as UTF-8
54+
// - return text
55+
// - throw/handle exceptions with a clear message
56+
static String readFile(String path) { /* ... */ return null; }
57+
58+
// buildPage(bodyHtml, useCdnCss, highlight): String
59+
// - choose cssLink = CDN or local path based on useCdnCss
60+
// - start template with <!doctype html>, <head> (meta + link rel="stylesheet" href=cssLink)
61+
// - if highlight == true, add highlight.js CSS/JS tags
62+
// - wrap bodyHtml with <article class="markdown-body">...</article>
63+
// - return the full HTML page as a String
64+
static String buildPage(String bodyHtml, boolean useCdnCss, boolean highlight) {
65+
String cssLink = useCdnCss
66+
? "https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css"
67+
: "file:./github-markdown.min.css"; // adjust if you keep a local copy
68+
/* build and return the page string */
69+
return null;
70+
}
71+
72+
// writeFile(path, contents): void
73+
// - create parent folders if needed
74+
// - write UTF-8 text to 'path'
75+
// - handle errors cleanly
76+
static void writeFile(String path, String contents) { /* ... */ }
77+
}

0 commit comments

Comments
 (0)