Plain text only gets you so far. To format text, draw boxes, add buttons, or do almost anything else in ioL, you use tags. This chapter explains how tags are written. The next chapter puts them to work.
print('<span bold=true {Here is some bold text}>')
input()
Here is some bold text
Everything from the < to the matching > is one tag. The console doesn't display the tag itself. Instead, it carries out the tag's instructions: in this case, show some text in bold.
Each tag is self-contained. There's no separate "closing tag": the text the tag applies to goes inside the tag itself, between braces.
Here's a bigger tag, spread over several lines with a comment explaining each part:
< <! 1. the start of the tag !>
box <! 2. the tag type !>
color={black} <! 3. a field !>
{What time is it?} <! 4. the primary field !>
visible=true <! 5. another field !>
rotate=7,{deg} <! 6. a field with two values !>
> <! 7. the end of the tag !>
Normally you'd write it on one line:
<box color={black} {What time is it?} visible=true rotate=7,{deg}>
All the fields other than the primary field are called secondary fields. Each tag type has its own set of fields. The Language Reference lists the fields each tag supports.
As with ordinary text, the console doesn't care about spaces and line breaks inside a tag. Spaces around the = are fine too. The order of the fields doesn't matter either, except that the tag type must come first. These two tags do the same thing:
<span bold=true italic=true {Hello}>
<span
{Hello}
italic = true
bold = true
>
In Python, triple-quoted strings make it easy to print a tag laid out over several lines:
print('''
<box
border=2
backgroundColor={lightyellow}
color={black}
{What is your name?}
>
''')
input()
When a field has more than one value, put a comma between each pair. Leave a comma out, and the next value is no longer part of that field. Instead it goes into the primary field:
<box rotate=7,{deg} {Hello}> <! rotated by 7 degrees, containing "Hello" !>
<box rotate=7 {deg} {Hello}> <! oops: rotated by 7, containing "degHello" !>
The second box still rotates, because degrees happen to be the default unit. But {deg} ended up in the box as text. When two blocks of text end up next to each other like this, they're joined into one.
The text inside braces can contain tags of its own. This is how you format part of a block of text:
print('<box {Hello, <span bold=true {World}>!}>')
Hello, World!
Tags can be nested as deeply as you need: a box containing a box containing a span, and so on.
In fact, everything your program prints is treated as one big block of text, as if it were inside a pair of invisible braces. That's why you could print plain text in the last chapter, and why a stray } is an error: there's no block for it to close.
Get a tag type wrong, and the console reports it in the terminal:
print('<Box {Hello}>')
ioL | invalid reference | Not defined in reference scope: Box.
A value the console can't make sense of becomes the special value invalid. If it ends up in something displayed on screen, it appears as an invalid marker, so you can see where the problem is.