Remove double space between sentences

Is there a way to prevent double spaces after periods? I certainly am not typing those in, they’re being auto-generated in the output. I know it’s old school and I appreciate that but I really prefer a single space if possible.

Any help is appreciated.

2 Likes

I have this problem accentuated by my exploitation to the hilt of the adaptive prose, and my diagnosis is that is an issue in the TADS3 itself, as described here, in a sparse order, if I’m right:

http://tads.org/t3doc/doc/sysman/strlit.htm

the handling of NL and spaces inside strings forces me to sacrifice readability for correct spacing, a sacrifice whose has already lead to a very serious bug, as dsherwood already know.

in a nut, I can’t write (edited example for spoilerish reasons; the actual text is much longer…) in a proper readable manner:
(the example is not one of the most advanced exploiting of T3’s adprose)

"<<if pc.var < 1>>
blah,  blah...
<<else>>
<<first time>>
first time blabla...
<<only>>\n
<b>important passage !</b>\n
<<first time>>another passage
<<only>>
concluding blabla"

instead of the plainly unreadable and hence, bug-prone:

"<<if pc.var < 1>>blah, blah...<<else>> <<first time>>first time blabla <<only>>\n important passage !\n<<first time>>another passage <<only>>concluding blabla"

because the former ends with a rather ugly spacing, in most, if not all, cases resulting from the NL’s needed in a rationally organised adprose coding.

so, i concur and second with dsherwood’s question, a solution whose don’t involve forking TADS3’s codebase will be rather welcome for me.

Best regards from Italy,
dott. Piergiorgio.

1 Like

I don’t think I know what you mean by automatic double spaces… I think there are compiler options regarding automatically condensing white space.

I’m equally puzzled, since this is not something I’ve seen. Could you provide an example of what you mean and the circumstances under which it occurs?

2 Likes

They show up in Prince Quisborne, though? Note the difference in size between the space after the comma, and the space after the period a couple lines down.

image

3 Likes

I’ve found the code that does this; it’s actually not a double space but an n-space. This occurs in the typographicalOutputFilter object in output.t at line 1877. As things stand you’d have to edit this line - or modify typographicalOutputFilter and override the entire filterText() method to change this.

For the next release I’ve added a new sentenceSpacer property to typographicalOutputFilter which can be overridden by game code to something other than the default n-space (so you could, if you wished, change it to a single space).

In the meantime I’ve uploaded this change to GitHub.

7 Likes

Thanks, Eric ! As you have read above, the stress test is easy to set, all I need is edit some of the unusual adprose into much more readable layout, modify the active a3lite library with the change from github, then t3make -f isekai.t3m…

Tomorrow for the actual test and its results :slight_smile:

Best regards from Italy,
dott. Piergiorgio

2 Likes

Yeah, it is with Prince Quisborne as Eric said. The source code is all written with single spaces after periods.
The default setting of both the adv3 and the adv3Lite libraries is to find sentence-ending punctuation and then automatically add \u2002 after it before outputting. This can be trivially overridden if desired, to leave the text exactly as is.

2 Likes

Thank you so much! For ADV3, found the code in en_us.t source line 3672. Just commented the line out. Works like a charm. Makes the entire text look instantly better, and not leftover from 2008…

        /*
         *   Look for sentence-ending punctuation, and put an 'en' space
         *   after each occurrence.  Recognize ends of sentences even if we
         *   have closing quotes, parentheses, or other grouping characters
         *   following the punctuation.  Do this before the hyphen
         *   substitutions so that we can look for ordinary hyphens rather
         *   than all of the expanded versions.
         */

//        val = rexReplace(eosPattern, val, '%1\u2002', ReplaceAll);
2 Likes

done the test. After editing output.t with the changes from your post and the current github revision, with this simple modify:

modify typographicalOutputFilter
   sentenceSpacer = ' ' //getting rid of double spc 
;

all look perfectly fine, at least for the initial room, whose now has a rational adprose layout :slight_smile:

Thanks again, Eric ! and

Best regards from Italy,
dott.Piergiorgio.

2 Likes

Showing off a bit the improved layout given by Eric’s solution to the doublespacing issue, I give this (non-spoilering) snippet from Isekai:

<<if mirror.examined>>
<<one of>>
inhumane... no, more correctly, an <i>elvish</i>
<<or>>
elvish
<<stopping>>
<<else>>
inhumane
<<end>>
beautifulness to these hands;

whose is definitively advanced, if not extreme, adprose: basically, the PC’s hand is initially defined as “inhumane”, then after an obvious action, the PC first self-correct is definition, then use the corrected definition.

Even I can’t have easily debugged this adprose in the former format, whose was:

<<if mirror.examined>><<one of>>inhumane... no, more correctly, an <i>elvish</i><<or>>elvish<<stopping>><<else>>inhumane<<end>> beautifulness to these hands [...]

(indeed there was a bug, noticed and removed during the reformatting of the now script-language like adprose…)

Best regards from Italy,
dott. Piergiorgio.

1 Like