Page MenuHomePhabricator

Bug or feature? A \n is automatically inserted before returned string if it starts with a colon
Closed, DuplicatePublic

Description

Hi, I came across this weird situation recently. To reproduce the scenario, first I created a module Module:Foo with the following content

local p = {}

function p.bar(frame)
	return ":test"
end

function p.baz(frame)
	return "test"
end

return p

Then I used Special:ExpandTemplates to expand the following expression

A{{#invoke:Foo|bar}}B
----
A{{#invoke:Foo|baz}}B

to get the following result

A
:testB
----
AtestB

Apparently, a \n is automatically inserted before ":testB". FYI, I was using LUA to do some transformations on page title, in a way like this

[[{{#invoke:Title|transform|{{FULLPAGENAME}}}}|description]]

and sometimes transform might return titles starting with colon. If so, the expanded wikitext might be something like this

[[
:Title|description]]

and the wikilink expression will be broken.

Though I can evade this colon-leading-situation, I was still not sure if the "\n"-prepending behavior was by design, and it seems that there's no related caveat on this in Extension:Scribunto/Lua reference manual. Thus I'd like to bring this up for a clarification. Is this a bug or a feature? Thank you.

Event Timeline

So, what should be the actual output?

A

testB?

So, what should be the actual output?

A

testB?

For now it's

A
:testB

which displays as
A
(Indented)testB
while what I want is just

A:testB

And since this task is marked as duplicate, maybe I'd better take a look at T14974 😀