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

CXuesong created this task.Feb 4 2017, 8:40 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 4 2017, 8:40 AM

So, what should be the actual output?

A

testB?
Restricted Application removed a subscriber: Liuxinyu970226. · View Herald TranscriptFeb 5 2017, 3:19 AM
CXuesong added a subscriber: Liuxinyu970226.EditedFeb 6 2017, 6:29 AM

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 😀

Restricted Application removed a subscriber: Liuxinyu970226. · View Herald TranscriptFeb 6 2017, 6:29 AM