The result of the move request was: Moved all except RexxS: Pppery: I cannot use pageswap.js nor perform a manual round-robin move on this particular one because of technical restrictions owing to the fact the page already exists and is in the Module namespace. However, as consensus has been determined, please feel free to submit a technical request for the remaining one and somebody with a higher power level can come along and do it. (closed by non-admin page mover) SITH (talk) 02:03, 27 December 2018 (UTC)
– Centralize personal lua modules under Module:Sandbox {{3x|p}}ery (talk) 23:27, 16 December 2018 (UTC)
(Module:Sandbox/Angr pukhlya and Module:Sandbox/Shah Jahan Ishaq already exist, so the modules that I would otherwise move there are given a ? target. ) {{3x|p}}ery (talk) 23:27, 16 December 2018 (UTC)
"It exists to provide a convenient pseudo-namespace for code testing
"It is important that you clean up after any move you perform."
I have a general design/coding question which I hope someone here could shed some light on. I've seen several table modules which work in the style of 1 module for the table-header and 1 module for the table-rows with corresponding templates. I was wondering, is there a way for a template to accept a list of parameters as one parameter? So for example, instead of calling the table-row template for each row and passing it the parameters |a=, |b= and |c=, have a |row= parameter that gets the row parameters |a=, |b= and |c=? --Gonnym (talk) 08:05, 13 December 2018 (UTC)
|a=
|b=
|c=
|row=
| delimiter = = |
local paramTable = mw.text.jsonDecode(args['your param name'])
The result of the move request was: consensus not to move the modules at this time, per the discussion below, which might also imply that the discussion above should be revisited at some point. Dekimasuよ! 08:27, 3 January 2019 (UTC)
– Centralize personal lua modules under Module:Sandbox (I nominated this one separately from the previous batch as these follow a consistent convention as Module:User:..., whereas the other batch didn't) {{3x|p}}ery (talk) 03:21, 27 December 2018 (UTC)
Fred Gandt · talk · contribs
/sandbox
Module:User:...
Module:Sandbox/FooBar/...
Module:Sandbox/<Username>/...
It exists to provide a convenient pseudo-namespace for code testing ... Please name your experimental modules in the following format
It exists to provide a convenient pseudo-namespace for code testing ...
Please name your experimental modules in the following format
Module:User:<Your User Name>
Module:User:<user>
Module:<user>
I'm trying to create a pattern to capture two sets of digits group that can be separated by various means such as "11-12", "11, 12", "11 / 12", "11 <hr /> 12".
This works for most of these:
local _, _, num1, num2 = episodeNumber:find("(%d*)%s*%p*%a*%s*%p*%s*(%d*)")
However I ran into two problems. The first was, why does
episodeNumber:find("(%d*)%s*.*%s*(%d*)")
or even
not work? The documentation says that "%." is all characters, so shouldn't that catch them?
The second was, that when I tried "11–12" (En dash) did not work. Does %p not cover it as well? If it's possible, would appreciate some insights into this as I'm really confused. Thanks. --Gonnym (talk) 20:54, 9 January 2019 (UTC)
mw.ustring.find('12–23', '%p')
<hr />
<hr/>
num1, num2 = mw.ustring.match (episodeNumber, '(%d+)%s*[%-–,/]%s*(%d+)') or episodeNumber:match ('(%d+)%s*<hr */>%s*(%d+)')
or
num1, num2 = mw.ustring.match (episodeNumber, '(%d+)%s*[%-–,/]%s*(%d+)') if not num1 then num1, num2 = episodeNumber:match ('(%d+)%s*<hr */>%s*(%d+)') end
The cheat's way of extracting two (and only two) unsigned integers is:
num1, num2 = episodeNumber:match('^%D*(%d+)%D+(%d+)%D*$')
%d+
%D*
The above works well for the given inputs but would be trickier if signed integers or numbers with decimal digits were wanted. Using (%d*) is no good because it matches zero or more digits so would often end up as an empty string. %. is an actual dot (period, full stop). Your last pattern includes .* which matches zero or more of any character (actually, any byte since using standard Lua functions), as many as possible. That will match everything up to the end of the string. You would have better luck with .- which matches zero or more of any byte, as few as possible. Johnuniq (talk) 01:30, 10 January 2019 (UTC)
(%d*)
%.
.*
.-
Followup question - I've ran into a problem if the range is more than 2. If it is possible, I'd like to catch the start and end of the range. So my current code is this:
local num1 local num2 if (episodeNumber:match('(%d+)%s*<hr */%s*>%s*(%d+)')) then num1, num2 = episodeNumber:match('(%d+)%s*<hr */%s*>%s*(%d+)') --divider = "<hr />" else num1, num2 = mw.ustring.match(episodeNumber, '(%d+)%s*[%s%-–,/&]%s*(%d+)') --divider = "–" end
I also have an alphanumeric block for figures like A, B, or A1, B1:
if (episodeNumber:match('(%w+)%s*<hr */%s*>%s*(%w+)')) then num1, num2 = episodeNumber:match('(%w+)%s*<hr */%s*>%s*(%w+)') --divider = "<hr />" else num1, num2 = mw.ustring.match(episodeNumber, '(%w+)%s*[%s%-–,/&]%s*(%w+)') --divider = " – " end
What I'm hoping is possible is that if the range is 1-2-3 (or 11-12-13-14, A-B-C, A1-B1-C1) to make it 1-3. --Gonnym (talk) 08:09, 11 January 2019 (UTC)
if (episodeNumber:match('^(%w+)%s*<hr */%s*>%s*(%w+)$')) then num1, num2 = episodeNumber:match('^(%w+)%s*<hr */%s*>%s*(%w+)$') --divider = "<hr />" elseif (episodeNumber:match('^(%w+)%s*<hr */%s*>.-<hr */%s*>%s*(%w+)$')) then -- 3 or more elements num1, num2 = episodeNumber:match('^(%w+)%s*<hr */%s*>.-<hr */%s*>%s*(%w+)$') --divider = "<hr />" elseif mw.ustring.match(episodeNumber, '^(%w+)%s*[%s%-–,/&]%s*(%w+)$') then num1, num2 = mw.ustring.match(episodeNumber, '^(%w+)%s*[%s%-–,/&]%s*(%w+)$') --divider = " – " else num1, num2 = mw.ustring.match(episodeNumber, '^(%w+)%s*[%-–,/&].-[%-–,/&]%s*(%w+)$') -- 3 or more elements --divider = " – " end
^
$
mw.text.split()
divider
episodeNumber
%s*[%s%-–,/&]%s*
%s*<hr */%s*>%s*
If various kind of separator are equivalent, a good approach is to replace all possible separators with something simple, before splitting. This is fast and works en dashes (the last line) and more. Example:
episodeNumber = episodeNumber :gsub('%s*<hr%s*/?%s*>%s*', '-') :gsub('%s*–%s*', '-')
After the above, split episodeNumber on hyphens. Johnuniq (talk) 00:49, 12 January 2019 (UTC)
When using a pattern, it seems impossible to use the pipe-symbol as a literal. I expect the pattern to recognise %| as the literal character to recognise.
A. {{#invoke:string|match|s=[[Main_page|wikihome]] |pattern=(%[) |plain=false |replace=%1}} B. {{#invoke:string|match|s=[[Main_page|wikihome]] |pattern=(%|) |plain=false |replace=%1}}
Anyting I am missing? -DePiep (talk) 10:40, 22 January 2019 (UTC)
{{!}}
(%{{!}})
C. {{#invoke:string|match|s=[[Main_page|wikihome]] |pattern=({{!}}) |plain=false |replace=%1}}
Anyone have any idea what template is Template:Gcd replaced with? It has a few pages still using it. --Gonnym (talk) 08:24, 6 February 2019 (UTC)
|answered=
(Whoever moves Module:Italian provinces/data, please do remember to update Template:ProvinciaIT)
The result of the move request was: Moved all but Module:Italian provinces/data as it's template-editor protected, I'm lighting up the admin batsignal for help moving that. (closed by non-admin page mover) SITH (talk) 17:37, 8 February 2019 (UTC)
– Move these modules to subpages of the modules that use them to make them not meet G8. (I am open to some flexibility on the new name, but these seem like the most logical start. {{3x|p}}ery (talk) 22:58, 28 January 2019 (UTC)
{{#invoke:Region topic|main | data = Module:Europe topic/data}}
I request that the code at Module:Sandbox/BrandonXLF/2 should be moved to Module:Module link. The purpose of this module is to create modules links. It is planned to be used on {{ml}}, {{mli}}, {{mlix}} and {{mlx}}. The advantage of the module is the error message (can be helpful) and it let's you use as many parameters are you need. – BrandonXLF (t@lk) 18:36, 25 November 2018 (UTC)
Please see Wikipedia talk:Templates for discussion#RfC: Proposal to make TfD more RM-like, as a clearinghouse of template discussions. — SMcCandlish ☏ ¢ 😼 05:21, 27 February 2019 (UTC)
Opinions at Template talk:Weather box#Requested move 3 March 2019 would be welcome. I'm posting here because it involves significant refactoring of a couple of modules. Johnuniq (talk) 08:37, 8 March 2019 (UTC)
(Not sure where to ask, feel free to redirect me)
The template {{IPAc-en}} offers an "audio" parameter. But no matter how I study the underlying module, I cannot understand how the parameter gets translated to the actual URL for the ogg file.
Let's take an example, from the Supercalifragilisticexpialidocious page. It contains this: {{IPAc-en|audio=Supercalifragilisticexpialidocious.ogg|ˌ|s|uː|p|ər|...}}
{{IPAc-en|audio=Supercalifragilisticexpialidocious.ogg|ˌ|s|uː|p|ər|...}}
How does "Supercalifragilisticexpialidocious.ogg" turn into [1] (which turns the web page to just an audio playback widget).
And how is one supposed to connect this to commons:File:Supercalifragilisticexpialidocious.ogg, which (presumably?) is the same file, now with all relevant details (file history, talk page etc)?
I mean, if I visit the Supercali... page and find the audio, how am I supposed to find the file details (such as who uploaded the file, who is the speaker, and so on).
Completely lost here. Regards CapnZapp (talk) 23:06, 9 March 2019 (UTC)
I have a request open at Template talk:Article history#DYK subpage parameter. It would appear to be a fairly uncomplicated request, but given my unfamiliarity with Lua, this may not be the case. Any assistance would be much appreciated. Ergo Sum 01:51, 18 March 2019 (UTC)
Not moved. See general agreement that these changes should not be made. There is a possibility as noted by the nom – "I am trying to set a guideline rather than enforce one, but given that the entire substance of the content dispute is about page naming, so RM does seem like the proper venue," – that there is a better venue for this discussion; however, noting the vehemence from other Lua experts on this subject, there seems little hope of making these potentially widely ranging changes part of a guideline. I could be wrong. Kudos to editors for your input, and Happy Publishing! (nac by page mover) Paine Ellsworth, ed. put'r there 17:37, 25 March 2019 (UTC)
– Talk pages are intended to be for discussion, not for testing Lua modules. {{3x|p}}ery (talk) 02:47, 17 March 2019 (UTC) This is admittedly an unusual requested move, as I am trying to set a guideline rather than enforce one, but given that the entire substance of the content dispute is about page naming, so RM does seem like the proper venue. For background, see Wikipedia:Edit filter noticeboard#Filter 694 is too strict, which made the move I am requesting possible. {{3x|p}}ery (talk) 02:47, 17 March 2019 (UTC)
have made no significant contribution [sic] to Wikipedia
As far as I can recall, Wikipedia:Lua#Unit testing has always advocated invoking tests from a module talk page. I don't see any compelling reason to go back and change all the module tests that have followed this advice. isaacl (talk) 17:11, 17 March 2019 (UTC)
I'm looking for a system that can make a group of images (not necessarily contiguous) all display to the same scale without using an absolute unit like pixels. The upright= parameter can rescale an image, but the effect on displayed scale is different for images with different native widths. I need something like a parameter scale= which is used to calculate and set the upright parameter. Someone should check, but I think the calculation would be upright=scale × image native width ÷ reference width. The reference width could default to whatever is considered the most common image size or be set to reference a specific image like scaleto=<filename>. Thanks for considering. SpinningSpark 17:56, 31 March 2019 (UTC)
upright=
scale=
upright=scale × image native width ÷ reference width
scaleto=<filename>
{{#invoke:Sandbox/Imagesize|getDimensions|Example.jpg}}
{{#invoke:Sandbox/Imagesize|getWidth|Example.jpg}}
{{#invoke:Sandbox/Imagesize|getHeight|Example.jpg}}
{{#invoke:Sandbox/Imagesize|getDimensions|File:Bishzilla Lucia Looking Right.gif}}
Actually, I dislike parser functions, so I've added a getScale function to the sandbox module. Using it is illustrated in the second row of the table below, with the first row using equal widths, for comparison.
There is a caveat: upright will not upscale an image above its natural dimensions. Have a look at the third row of the table below, where the scale is set to 2, which would make the Example.jpg bigger than 275x297px.
{{#invoke:Sandbox/Imagesize|getDimensions|File:Doorway from Moutiers-Saint-Jean MET DP255158.jpg}}
{{#invoke:Sandbox/Imagesize|getScale|File:Doorway from Moutiers-Saint-Jean MET DP255158.jpg|scale=1}}
As far as I can see, there's no way around that because of the way that the upright parameter is implemented. Cheers --RexxS (talk) 21:50, 31 March 2019 (UTC)
upright
IMO, the right way to show images and let some code determine dimension is the gallery tag. even if it _is_ possible to find a file's aspect ratio and make some calcs based on it using scribuntu, it's still the wrong thing to do. use gallery, use "mode=packed" (if it was up to me, it would have been the default), and use heights and widths to control the dimension. this is especially true when you want to display more than 2 or 3 images in one line: gallery will handle different browser window widths, mobile view, and other display options you may not think of (print?), and oh, by the way, unless there is a really really good reason not to, gallery will show all images (or "thumbnails") with equal heights. i know it's not a very lua-ish response, but then again, even if you have a hammer, not everything you see is a nail. (gallery example below).
gallery
heights
widths
oh - and one more thing: the correct term for the ratio between the height and width of a picture is "aspect ratio", not "scale". "scale" standard meaning (when discussing photos) is the ratio between the size of the actual object, to the size of its image. peace - קיפודנחש (aka kipod) (talk) 18:20, 1 April 2019 (UTC)
heights=
widths=
heights= and widths= are set in pixels and absolute units are deprecated nowadays.
|upright=
The examples shown above have radically different content and its hard to judge the effect scaling is having on them. I'm a little confused where we currently are. Could someone please demonstrate how these two examples are made to display at the same scale. This is taken from Power dividers and directional couplers but I'm not saying anything actually needs doing in that article. It is not the one I am currently working on. I chose it because the image sizes are hugely different, but they both contain the same elements making it easy to judge scaling by eye. SpinningSpark 22:50, 1 April 2019 (UTC)
upright = scale factor × image width / reference width
x456px
x<calculated height>px
|upright=1
upright={{scale|<upright factor>|<reference width>}}|
upright factor * image width ÷ reference width
upright={{scale original size|<file name>|<upright factor>|<reference width>}}
scale
[[File:<filename>|<parameters>]]
[[File:Name|Type|Border|Location|Alignment|Size|link=Link|alt=Alt|page=Page|lang=Langtag|Caption]]
upright=foo
[[File:....]]
{{ calcUpright | refimage = <ref image name> | refwidth = <reference image width. only one of "refimage" or "refwidth" should be used> | content = <nowiki>[[File:<image file name> | bla bla bla | bli bli bli | etc. etc. etc.]]</nowiki> }}
it should be easy enough for the lua code to extract the file name, make the required calcs, add the | upright = XXX pseudo-parameter, send the whole shebang to wikicode parsing (basically counteracting the "nowiki"), and return the result. peace - קיפודנחש (aka kipod) (talk) 17:18, 3 April 2019 (UTC)
| upright = XXX
I wish to get a Template and Lua module that shows a sequence, for example the sequence of primes, to be shown in the article Prime number. It will show the first number of the sequence, pause for a second, show the second number, pause for a second, etc. It will contain a play/pause button and a back to the beginning button. You can see a example at the bottom of this page. Thanks, David Shay דוד שי (talk) 17:59, 8 April 2019 (UTC)
Hi, I need help from someone who understands Lua to edit Module:Ancient Greek (ALA-LC). I've copied Module:Ancient Greek and made a couple of tiny adjustments. The module converts Ancient Greek text into Latin characters using the ALA-LC standard (see Romanization of Greek#Ancient Greek)
῾
Cheers, M.Clay1 (talk) 08:36, 29 March 2019 (UTC)
As you can see from the testcases, the module TimeAgo does not accurately calculate the number of years that have passed. Its current calculations are 7 days behind, it claims that 2018-04-04 (1 year and 6 days ago) was 11 months ago. This seems to result from TimeAgo not calculating based on dates, but based on seconds. Could this problem be fixed by calling Module:Age in Module:TimeAgo?
Pseudo-fix, to be placed on line 92:
-- Fix year calculations if magnitude_num == 63115200 then result_num = {{age in years|args[1]}} -- (incorrect way to call a module, but you get what I mean) -- Fix month calculations elseif magnitude_num == 5356800 then result_num = {{age in months|args[1]}} -- (again, incorrect) end
Regards, – Þjarkur (talk) 13:34, 10 April 2019 (UTC)
{{#invoke:TimeAgo|main|4 April 2018}}
{{#invoke:TimeAgo|main|2018-04-04}}
{{#invoke:TimeAgo|main|5 April 2018}}
{{#invoke:TimeAgo|main|{{#time: j F Y | -1 years -6 days}}}}
{{#time: j F Y | -1 years -6 days}}
@Þjarkur: I refactored Module:TimeAgo/sandbox and fixed the testcases, results at Module talk:TimeAgo/testcases. The module has a basic problem in that it calculates inputTime from the date/time in the input, and the time now, then takes the difference, then estimates how many time units (years/months etc.) that is. However, for most cases, the input will be something like '1 Feb 2012' (no time) and that makes inputTime assume 12 noon as the time. On the other hand, the time now is the precise date/time now (to the nearest second). That is why some obvious cases such as a date exactly 12 months ago sometimes showed 11 months. I added in a rounding kludge which seems to work. The testcases were probably correct when entered, but now, some years later, many expected calculations were wrong so I replaced them with calls to Module:Date. Please give {{time ago/sandbox}} a test. If it's ok, I'll update the main module. Johnuniq (talk) 08:01, 13 April 2019 (UTC)
{{time ago/sandbox|2019-09-13}}
{{time ago/sandbox|2019-07-14}}
{{time ago/sandbox|2016-04-14}}
{{time ago/sandbox|2018-03-15}}
Hi! A while ago i requested a module, thanksfully, helpful users helped to create. That's now used in almost all articles on Azerbaijani Wikipedia.
On Azerbaijani Wikipedia, infoboxes are filled by Wikidata properties by default to speed up creating articles. Everything is working correctly. What i want is to teach the module these:
On Wikidata: 1) If there's no Azerbaijani label/article for the Q-element, skip that and don't show in infoboxes.→2) If there's no Azerbaijani article but there's Azerbaijani label, show that in plain text.→3) If there's article on Azerbaijani wikipedia, then show the element with link to the article.
The module is located here. The part that i mentioned starts from 984th line.
An example is Corc Herbert Uoker Buş article. On infobox you can see that Doğum yeri (birth place) has parameters that are different. For example, Milton has Azerbaijani label on Wikidata but no article on Azerbaijani. That will be shown on infobox, but in plain text (category 2). Norfolk County has no Az label on Wikidata and no article in Azerbaijani Wikipedia and has to be skipped (category 1). The rest have article they will be shown (category 3).
I hope, i made myself clear. Thanks!--Toghrul Rahimli (talk) 08:43, 5 April 2019 (UTC)
Milton[d], Norfolk County[d], Massaçusets, ABŞ[1]
{{#invoke:Wikidata|formatProperty|property=P19}}
{{#invoke:Wikidata/sandbox|formatProperty|property=P19}}
teatr aktrisası
How do I print the contents of a table? I'm trying to understand the protectionLevels for a title, but Module:Sandbox/DannyS712/gen isn't printing any protection, despite the pages I test being protected. Can you help? Thanks, --DannyS712 (talk) 04:57, 21 April 2019 (UTC)
mw.dumpObject
title.protectionLevels
local p = {} function p.main( frame ) local title = mw.title.makeTitle( 'Wikipedia', 'Arbitration' ) local protection_table = title.protectionLevels local text = 'Start:<br>' for k, v in pairs( protection_table ) do text = text .. k .. ' = ' .. table.concat(v, ", ") .. '<br>' end return text end return p
This module is used in nearly 100k articles and uses a flat data file about 250k in size. Is there a way to check for performance problems with this large data file, and possible suggestions on how the data file might be split. -- GreenC 00:33, 22 April 2019 (UTC)
mw.loadData
require
Is there any template or module available that produces a country adjective from a country name? So for example "France" -> "French", "Brazil" -> "Brazilian". --Gonnym (talk) 08:30, 23 April 2019 (UTC)
pt-BR
Why wikitext table "{|\n|cell\n|}" from module → template (invoke) → page shows two lines above the table when in the page wikitext is only one line between the text and the template? If I replace wikitext with "<table><tr><td>cell</td></tr></table>" then only one empty line will be displayed as usual. --Sunpriat (talk) 01:15, 15 May 2019 (UTC)
"{|\n|cell\n|}"
"<table><tr><td>cell</td></tr></table>"
The following articles use wikitext
{{Infobox lok sabha constituency1|{{#invoke:Wikidata|pageId}}}}
For the first article, that is equivalent to
{{Infobox lok sabha constituency1|Q3595503}}
Articles
I think that due to some recent Wikidata changes, the articles are displaying "Lua error in Module:Lok_sabha_constituency at line 270: bad argument #2 to 'format' (string expected, got nil)."
Template:Infobox lok sabha constituency1 calls Module:Lok sabha constituency and looking at that shows I fixed a similar problem in January 2018. Any thoughts on how to proceed? I looked at the module again but it really needs to be rewritten. I am inclined to simply comment-out the call to the infobox in the articles. Any thoughts? Johnuniq (talk) 03:59, 21 May 2019 (UTC)
datavalue
'Q' .. foo.datavalue[numeric-id]
Hello, I am looking to streamline the {{citation}} template, by auto-generating the unique backlink as a suffix to the listing. (Full conversation.) If there is any member who is capable of training, I would like to learn.
{{citation}}
|author=
With help from Trappist the monk, Erutuon, and Headbomb, they've explained that a data module that searches for {{sfn}}, scanning the page for matching {{sfn|last|date}} and {{citation|last|first|date|title|work|url|accessdate}}, and tallies, would be loaded with mw.loadData, and then adds a backlink, after the relevant citation. - NorthPark1417 (talk) 03:43, 16 April 2019 (UTC)
In Module:Infobox television disambiguation check I currently check if the article has correct disambiguation (per WP:NCTV) by checking if it uses one of the valid formats. The format can be prefixed by a country (country TV series) or year (yyyy TV series), or both (yyyy country TV series) and I'd like to add another validation that checks if the country uses the correct adjective from the list at Module:Country adjective (based on List of adjectival and demonymic forms for countries and nations, which is what NCTV says to use). Any suggestions on how to correctly do this? --Gonnym (talk) 15:00, 19 May 2019 (UTC)
local adj_from_country = {
local country_from_adj = {}; for k, v in pairs (adj_from_country) do country_from_adj[v] = k; end return { adj_from_country = adj_from_country, country_from_adj = country_from_adj }
attempt to call field 'adjFromCountryList' (a table value).
adjFromCountryList
local data = mw.loadData ('Module:Country adjective')
local country = -- some code here that gets the country name for which you want an adjective ... if not data.adjective_from_country_list [country] then -- returns the adjective associated with country or nil -- code here to do something with a bad country return -- failure message or whatever else -- maybe not necessary -- code here to do something with a country name that has an adjective end
local adjective = -- some code here that gets the adjective for which you want a country name ... if not data.country_from_adjective_list [adjective] then -- returns the countru associated with adjective or nil -- code here to do something with a bad adjective return -- failure message or whatever else -- maybe not necessary -- code here to do something with a adjective that has a country name end
country_from_adj[v] = true;
[[year] [country adjective]] TV series | TV programme | TV program | TV film | film | miniseries | serial | game show | talk show | web series
I'm working on doing disambiguation checking for a sister infobox (Template:Infobox television season) at Module:Sandbox/Gonnym/Infobox television season disambiguation check and wanted to re-use the code. For that I've split the code to Module:Sandbox/Gonnym/Infobox disambiguation check and modified the code at the previous module (Module:Infobox television disambiguation check/sandbox) which works; I now pass as parameters the unique variables (title, validDisambiguationTypeList, exceptionList and otherInfoboxList). My problem is now, the extended disambiguation checks at the base module are different. The validation process here is:
Any idea how best to approach this? --Gonnym (talk) 13:58, 25 May 2019 (UTC)
local function getDisambiguation(title) local match = require("Module:String")._match return match(title, "%s%((.-)%)", 1, -1, false, "") end
local function getDisambiguation(title) return title:match ('%s*%b()$'); end
getDisambiguation()
string.match()
=mw.ustring.match ('title (title part) (dab)', '%s*%b()$')
=mw.ustring.match ('title (title part) (dab)', '%s*%b()$'):gsub('[%(%)]', '')
=(string.match ('title (title part) (dab)', '%s*%b()$') or ''):gsub('[%(%)]', '')
mw.ustring.match()
require()
|nomatch=
string.match (title, '%s*%b()$')
or ''
:gsub('[%(%)]', '')
mw.text.trim (dab, '()')
nil
=(string.match ('title (title part) (dab)', '%s*%b()$' or ''):gsub('[%(%)]', '')
:gsub(...)
''
nil or ''
string.gsub()
=(string.match ('title', '%s*%b()$') or ''):gsub('[%(%)]', '')
local year; local country; local num; local patterns = { '(%d%d%d%d) TV series, season (%d+)', -- <year> TV series, season <#> '(%d%d%d%d) TV series, series (%d+)', -- <year> TV series, series <#> '(%d%d%d%d) season', -- <year> season '([%D]+) season (%d+)', -- <country> season <#> '([%D]+) series (%d+)', -- <country> series <#> '([%a ]+) season', -- <country> season 'season (%d+)', -- season <#> 'series (%d+)', -- series <#> } if dab:match (patterns[1]) then year, num = dab:match (patterns[1]) elseif dab:match (patterns[2]) then year, num = dab:match (patterns[2]) elseif dab:match (patterns[3]) then year= dab:match (patterns[3]) elseif dab:match (patterns[4]) then country, num = dab:match (patterns[4]) elseif dab:match (patterns[5]) then country, num = dab:match (patterns[5]) elseif dab:match (patterns[6]) then country = dab:match (patterns[6]) elseif dab:match (patterns[7]) then num = dab:match (patterns[7]) elseif dab:match (patterns[8]) then num = dab:match (patterns[8]) end if not (year and country and num) then return false; end if year then ... end if country then ... end if num then ... end
^(%d+) TV series, season (%d+)
([%D]+) season (%d+)
%s
(string.match (title, '%s*%b()$')
validDisambiguationPatternList
'^...$'
Can someone help me create a module that converts alphanumeric emoji codes (e.g. joy) into hex codes for use with {{emoji}}? This would make that template a lot easier to use – for example, you would be able to use {{emoji|joy}} instead of {{emoji|1F602}}. Note that the logic for this module should be fairly simple, but adding all of the emoji codes will be mad work.
joy
{{emoji|joy}}
{{emoji|1F602}}
Most sites use the emoji codes listed at Emoji Cheat Sheet, the GitHub repository for which is available here. I don't see a license for the emoji code list (if it can be considered eligible for copyright), but I can ask the maintainers to license the list under ISC or similar (or waive database rights). Qzekrom 💬 theythem 02:36, 23 March 2019 (UTC)
local emotbl = { grin = "1f600", beam = "1f601", joy = "1f602", -- and so on ... smiley = "263A" } local p= {} function p.emocode(frame) local emoname = mw.text.trim(frame.args[1] or "smiley") return emotbl[emoname] end return p
{{#invoke:Emoji |emocode |the-name-of-the emoji-you-want}}
emocode
emotbl
{{emoji | {{emocode|smiley}} | size=24}}
{{emoji | {{emocode|smiley}} | size=24 | theme=noto}}
{{emoji | {{emocode|smiley}} | size=24 | theme=noto 8.0}}
{{emoji | 1f9b8-1f3ff-200d-2640-fe0f |theme=twitter | size=24}}
{{emoji | 1f9b8 1f3ff 200d 2640 |theme=noto | size=24}}
{{#invoke:Emoji | emocode | smiley}}
1f603
{{#invoke:Emoji | emoname | 1f603}}
smiley
{{emoji |{{#invoke:Emoji | emocode | smiley}} }}
{{emoji |{{#invoke:Emoji | emocode | 8ball}} }}
{{emocode | smiley}}
{{emoji | {{emocode | smiley}} }}
{{emoji | {{emocode | 8ball}} }}
{{#invoke:}}
local emoname = mw.text.trim(frame.args[1] or "smiley") local emocode = mw.text.trim(frame.args[1] or "1f603")
frame.args[1]
{{#invoke:Emoji | emocode }}
emoname
{{#invoke:Emoji | emoname }}
{{#invoke:Data|Module:Emoji/data|smiley}}
{{#invoke:Data|Module:Emoji/data|1f603}}
{{#invoke:Data|Module:Emoji/data}}
emorevtbl
{{#invoke:Data|Module:Emoji/data|emotbl|smiley}}
{{#invoke:Data|Module:Emoji/data|emorevtbl|1f603}}
p.emotbl.smiley
p.emorevtbl.1f603
{{#invoke:Emoji|emoname}}
{{#invoke:Emoji|emocode}}
{{#invoke:Emoji|emoname|1=}}
{{#invoke:Emoji|emocode|1=}}
{{#invoke:Data|Module:Emoji/data|emotbl}}
{{#invoke:Data|Module:Emoji/data|emorevtbl}}
{{#invoke:Data|Module:Emoji/data|emotbl|1=}}
{{#invoke:Data|Module:Emoji/data|emorevtbl|1=}}
true
frame.args[1] and mw.text.trim(frame.args[1])
{{#switch:{{{1}}} | happy = <code> | sad = <another code> ... etc. maybe even "| #default = <some default emoji, e.g., "can't understand what you want from me" icon > }}
switch
{{{1}}}
function emoname()