Edge Rewrite
// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a21e1e6ca8ed386c

Jump to content

Module talk:Multiformat

Page contents not supported in other languages.
Add topic
From Wikipedia, the free encyclopedia
Latest comment: 1 month ago by Grufo in topic Merge with Module:For nowiki?

Merge with Module:For nowiki?

[edit]

@Aasim: Since they are almost identical, should this be merged with Module:For nowiki instead? Compare {{Standard installation}} and this sandbox version. --Grufo (talk) 21:55, 28 May 2026 (UTC)Reply

I think that's fair, but it would still be nice to have the escape sequences. It's frustrating when one knows there probably exists a module somewhere but one can't find it. I mostly steered clear of supporting {{{1|}}} syntax because when I created this module I was largely thinking of DPL. For nowiki also is not as easy to remember as something like multiformat or params or something like that. Aasim (話すはなす) 22:53, 28 May 2026 (UTC)Reply
I get the frustration of not finding things. Category:Template metamodules should come in handy with this kind of modules. Those are not intended to be adopted by specific templates, instead they are general modules that can be potentially used by any template. I don't know about the opportunity of supporting escape sequences; my usual question in these cases is: what improvement do escape sequences bring? what problem do you have in mind that they can solve? Consider also that implementing escape sequences is as simple as doing
{{#invoke:string|replace|TEXT TO ESCAPE GOES HERE|\([%[%]%{%}\])|%1||false}}
For instance:
  • {{#invoke:string|replace|\{\{Hatnote{{!}}Example hatnote text.\}\}|\([%[%]%{%}\])|%1||false}}
    {{Hatnote|Example hatnote text.}}
--Grufo (talk) 23:23, 28 May 2026 (UTC)Reply
I also defined custom escape sequences such as \p for | and \e for = because the latter are recognized as part of parser functions and whatnot. Don't know if the method will allow for easy replacement of those escape sequences, since Lua and to a greater extent all programming languages only have certain recognized escape patterns. Aasim (話すはなす) 23:26, 28 May 2026 (UTC)Reply
Supporting \p and \e via {{#invoke:string|replace}} complicates things a bit, but also they are not really needed, since {{!}} and {{=}} are the standard way of escaping those. These however are details; the important question for me would still be: what problem do escape sequences solve? Or even, in which way are they just more convenient than using <nowiki>...</nowiki>? --Grufo (talk) 23:33, 28 May 2026 (UTC)Reply

@Aasim: I am still convinced that Module:Multiformat is a duplicate of {{#invoke:For nowiki}} with a worse syntax, so something should be done to address that. Consider also that using named parameters for separators and other strings forbids writing leading and trailing spaces (unless one uses html entities). I want also you to see with your own eyes how frame:preprocess() leads to slower code. Independently of the opportunity of introducing parameters in {{Tl}} (I am not really convinced), please check these performance tests. The numbers are the average of 10 parser profiling data results (“Lua time usage”):

P.S. There is currently a bug in {{Template link/sandbox}}: to remain consistent, when one writes |12=boom we should see |11=boom instead of |12=boom. --Grufo (talk) 21:37, 5 June 2026 (UTC)Reply

I did notice that one of my modules was a bit slow, but that was on the order of a few microseconds rather than a few seconds. Perhaps there is a better way to fix it, I would use Module:Escape instead of writing my own module if I can work the syntax.
In any case, about {{template link/sandbox}} I thought perhaps there needs to be a general purpose formatter for this, which is what I am working on right now even though I have not saved yet. Aasim (話すはなす) 22:20, 5 June 2026 (UTC)Reply
@Aasim: In short: Concerning {{Tl}}, the problem is structural with Lua and there is nothing we can do about it: the parameter order is always lost. If someone were to write something like {{Tl|My template|foo=bar|zoo=window|amber=hello}} there would be no way to restore the original order. In {{User:Grufo/sandbox/tl-version-1}} I arbitrarily chose to show parameters in natural sort order, so you get {{My templateScript error: No such module "params".}}, but that is as arbitrary as anything else. Concerning frame:preprocess(), the biggest problem is that for each parameter it invites to call modules, templates, and parser functions more than it is necessary (for example, in {{User:Grufo/sandbox/tl-version-1}} I do not call anything, which is the main reason why it is faster—the algorithm chosen might also be slightly more efficient). Concerning {{#invoke:escape}}, the problem is the very use of escape sequences, which make the code hard to read (especially with your custom-made sequences \p and \e), whereas using <nowiki>...</nowiki> makes it very readable. Last but not least, as I mentioned earlier, using named parameters to provide strings forbids writing leading and trailing spaces. --Grufo (talk) 22:40, 5 June 2026 (UTC)Reply
Is it possible to specify a line break in for loop nowiki or even through nowiki tags? If so then yes I agree perhaps we can safely do the merge and migration. If it is not, then perhaps this module may be needed. A use case for example is that one should be able to have space or anything else as a separator. Aasim (話すはなす) 23:25, 5 June 2026 (UTC)Reply
Yes, the previous example I had shown you uses a line break followed by an asterisk as separator between parameters. It is possible because Module:For nowiki uses unnamed parameters to pass strings. --Grufo (talk) 00:29, 6 June 2026 (UTC)Reply