Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion playground/knot/src/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,31 @@ export const DEFAULT_SETTINGS = JSON.stringify(
4,
);

const DEFAULT_PROGRAM = `from typing import Literal

type Style = Literal["italic", "bold", "underline"]

# Add parameter annotations \`line: str, word: str, style: Style\` and a return
# type annotation \`-> str\` to see if you can find the mistakes in this program.

def with_style(line, word, style):
if style == "italic":
return line.replace(word, f"*{word}*")
elif style == "bold":
return line.replace(word, f"__{word}__")

position = line.find(word)
output = line + "\\n"
output += " " * position
output += "-" * len(word)


print(with_style("Red Knot is a fast type checker for Python.", "fast", "underlined"))
`;

const DEFAULT_WORKSPACE = {
files: {
"main.py": "import os",
"main.py": DEFAULT_PROGRAM,
"knot.json": DEFAULT_SETTINGS,
},
current: "main.py",
Expand Down
Loading