Skip to content

Commit be0f196

Browse files
Merge branch 'code-differently:main' into feature/myless05
2 parents 1955aef + a12ae59 commit be0f196

File tree

177 files changed

+23698
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+23698
-6
lines changed

lesson_01/tyranricejr/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# 📝 Markdown To HTML Script
2+
3+
This program turns any Markdown file into a complete HTML document.
4+
5+
#### _Created By: Tyran Rice Jr._
6+
7+
## 📖 How It Works
8+
9+
### 1. Start with a Markdown file
10+
Markdown is plain text with some symbols for formatting
11+
12+
### 2. Read the file
13+
The script uses Pythons `open()` in-built function to read the Markdown file:
14+
```py
15+
with open(markdown_path, "r", encoding="utf-8") as md_file:
16+
```
17+
### 3. Update References
18+
When reading the markdown file, the source functions for images are not pathed properly,
19+
so we must update them:
20+
21+
### 4. Convert Markdown → HTML
22+
We then use the [`markdown`](https://pypi.org/project/Markdown/) library to turn Markdown into HTML:
23+
```py
24+
html_content = markdown.markdown(markdown_content)
25+
```
26+
27+
### 5. Wrap HTML document in a complete page
28+
We wrap the entire converted markdown file in HTML tags listed below:
29+
- `<!DOCTYPE html>` and `<html>` / `<head>` tags
30+
- A `<link>` to **GitHub's** CSS Markdown Stylesheet
31+
- Small custom CSS for width, margin and padding
32+
33+
### 6. Write to `convertedmarkdown.html`
34+
We save the wrapped HTML page:
35+
```py
36+
with open("./convertedmarkdown.html", "w") as f:
37+
```
38+
We can then see the HTML file in the same folder as `markdownparser.py`.
39+
40+
## 🚀 How to Use
41+
42+
### 1. Install `markdown`:
43+
```bash
44+
pip install Markdown
45+
```
46+
### 2. Navigate To Folder
47+
Starting from the root directory, navigate to
48+
`lesson_01/tyranricejr`. This is where the script is located in.
49+
50+
### 3. Run the script:
51+
```bash
52+
python markdownparser.py
53+
```
54+
55+
### 4. Input your `markdown` file path:
56+
The script will ask you to input your `markdown` file path. This path should be the direct path starting either from the `root` directory or from `lesson_01/tyranricejr` directory.
57+
58+
### 5. Success!
59+
After putting your correct file path, the script
60+
will give you the `HTML` converted version in the output file!
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import markdown
2+
3+
'''
4+
5+
Title: Markdown Parser
6+
7+
Description: This program turns your Markdown files into HTML files
8+
9+
Created By: Tyran Rice Jr.
10+
11+
'''
12+
13+
'''
14+
15+
Function Title: read_markdown_file
16+
17+
Description:
18+
This function reads the user's markdown file from the
19+
given path input.
20+
21+
Arguments:
22+
- markdown_path: The path to the Markdown file given by the user
23+
24+
Returns:
25+
- markdown_content: The Markdown file that was read from the given path
26+
27+
'''
28+
29+
30+
def read_markdown_file(markdown_path):
31+
with open(markdown_path, "r", encoding="utf-8") as md_file:
32+
markdown_content = md_file.readlines()
33+
34+
return markdown_content
35+
36+
37+
'''
38+
39+
Function Title: write_html_file
40+
41+
Description:
42+
This function takes the user's updated markdown file and converts it
43+
into a HTML file under the name 'convertedmarkdown.html'.
44+
45+
Arguments:
46+
- markdown_content: The updated Markdown file
47+
48+
Returns:
49+
- void: Simply writes a new HTML file
50+
51+
'''
52+
53+
54+
def write_html_file(markdown_content):
55+
# Convert Markdown file to HTML
56+
html_content = markdown.markdown(markdown_content)
57+
58+
with open("./output/convertedmarkdown.html", "w") as f:
59+
f.write("<!DOCTYPE html>\n")
60+
f.write("<html lang='en'>\n")
61+
f.write("""<head>
62+
<meta charset = "UTF-8" >
63+
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown-light.min.css" >
64+
<style >
65+
body {
66+
max-width: 800px;
67+
margin: auto;
68+
padding: 2rem;
69+
}
70+
</style >
71+
</head >
72+
<body class = "markdown-body" >""")
73+
f.write(html_content + "\n")
74+
f.write("</html>")
75+
76+
77+
'''
78+
79+
Function Title: change_url_path
80+
81+
Description:
82+
This function changes the URL path for src references to
83+
make sure they are correctly pathed to the right directory.
84+
This is done by taking the input of the user's path to their
85+
existing mark down file and adding it to the src path.
86+
87+
Arguments:
88+
- markdown_content: The Markdown file given by the user
89+
- markdown_path: The path to the Markdown file given by the user
90+
91+
Returns:
92+
- markdown_content: The new Markdown file with updated src paths
93+
94+
'''
95+
96+
97+
def change_url_path(markdown_content, markdown_path):
98+
# Removes 'README.md' from path to ensure the path is correctly referenced in src
99+
markdown_path = markdown_path.removesuffix("README.md")
100+
for i in range(len(markdown_content)):
101+
# If "src=" is located in a line, it will be correctly referenced
102+
if (markdown_content[i].find("src=") != -1):
103+
index = markdown_content[i].find("src=")
104+
# Change src to have the correct path location
105+
markdown_content[i] = markdown_content[i][:index + 4] + \
106+
"\"" + markdown_path + markdown_content[i][index + 5:]
107+
108+
return markdown_content
109+
110+
111+
def main():
112+
try:
113+
print("Welcome to Tyran's Markdown-To-HTML Converter")
114+
markdown_path = input("Please enter the path of the mark down file: ")
115+
116+
# Read the Markdown file and convert it into a list of strings
117+
markdown_content = read_markdown_file(markdown_path)
118+
119+
# Update references inside Markdown file
120+
markdown_content = change_url_path(markdown_content, markdown_path)
121+
122+
# Join the list of strings from the Markdown file into one entire string
123+
markdown_content = ''.join(markdown_content)
124+
125+
# Turn the Markdown file into a HTML file
126+
write_html_file(markdown_content)
127+
128+
print("Converted Markdown To HTML content")
129+
130+
except FileNotFoundError:
131+
print("Error: The specified Markdown file was not found.")
132+
except Exception as e:
133+
print(f"An error occurred!\nError: {e}")
134+
135+
136+
if __name__ == "__main__":
137+
main()
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html lang='en'>
3+
<head>
4+
<meta charset = "UTF-8" >
5+
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown-light.min.css" >
6+
<style >
7+
body {
8+
max-width: 800px;
9+
margin: auto;
10+
padding: 2rem;
11+
}
12+
</style >
13+
</head >
14+
<body class = "markdown-body" ><h1>📝 Markdown To HTML Script</h1>
15+
<p>This program turns any Markdown file into a complete HTML document.</p>
16+
<h4><em>Created By: Tyran Rice Jr.</em></h4>
17+
<h2>📖 How It Works</h2>
18+
<h3>1. Start with a Markdown file</h3>
19+
<p>Markdown is plain text with some symbols for formatting</p>
20+
<h3>2. Read the file</h3>
21+
<p>The script uses Pythons <code>open()</code> in-built function to read the Markdown file:
22+
<code>py
23+
with open(markdown_path, "r", encoding="utf-8") as md_file:</code></p>
24+
<h3>3. Update References</h3>
25+
<p>When reading the markdown file, the source functions for images are not pathed properly,
26+
so we must update them:</p>
27+
<h3>4. Convert Markdown → HTML</h3>
28+
<p>We then use the <a href="https://pypi.org/project/Markdown/"><code>markdown</code></a> library to turn Markdown into HTML:
29+
<code>py
30+
html_content = markdown.markdown(markdown_content)</code></p>
31+
<h3>5. Wrap HTML document in a complete page</h3>
32+
<p>We wrap the entire converted markdown file in HTML tags listed below:
33+
- <code>&lt;!DOCTYPE html&gt;</code> and <code>&lt;html&gt;</code> / <code>&lt;head&gt;</code> tags
34+
- A <code>&lt;link&gt;</code> to <strong>GitHub's</strong> CSS Markdown Stylesheet
35+
- Small custom CSS for width, margin and padding</p>
36+
<h3>6. Write to <code>convertedmarkdown.html</code></h3>
37+
<p>We save the wrapped HTML page:
38+
<code>py
39+
with open("./convertedmarkdown.html", "w") as f:</code>
40+
We can then see the HTML file in the same folder as <code>markdownparser.py</code>.</p>
41+
<h2>🚀 How to Use</h2>
42+
<h3>1. Install <code>markdown</code>:</h3>
43+
<p><code>bash
44+
pip install Markdown</code></p>
45+
<h3>2. Navigate To Folder</h3>
46+
<p>Starting from the root directory, navigate to
47+
<code>lesson_01/tyranricejr</code>. This is where the script is located in.</p>
48+
<h3>3. Run the script:</h3>
49+
<p><code>bash
50+
python markdownparser.py</code></p>
51+
<h3>4. Input your <code>markdown</code> file path:</h3>
52+
<p>The script will ask you to input your <code>markdown</code> file path. This path should be the direct path starting either from the <code>root</code> directory or from <code>lesson_01/tyranricejr</code> directory.</p>
53+
<h3>5. Success!</h3>
54+
<p>After putting your correct file path, the script
55+
will give you the <code>HTML</code> converted version in the output file!</p>
56+
</html>

lesson_03/quiz/quiz.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ quiz:
1717
anotherone:
1818
- $2y$10$8eHSzy3aCu4Ry3LzO9nWCeGpofSxsNVbnF.wCfn3ZADwQ6MEtN/KK
1919
- $2y$10$dGB0CGv7.XQC5OqfyY6iXOiJsdVyxU3ve5YE0gt4m2I8P8H13lNXa
20+
calvinrobinson:
21+
- $2y$10$cq2na3OgOfB0rpCum0vwA./4zXbQ2xZT5avpyfmpp9e0LDtU5eJu.
22+
- $2y$10$yog14Y5aV9U3lPv3s9FhaORRwg9rRslGdnBt8Px8ASQWtxUjgwHpS
23+
- $2y$10$k5rLqfcOEJy/T3E5MRczRuvIIfjeefiuDp02nSN2o7j2BUoD48nb2
24+
jarededge:
25+
- $2y$10$Kx2BYkI5IAFavfXUwN/ST.lJIuajCNlxjO5hLuvKar1Pu4CkBxNwW
26+
- $2y$10$qidseGsgyENF1SHAzQ.Kn.mJgwSaT1cqGeMohqUuOsiViiU5lmWvi
27+
- $2y$10$uU3/atiXzJAHlXr4GD5.a.bOSNVFyH0MQNDQ9tkh/hUAms/4gIi9W
2028
danielboyce:
2129
- $2y$10$3sE7jqrvoniwvAR7Hb94aOkqvWtRMX/rLARy4q8B2xJ4JVifK3BLC
2230
- $2y$10$ONEdMxmf7aUg.1p/PGhAfOIaRyNoFepaoRqpCnR//JLdJETXNKuzK
@@ -58,10 +66,14 @@ quiz:
5866
- $2y$10$FMRsdjEhIG0anbZOIcVvSOy4e4eFTZGIYYyATChwc.QRMpWuomR5C
5967
- $2y$10$0AQW/94c4pPxp8xIhJUIs.qoLnUuQg/Hwe1vd4975K96EKGEPz.H6
6068
- $2y$10$ibNpd6ZjWh/yRXafaN8R5.vxbBw7KVZ7r4IsFv4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ts6wCd3i9cOeDiJWHK1tY4QbAspwXdVUcrYllLl1vG
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import {
2+
AnswerChoice,
3+
MultipleChoiceQuizQuestion,
4+
QuizQuestion,
5+
QuizQuestionProvider,
6+
} from 'codedifferently-instructional';
7+
8+
export class CalvinRobinsonQuiz implements QuizQuestionProvider {
9+
getProviderName(): string {
10+
return 'calvinrobinson';
11+
}
12+
13+
makeQuizQuestions(): QuizQuestion[] {
14+
return [
15+
CalvinRobinsonQuiz.makeQuestion0(),
16+
CalvinRobinsonQuiz.makeQuestion1(),
17+
CalvinRobinsonQuiz.makeQuestion2(),
18+
];
19+
}
20+
21+
private static makeQuestion0(): QuizQuestion {
22+
return new MultipleChoiceQuizQuestion(
23+
0,
24+
'Why do PCs overheat?',
25+
new Map<AnswerChoice, string>([
26+
[AnswerChoice.A, 'Using a wireless mouse and keyboard'],
27+
[AnswerChoice.B, 'Excessive use of solid-state drives'],
28+
[AnswerChoice.C, 'Poor ventilation and airflow inside the case'],
29+
[AnswerChoice.D, 'Running low-resolution graphics settings'],
30+
]),
31+
AnswerChoice.UNANSWERED,
32+
); // Replace `UNANSWERED` with the correct answer.
33+
}
34+
35+
private static makeQuestion1(): QuizQuestion {
36+
return new MultipleChoiceQuizQuestion(
37+
1,
38+
'Which answer best describes GitHub?',
39+
new Map<AnswerChoice, string>([
40+
[
41+
AnswerChoice.A,
42+
'A cloud-based spreadsheet tool for financial analysis',
43+
],
44+
[
45+
AnswerChoice.B,
46+
'A social media platform for developers to share memes',
47+
],
48+
[
49+
AnswerChoice.C,
50+
'A web-based platform for hosting and collaborating on Git repositories',
51+
],
52+
[
53+
AnswerChoice.D,
54+
'A database management system for storing large datasets',
55+
],
56+
]),
57+
AnswerChoice.UNANSWERED,
58+
); // Replace `UNANSWERED` with the correct answer.
59+
}
60+
61+
private static makeQuestion2(): QuizQuestion {
62+
return new MultipleChoiceQuizQuestion(
63+
2,
64+
'What is PR in software development?',
65+
new Map<AnswerChoice, string>([
66+
[AnswerChoice.A, 'Public Relations strategy for tech companies'],
67+
[AnswerChoice.B, 'Pull Request used to propose changes in a codebase'],
68+
[AnswerChoice.C, 'Page Refresh triggered by user interaction'],
69+
[AnswerChoice.D, 'Program Runtime measured during execution'],
70+
]),
71+
AnswerChoice.UNANSWERED,
72+
); // Replace `UNANSWERED` with the correct answer.
73+
}
74+
}

0 commit comments

Comments
 (0)