Fall 2026
  • Discord
  • Gradescope
  • Syllabus

On this page

  • Start
  • Implement the Functions
  • Compile a Page
  • Grading
  • Submit
  • FAQs

Project 1: Markdown Compiler

Due: Wednesday, October 7 at 11:59pm · Worth: 20 points (+1 extra credit; maximum 21/20)

GitHub displays a formatted page when you open a Markdown README. In this project you’ll build a Python program that does a small version of that conversion. It reads a Markdown file and writes the headings, paragraphs, and other elements as HTML.

Start

Open the markdown-compiler starter, select Use this template, and create a repository named markdown-compiler under your account. Clone it and set up its Python environment. From the repository root, the folder containing pyproject.toml, run:

python -m pip install -e .
python -m pip install -r requirements.txt

The first command installs markdown-compiler. The -e option makes it use your source files as you edit them. The second installs the style checker, flake8.

Implement the Functions

Start in markdown_compiler/util/line_functions.py and markdown_compiler/__init__.py. Each function has doctests showing the input and the HTML it should produce. Implement one function at a time, keeping the supplied names, parameters, and doctests.

Spaces and tags are part of the expected output. This compiler uses <ins> for ~~text~~ and leaves unmatched delimiters as written. If two functions differ only in their delimiter and HTML tag, you can pass those values to a shared helper.

Run the doctests and style checker from the repository root:

python -m doctest -v markdown_compiler/util/line_functions.py
python -m doctest -v markdown_compiler/__init__.py
python -m flake8 --isolated markdown_compiler --ignore=E501

Fix the reported failures and rerun the checks. Style fixes include replacing import * with imports of the names you use. The --ignore=E501 option allows long lines.

Compile a Page

Implement the --add_css option at the FIXME in markdown_compiler/__main__.py. Then compile the example document without CSS:

markdown-compiler --input_file=example/README.md

Open example/README.html in your browser. Run the command again with --add_css and reopen the output to see the styled version:

markdown-compiler --input_file=example/README.md --add_css

Both commands write the same output file, so inspect each version before running the next command. The CSS option adds the starter’s two stylesheets to the generated page.

Check that fenced code blocks retain their indentation and newlines. The minify function is a separate string exercise with its own doctests. Do not apply it to the finished page, because it would remove whitespace that matters inside code blocks.

Grading

Gradescope runs your functions on new inputs, installs the command-line program, and checks its output and style. The 20 points are:

  • Inline Markdown transformations.

  • Whole-document compilation, code blocks, CSS selection, and the separate minify function.

  • The installed command produces plain and styled HTML.

  • Python code passes the flake8 command above.

Extra Credit

  • Add ordered lists, for a maximum of 21/20.

For example, these two Markdown lines:

1. apples
2. pears

should become:

<ol><li>apples</li><li>pears</li></ol>

Add three doctests to compile_lines: a one-item list, a multi-item list, and a list next to an ordinary paragraph. Show the expected HTML, including item order and where each list ends, then implement the behavior.

Submit

Commit and sync your updated markdown_compiler/ files, keeping pyproject.toml and requirements.txt. If you completed the extra credit, include this file at the repository root:

# submission.toml
[features]
ordered_lists = true

Gradescope runs the extra-credit check only when claimed. It checks the generated lists and your three added doctests. Choose GitHub and submit your repository and branch.

FAQs

Why does converting italics break my bold text?

The delimiters overlap: **bold** contains single * characters too. If your italic transformation runs first, it can consume part of a bold delimiter. Think about which transformation needs to run first, and test a line containing both bold and italic text.

Should a Markdown heading inside a code block become an HTML heading?

No. Inside a fenced code block, # heading is code to display. Track whether you’re inside a code block before applying the ordinary line transformations. Keep its indentation and newlines when you write the finished HTML.

What should happen when there’s only one delimiter?

Leave unmatched delimiters unchanged. Before replacing an opening delimiter, check that there’s a matching closing one. Try both before *unfinished and before *finished* after so you can see whether your function preserves the surrounding text.