We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

TextNode

We're going to need a way to represent all the different types of inline text. We're going to be parsing Markdown text, and outputting it to HTML, so we need an intermediate representation of the text in our code.

When I say "inline" I just mean text that is part of a larger block of text. For us, this includes:

  • text (plain)
  • **Bold text**
  • _Italic text_
  • `Code text`
  • Links, in this format: [anchor text](url)
  • Images, in this format: ![alt text](url)

Everything else we're considering block level, like headings, paragraphs, and bullet lists, and we'll handle those later.

Assignment

python3 src/main.py
./main.sh
# hello world
__pycache__/

This will prevent autogenerated __pycache__ directories from being committed to Git. Finally, create a src/textnode.py file, and read on to see what it should contain.

Here's an example of how you can create an enum:

from enum import Enum


class Bender(Enum):
    AIR_BENDER = "air"
    WATER_BENDER = "water"
    EARTH_BENDER = "earth"
    FIRE_BENDER = "fire"
TextNode(TEXT, TEXT_TYPE, URL)

Where TEXT, TEXT_TYPE, and URL are the values of the text, text_type, and url properties, respectively.

You can get the string representation of the text_type enum by using the .value field.

TextNode(This is some anchor text, link, https://www.boot.dev)

Run and submit the CLI tests from the root of the project.

You can delete the files in the public directory, they aren't needed anymore.

Tips

chmod +x main.sh
from cars import SuperCar