0 votes
by (220 points)
edited by
When you have a widget that displays text at the end of a sentence (right before the period) it shows an extra space right before the period. Is there a way to prevent that?

For example when you have a widget that outputs your location if your text is;

"Your location is <<showlocation $player>>."  -----> "Your location is the bar ."

"<<showlocation $player>> is your location." -----> "the bar is your location."
 

It seems like the extra space interaction only happens if the widget is before punctuation.

1 Answer

0 votes
by (68.6k points)
Punctuation is not the issue, your widget code must be creating the space; you simply don't see it in the second case because browsers compress contiguous spaces.  What does the widget look like?
by (220 points)
edited by
<<widget "descriptor">>

<<if $args[0] == "npc">>

	<<set _npc = {body:null, size:null, hair:null, skin:null}>>
	<<set _body = []>>
	<<set _size = []>>

	<<if $activeNPC.skintone>>
		<<set _skin = $race[$activeNPC.skintone]>>
		
	<<else>>
		<<set _skin = $activeNPC.fur>>
		
	<</if>>

	<<set _npc.skin = _skin>>

	<<switch $args[1]>>
		<<case "body">>
			<<if $activeNPC.fur>>
				<<set _body.push("$activeNPC.fur-colored fur")>>
			<<elseif $activeNPC.skintone>>
				<<set _body.push("_npc.skin skin")>>
			<</if>>
			
			<<set _npc.body = Array.random(_body)>>
			_npc.body
		
		<<case "size">>
			<<if $activeNPC.sex == "male" && $activeNPC.height <= 165>>
				<<set _size.push("short")>>
				
			<<elseif $activeNPC.sex == "male" && $activeNPC.height >= 190>>
				<<set _size.push("tall")>>
				
			<<elseif $activeNPC.sex == "female" && $activeNPC.height <= 150>>
				<<set _size.push("short")>>
				
			<<elseif $activeNPC.sex == "female" && $activeNPC.height >= 175>>
				<<set _size.push("tall")>>
				
			<</if>>
			
			<<set _npc.size = Array.random(_size)>>
			_npc.size
		
	<</switch>>

<<elseif $args[0] == "player">>

<</if>>
<</widget>>

And the usage would be;

$activeNPC.name has <<descriptor 'npc' 'body'>>.

But it comes out as;

Gordon has pale skin .

The passage is tagged with nobr & widget.

by (159k points)

The nobr special tag documentation explains that each trailing newline (line-break) is replaced with a single space character, and it is those space characters (compressed by your web-browser) that you as seeing in the widget's output. I suggest using Line Continuations instead to suppress the unwanted newlines, as they don't replace the newline with a space character.

eg. The following dummy widget will not add unwanted space characters to it's output.

<<widget "UsingLineContinuations">>\
aaa\
<</widget>>

... as can be seen when it is used like so.

Some text that will not have a space before the period <<UsingLineContinuations>>.

 

by (220 points)
Thank you very much, that works.
...