top expert

a biting cat website

where will it end? who will draw the line (break)?

Please help, I can’t hold all these line breaks.

If you’ve been messing with Inform for a little while, this has probably happened to you.

>l
lab
A bowl of ice cream rests on the counter. It looks like delicious vanilla.


You had better eat that ice cream before it melts!

>

See that extra line space up there? Between “vanilla” and “You had better?” Sooner or later, we all will produce a passage with either too few or too many line spaces. In some cases, it may seem impossible for us to hit the right number.

WI §5.8 Line breaks and paragraph breaks from Writing with Inform takes an optimistic view: there are perhaps only few adjustments needed, so only a few adjustments are possible. This is true nearly all of the time! We can fix this case, for instance. Let’s look at the offending code.

lab is a room.

the interderminate ice cream is on the counter. "[IC_desc]".
the counter is a scenery supporter in lab.

IC counter is initially one;

to say IC_desc:
say "A bowl of ice cream rests on the counter. ";
if IC counter is one, say "It looks like delicious vanilla.";
if IC counter is two, say "Chocolate! My favorite.";
if IC counter is three, say "Strawberry with real chunks of fruit in it.";
increment IC counter;
if IC counter is four, now IC counter is one;

every turn when the interderminate ice cream is on the counter:
say "You had better eat that ice cream before it melts!";

Where is the line space coming from? There are hopefully only two places to look. The first is in the third sentence, "[IC_desc]". The second is in the actual description for [IC_desc].

We know that the [run paragraph on] substitution can suppress line breaks. According to the documentation:

This text substitution produces no text. It’s used only for a side-effect: it prevents a paragraph break occurring after the present text is printed, in case Inform might be tempted to place one there. Example:”

Well, let’s give it a try!

If we revise our third line of code to match the following:

the interderminate ice cream is on the counter. "[IC_desc][run paragraph on]".

Nothing changes. Let’s try adding something to the end of our substitution, instead.

to say IC_desc:
say "A bowl of ice cream rests on the counter. ";
if IC counter is one, say "It looks like delicious vanilla.";
if IC counter is two, say "Chocolate! My favorite.";
if IC counter is three, say "Strawberry with real chunks of fruit in it.";
increment IC counter;
if IC counter is four, now IC counter is one;
say run paragraph on;

That doesn’t change anything either! In this particular case, we’ll want to stay close to the punctuation. Inform makes these spacing decisions at the end of sentences, even if the influencing factors aren’t always clear. In this case, for instance, we could decorate our individual sentences so:

	if IC counter is one, say "It looks like delicious vanilla.[run paragraph on]";

That should do it! All we have to do is type those words in those brackets every time we write a text substitution. That shouldn’t add up to much in a 30k word project.

lets not run so far or so long, [run paragraph on]

Or mightn’t it? Most of us like to avoid typing when we can. We can shorten that up in a few ways. Since the inflection point is the period symbol (.) in our text, we could always approach that a different way. Credit where credit is due: Zed Lopez suggested this to me while I was fighting my way through Repeat the Ending, which has an outlandish amount of printed text.

What are we to do? Inform checks for punctuation at the end of our quoted passages, but it doesn’t check to see if we are displaying punctuation characters. How do we print a period without putting it into our sentence? We print its Unicode character. In inform, we can use a special text substitution that invokes a Unicode character code. The Unicode character code for period, for instance, 46. Where do we get this information?

Unicode references are ubiquitous. The main thing we Inform authors need is one that contains decimal codes (hex codes are apparently more popular). Wikpedia has a full list. Note that we can’t use all Unicode characters, and many of our favorites will lie tantalizingly beyond reach, as the highest possible code in Inform 10 is 65535. Humble Unicode 46 is certainly doable. We can try these:

To say dot:
say unicode 46;

To say fs:
say unicode 46;

To say p:
say unicode 46;

All will print a period. I’m partial to dot, though p is more economical. Some of our English friends might prefer fs for full stop. Any will do, as our extra space is now happily gone:

