Description: HTML is almost never written by hand these days. Instead, we write programs that write the HTML for us. In this homework, you will write a Python program that generates HTML from a Markdown document.
Markdown is a simpler language than HTML, and it is widely used. Social media websites like reddit use markdown to format comments; if you take the CS36: Fundamentals of Data Science, then all your homeworks will be completed in R-Markdown; and for my own personal blog at izbicki.me, I use Markdown to write all my posts. GitHub uses GitHub flavored markdown for all README.md files and for all issues.
Financial Aside: Let's consider Github's implementation of their Markdown-HTML compiler: 1. How much did it cost GitHub? 1. I would assign an entry-level engineer to implement this task and expect it to take about 1 week. 1. Entry-level engineers at Github make $148k/year, so about $3000/week. 1. Therefore, GitHub paid someone $3000 to implement what you're doing for homework. 1. Was this a good investment by GitHub? 1. GitHub has >60 million active users 1. So GitHub spent 0.005 cents per user on this feature (one time fee!) 1. GitHub makes on average about $4/user/month 1. (mostly by selling compute time, something that we don't use in this class) 1. This discrepancy between how much users pay and how much it costs "per user" to pay an engineer is why software engineers make so much money 1. This is a simplified analysis. 1. The field of "software engineering" studies actually making these project timeline estimates and accounting details. 1. Recall that employers look at your github profile when hiring, and one of the purposes of this project is to help you create a strong github profile.
Due: Tuesday, 24 February, midnight Sunday, 01 March, midnight
> NOTE: > We will still have more labs/quizzes/etc next week, > so I strongly recommend trying to complete it by this coming Sunday.
Learning objectives:
1. understand the markdown language 1. understand string manipulation in python 1. understand how compilers convert from one programming language into another
STEP 1: Fix the code so that all three github actions pass. (You do not need to edit the github actions at all, but I encourage you to read the actions to understand what they are doing.)
STEP 2: On your own machine, run the two commands below.
$ markdown-compiler --input_file=example/README.md $ markdown-compiler --input_file=example/README.md --add_csseach of these commands will generate a new file called
README.html. Open this file in firefox and take a screenshot. Place the screenshot in the correct location in this git repo so that they appear in the appropriate location in the rendered README.md. > NOTE: > Adding the --add_css flag to the command line adds css code to the webpage that modifies how the page gets rendered. > This is one advantage of using markdown over straight HTML for webpage generation: > we can easily generate many different looking webpages from the same markdown content.
> HINT: > Do not wait to run your the --input_file commands until you've completed all of the doctests. > You should run these commands continuously as you complete each function and verify that the output works.
This assignment is worth a total of 16 points. - Each passing github action in worth 4 points. - The screenshots are worth 4 points. (You will only get this credit if the html viewed in the screenshot is correct.)
Upload to canvas: 1. a url that points to your git repo 1. if you complete the extra credit below, then say so in your submission so that I know to grade it
Currently, there is no support for converting markdown lists into html lists. For example, the markdown text
1. this 2. is 3. a 4. listwill get converted into
1. this 2. is 3. a 4. listinstead of
- this
- is
- a
- list
To get this extra credit, you will have to: 1. Add 3 doctests to the compile_lines function that contain markdown lists. These should be "good" doctests that reasonably test that the list functionality works; feel free to chat 1-1 with me about this. 1. Modify your code so that these doctests pass.