to say IC_desc:
say "A bowl of ice cream rests on the counter. ";
if IC counter is one, say "It looks like delicious vanilla[dot]";
if IC counter is two, say "Chocolate! My favorite[fs]";
if IC counter is three, say "Strawberry with real chunks of fruit in it.[p]";
increment IC counter;
if IC counter is four, now IC counter is one;

alternatives

We don’t have to do it that way, though. We could strip the periods out of our substitutions altogether, and place one in initial our description code, and then append [run paragraph on] to the end of it.

the interderminate ice cream is on the counter. "[IC_desc].[run paragraph on]".

We’re already halfway to a Frankenstein text, with our first “A bowl of ice cream…” floating above the other options. We could put a single period on a line at the bottom.

to say IC_desc:
say "A bowl of ice cream rests on the counter. ";
if IC counter is one, say "It looks like delicious vanilla";
if IC counter is two, say "Chocolate! My favorite";
if IC counter is three, say "Strawberry with real chunks of fruit in it";
say ".[run paragraph on]";
increment IC counter;
if IC counter is four, now IC counter is one;

None of this quite feels like sitting down to write, though, does it? We don’t carry loose periods in our pockets around with us or else paint period-shaped specks on our screens when we write, after all.

Nevertheless, with some judicious added touches, we can usually get things to look the way we want them to.

further adventures.

Let’s say, for some reason, we wanted to make a rulebook that printed, line by line, the first stanza of John Berryman’s “Dream Song 14.” As anyone peeking under the hood of my own Portrait with Wolf might tell you, it can be hard to lay out poetry in Inform, but we can manage this one easiliy enough:

before jumping:
follow the typesetting rules;

typesetting is a rulebook.

a typesetting rule:
say "Life, friends, is boring. We must not say so.";

a typesetting rule:
say "After all, the sky flashes, the great sea yearns,";

a typesetting rule:
unless one is one, say paragraph break;

a typesetting rule:
say "we ourselves flash and yearn,";

a typesetting rule:
say "and moreover my mother told me as a boy";

a typesetting rule:
say "(repeatingly) ‘Ever to confess you’re bored";

a typesetting rule:
say "means you have no";

If we park our text at the top of a jumping action, we’ll get this:

>jump
Life, friends, is boring. We must not say so.After all, the sky flashes, the great sea yearns,
we ourselves flash and yearn,
and moreover my mother told me as a boy
(repeatingly) "Ever to confess you're bored
means you have no
You jump on the spot.

It isn’t quite right, but we can get there! We’ll need to enforce a page break between “say so.” and “After all,” because that’s how the poem goes.

If we just assert one, as in "Life, friends, is boring. We must not say so.[line break]";, we’ll come away with an extra line space.

>jump
Life, friends, is boring. We must not say so.

After all, the sky flashes, the great sea yearns,

We can use the familiar Unicode trick, or else we can append [command clarification break]. We aren’t clarifying any commands, obviously, but we are asking the [command clarification break] to do what the documentation says that it will. Specifically:

This text substitution produces a line break, and then also a paragraph break if the text immediately following is a room description brought about by having gone to to a different room and looking around, in which case a line break should be added.

[command clarification break] is, whatever its intended purpose, an excellent means for suppressing Inform’s default tendencies to make complex determinations regarding line breaks. Since we don’t usually use the specific code that the Standard Rules uses to print room descriptions while going, we aren’t likely to ever prompt unwanted extra line breaks via [command clarification break] (see here for more information).

In other words:

a typesetting rule:
say "Life, friends, is boring. We must not say so.[command clarification break]";

Is this a superior option to typing [dot]? It requires more characters, which is certainly a strike against it! Let’s look once more at the entire output. There’s a paragraph break missing there. That’s because there’s no period ending the final rule:

a typesetting rule:
say "means you have no";

Adding a period would solve everything, but what if we don’t want one? If we simply add a [run paragraph on] substitution, we’ll end up with two breaks. The answer is another [command clarification break] at the end:

a last typesetting rule:
say command clarification break;

do not accept defeat!

I’ve struggled with stubborn line breaks in past projects, but I’ve been able to figure them all out (so far). I hope I haven’t jinxed anything by saying so! For further reading, consult this forum thread for other suggestions, tactics, and commiserations.