Jump to content

Module talk:Excerpt/Archive 1

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 05:58, 14 November 2019 (Archiving 1 discussion(s) from Module talk:Excerpt) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 1Archive 2Archive 3Archive 4

Paragraph selection not working

I have tried using this template in Portal:Earth sciences/Selected article/2, selecting for the first two paragraphs, and it is transcluding all of them. RockMagnetist(talk) 17:08, 27 April 2018 (UTC)

Fixed in Portal:Earth sciences/Selected article/2. The paragraph selection option is a named parameter, so the template needs paragraphs=1-2 rather then just 1-2. I'll see if I can make the documentation clearer. Certes (talk) 17:41, 27 April 2018 (UTC)
Thanks! RockMagnetist(talk) 23:36, 27 April 2018 (UTC)

A hidden template breaker

I ran into a curious problem with Portal:Earth sciences/Selected article/8. In a previous revision of Climate of India, there was a break in the middle of the caption of the third figure, and the transclusion displayed the figure as well as a badly formatted chunk of the caption in the lead. I didn't request a figure in the template. After I fixed the caption (this revision), it worked fine. RockMagnetist(talk) 23:36, 27 April 2018 (UTC)

Thanks for the report. File: and Image: can contain nested wikilinks and I've been a bit lazy in parsing them (which speeds the module up). I'm assuming that they take up the rest of the line, which is usually but not always the case. I should probably fix that soon, but it's good that you've patched things up for now. Certes (talk) 00:11, 28 April 2018 (UTC)
Yes, it's not urgent but I'll let you know if there are any more issues. RockMagnetist(talk) 02:05, 28 April 2018 (UTC)
Fixed. Certes (talk) 14:02, 28 April 2018 (UTC)

"Bad argument #1 to 'title.new' (number or string expected, got nil)"

I keep seeing the error above (clicking on it links to line 16) on some of the selections at User:Waggers/sandpit/portal selection random. (If you don't see the error at first, click "purge" to select a different article). Annoyingly the error doesn't always occur - but seems to more often than not.

It seems to be indicating that the pagename variable is not populated, yet the same page name is fed to {{more about}}, which always seems to display correctly, and the supposed lack of a pagename is not captured and handled by line 7, which looks like it's testing for pagename=nil. Am I doing something wrong? WaggersTALK 13:04, 3 May 2018 (UTC)

Thanks for the report. Whisper it quietly, but function lead (for Transclude lead excerpt) and function random (for Transclude random excerpt) are identical. They pick one of their unnamed parameters at random and treat it as an article title. In this case you're passing three unnamed parameters to lead. If your random number is 3 then these are article3, paragraphs3 and leadimages3, which evaluate to "Jane Austen", "" and "" respectively. One time in three you show part of Jane Austen; two times in three you try to show the article "" and get an error message. I can change the module so lead ignores all unnamed parameters except the first (making it differ from random), and I'll see if I can put out a more helpful error message. I should probably also make random ignore blank parameters and possibly try a different random number if it hits a missing article. Certes (talk) 13:35, 3 May 2018 (UTC)
I see, thanks. My bad - I've now named those parameters in the call to {{Transclude lead excerpt}} (they should be |paragraphs= and |files= instead of unnamed. Thanks v much for the quick response. WaggersTALK 15:06, 3 May 2018 (UTC)
Module changed as above. Choosing a random excerpt from "cat" and a bunch of invalid titles now always tells you what a cat is. I've also added errors= to show conventional Lua error messages rather than a blank excerpt. Certes (talk) 16:30, 3 May 2018 (UTC)

Bug fix request

I would like to request a small bug-fix if possible. The Transclude Lead Excerpt template leaves out the Template:Rp. An example below (note the superscript “:11” after “integral part of the airline's business”):

Biman Bangladesh Airlines, commonly known as Biman (/bmɑːn/ bee-mah-n, Bengali: [ˈbimaːn]), is the national flag carrier of Bangladesh. With its main hub at Hazrat Shahjalal International Airport in Dhaka, the airline also operates flights from its secondary hubs at Shah Amanat International Airport in Chittagong and as well as Osmani International Airport in Sylhet. The airline provides international passenger and cargo services to multiple destinations and has air service agreements in 42 countries. The headquarters of the airline, Balaka Bhaban, is located in Kurmitola, in the northern part of Dhaka. Annual Hajj flights, transporting tourists, migrants, and non-resident Bangladeshi workers and the activities of its subsidiaries form an integral part of the corporate business of the airline.

Created in February 1972, Biman enjoyed an internal monopoly in the aviation industry of Bangladesh for 24 years, until 1996. In the decades following its founding, the airline expanded its fleet and destinations but it was adversely affected by corruption and mismanagement. At its peak, Biman operated flights to 29 international destinations, extending from New York City in the west to Tokyo in the east. The airline was wholly owned and managed by the government of Bangladesh until 23 July 2007, when it was transformed into the country's largest public limited company by the Caretaker Government of Bangladesh. Since becoming a public limited company in 2007, the airline has reduced staff and begun to modernize its fleet. The airline had signed a deal with Boeing to buy ten new aircraft and options for ten more in 2008. After taking delivery of the new planes, Biman expanded its destinations and added in-flight amenities such as onboard internet, WiFi, mobile telephony and live TV streams.

During his visit to Dhaka in September 2023, French President Emmanuel Macron and then Bangladesh Prime Minister Sheikh Hasina announced the order of ten Airbus A350 aircraft for Biman. The Airbus order consists of the purchase by Biman Bangladesh Airlines of two A350F cargo aircraft and eight A350 passenger aircraft. The aircraft will be delivered in stages with two passenger A350 aircraft joining the Biman fleet first. Biman Bangladesh Airlines is certified as safe to fly in Europe by the European Union Aviation Safety Agency. In addition, Biman has also successfully passed the IATA Operational Safety Audit and since then, the airline has resumed flights to some of its previous destinations in Asia and Europe. In recent times, Biman Bangladesh Airlines has seen a marked improvement in punctuality, as well as in on-time flight performance, under its new management team. (Full article...)

Regards, Arman (Talk) 09:48, 6 May 2018 (UTC)

 Done in Module:Excerpt. @Armanaziz: thanks, good catch. Certes (talk) 18:50, 6 May 2018 (UTC)

Bug?

Default for parameter files appears to be no files rather than all files as stated on the description page. · · · Peter (Southwood) (talk): 04:51, 7 May 2018 (UTC)

I see that the description varies in different places. I will fix it to comply with reality. · · · Peter (Southwood) (talk): 04:54, 7 May 2018 (UTC)

issue

On the CKB Wikipedia nothing seems to be happening when I use the Transclude lead excerpt template. It doesn't display any text from the main article. Do you think this is because it doesn't support RTL languages or I'm doing something wrong? I used it here.--◂ ‎épine 01:01, 2 May 2018 (UTC)

I don't know! To be honest, I wrote the alpha draft of the module with English Wikipedia in mind and didn't think very hard about internationalisation at this early stage. I am quite surprised that the module has been taken up so widely and so quickly. Please can you provide links to the module and the template on CKB Wikipedia? I've not seen Sorani before and I can't actually work out how Excerpt was being used in the Evanescence portal. Arabic Wikipedia seems to be using the module ar:وحدة:Excerpt with RTL text in ar:بوابة:تشريح. Hope that helps, Certes (talk) 01:29, 2 May 2018 (UTC)
@Certes: this is the template and this is the module. Note: @مصعب: has edited the coding today. Also please ping me for future responses.--◂ ‎épine 16:55, 13 May 2018 (UTC)
@Épine: It works on Kurdish wiki. Look here brother. I am happy to help.-مصعب (talk) 17:08, 13 May 2018 (UTC)
@مصعب: I see, it seems I wasn't using the template quite correctly, however, in my defense, the documentation for the template is not really clear. That's understandable since it's still being worked on.--◂ ‎épine 19:54, 13 May 2018 (UTC)
@Épine: Please feel free to suggest what is unclear in the documentation, or just go ahead and improve it. But as you say, although several portals are already using the templates, this is an alpha module and is still being developed. The module was specifically aimed at a current initiative to improve English portals, but if other wikis are using the software then perhaps we should think more seriously about making it work better in other languages, including RTL text. Certes (talk) 20:46, 13 May 2018 (UTC)
You should definitely keep the other wikis in mind. We rely on these types of modules more than you think.--◂ ‎épine 21:15, 13 May 2018 (UTC)

Transclude lead excerpt not removing {{sfnm}}

The transclude lead excerpt template does not remove the {{sfnm}} template, which is a template for multiple refrences in one note. Dreamy Jazz (talk) 15:07, 20 May 2018 (UTC)

@Dreamy Jazz: I've now attempted to fix that problem, but I can't find an example of Sfnm being used in the lead. Please can you check the page which was broken, and confirm whether it has improved? Thanks, Certes (talk) 15:28, 20 May 2018 (UTC)
@Certes: I can no longer see them on Portal:Argentina, which is the place I noticed the problem. It seems to be fixed, thanks Dreamy Jazz (talk) 16:02, 20 May 2018 (UTC)

Possible bug with italics and bolding

I have an instance of failing to return to unitalicised text on text starting The '''SS ''Vienna''''' was built in 1873 . Text starting with "Vienna" and continuing through "was built..." until next instance of '' all in italics. Possibly misinterpreting the '''''. See below

The SS Vienna was built in 1873 during the era when steamers were built with sail rigging. She had a 19 year career marked with maritime incidents including sinking when she was just three years old. She sank for her final time in fair weather in Whitefish Bay in Lake Superior after she received a mortal blow when she was inexplicably rammed by the steamer Nipigon. Although there were no deaths when the Vienna sank for the last time, more than 100 years later her wreck claimed the lives of 4 scuba divers, the most of all the wrecks in the Whitefish Point Underwater Preserve that now protects her as part of an underwater museum. Her wreck was stripped of artifacts that resulted in the Michigan Department of Natural Resources seizing her artifacts in a raid on the Great Lakes Shipwreck Museum in 1992. Her artifacts are now on display in this museum as loan from the State of Michigan. (Full article...)

Cheers, · · · Peter (Southwood) (talk): 10:20, 22 May 2018 (UTC)

@Pbsouthwood:  Fixed. Thanks for the report. The nested apostrophe parser now handles partially italic titles in bold, such as '''SS ''Vienna''''' and '''''Billboard'' 200'''. I've also tweaked the image parsing so that it displays the ship image in preference to the U.S. flag. Certes (talk) 12:20, 22 May 2018 (UTC)
Thank you for fixing it. The least we can do as users is try to give you accurate bug reports. It is getting better than it was, so a net gain for the project. · · · Peter (Southwood) (talk): 12:37, 22 May 2018 (UTC)

Request to include image from infobox

Many article leads only have an image in the infobox. These would be desirable in the transcluded leads for portal selected articles if parameter files is set. It would also be better to specify image size in the template than to transclude the size used in the article, which is often much too large for the portal frame. · · · Peter (Southwood) (talk): 04:38, 7 May 2018 (UTC)

I agree that these are good ideas. In theory, an infobox which uses full image syntax per {{Infobox/doc#Illustration image}} should be easy to parse. In practice, each project has invented its own syntax such as {{Infobox film/doc#Image}} (which also has optional alt= and image_size= parameters). I'll have a look at it but it's probably better to leave the feature out than to implement it unreliably.
I could add an image size (or a list of sizes for multiple images?), but would it be better simply to use the [[File:...]] syntax outside the template? If the article changes to use a different image, we may well want to change the size in the excerpt too, rather than have it automatically apply the sizing chosen for a different image. Certes (talk) 09:35, 7 May 2018 (UTC)
Possibly my ignorance will show here, but how difficult would it be to extract just the file name and the caption, and combine them as a default size thumbnail at the top of the excerpt? · · · Peter (Southwood) (talk): 18:03, 7 May 2018 (UTC)
It seems to be almost getting the image from the infobox at James Talacek here:
[[File:NEEMO 14 James Talacek wearing LifeShirt.jpg|Talacek inside Aquarius during the |thumb| James Raymond Talacek is an American professional aquanaut with the University of North Carolina Wilmington (UNCW). He serves as Oceanographic Field Operations Manager at Aquarius Reef Base, the world's only undersea research laboratory. Read more...
It seems to have hit a problem with a link in the caption. · · · Peter (Southwood) (talk): 11:19, 22 May 2018 (UTC)
Yes: it misreads the | within the piped link as ending the infobox's caption= parameter. I'll see what I can do, but a bulletproof wikitext parser would take years to write and shouldn't really go in such a specialised module. Certes (talk) 12:23, 22 May 2018 (UTC)
Whatever you can do is appreciated. Cheers, · · · Peter (Southwood) (talk): 12:33, 22 May 2018 (UTC)
 Fixed, though that bit of code is more complex than I'd have liked. I see a separate bug with his name not being wikilinked. I'll take a look at that next. Certes (talk) 14:46, 22 May 2018 (UTC)
Name linking bug also fixed. (The long image caption made it appear that the bold text occurred too late in the article to be a synonym for its title.) Certes (talk) 14:59, 22 May 2018 (UTC)

Idea

It would be really helpful if the module could include the infobox picture in the excerpt instead of ignoring it completely.--◂ ‎épine 04:14, 22 May 2018 (UTC)

I've made some changes today which should make the picture appear more often. The problem is that there are so many ways to "hide" an image in an infobox. One example I've just added support for: {{Infobox ship image}} names its parameter Ship image= rather than the more common image=. I can't just take anything containing the string "image", because we don't want parameters such as map_image. If you're seeing the problem on a non-English wiki then it may be an internationalisation issue (because infoboxes on that wiki name their parameters using non-English words that I didn't think of). Certes (talk) 15:09, 22 May 2018 (UTC)

FA stars transcluded?

It looks like the code for the FA star is being transcluded on Portal:Underwater diving. I checked by taking out that specific transclusion (Underwater diving), but it took a few tries, so I think it does it for all FA articles - there can be up to three in that portal. Cheers, · · · Peter (Southwood) (talk): 11:58, 23 May 2018 (UTC)

@Pbsouthwood: Clicking the star takes me to WP:Featured pictures, so I think it may be coming from an image rather than a transcluded article excerpt.
Most FA display their star using {{featured article}} at the top (which gets removed along with the rest of the heading tag junk) or at the bottom (which gets removed along with the non-lead text). It is possible that someone buried the tag in the middle of the lead instead, in which case it will display the star, but without knowing which article is causing a problem that's hard to verify. I've changed the module to explicitly remove that sort of template wherever it appears, just in case. Certes (talk) 12:46, 23 May 2018 (UTC)

Problem with custom templates

On a very few pages, custom templates are used that are not needed for Transclude lead excerpt (such as {{Mithun Chakraborty sidebar}} and although templates like this can be removed, we could not always prepare for all eventualities. I propose that a parameter is added that allows removal of certain templates that would be included. Dreamy Jazz (talk) 22:04, 24 May 2018 (UTC)

@Dreamy Jazz:  Fixed. Portal:Bengali cinema/Selected biography/7 no longer transcludes the sidebar from Mithun Chakraborty. That article positions the sidebar unusually at the end of the lead. The module removes templates found before the lead, but retains templates within or at the end of the lead unless they're on a blacklist. I've now changed Module:Excerpt to blacklist sidebars. Certes (talk) 22:31, 24 May 2018 (UTC)

This template does not remove {{UN_Population|ref}}

The template {{UN_Population|ref}} is not removed when transcluding introductions. See Portal:Benin for example. Dreamy Jazz (talk) 09:53, 25 May 2018 (UTC)

@Dreamy Jazz:  Done. I've updated the module to keep such templates but strip out a |ref or |shortref parameter. There's a risk of catching parameters where "ref" has some other meaning, but I think it's low. Several templates work this way, including some obscure ones, so I don't think it's practical to maintain a list. Certes (talk) 10:59, 25 May 2018 (UTC)

This template is removing {{nihongo}}

As on Portal:Ancient Japan/Selected article/5 and Portal:Ancient Japan/Selected article/1, the {{nihongo}} tag is removed. This should not be removed, as it removes the page title from the lead. Dreamy Jazz (talk) 20:03, 29 May 2018 (UTC)

Yes, the module removes templates which occur before the lead, because they're usually not wanted. Here, {{nihongo}} is part of the lead but that's not obvious. Perhaps I can persuade it to retain templates which are before but on the same line as the first unadorned text in the lead. Certes (talk) 20:22, 29 May 2018 (UTC)
This also seems to cause a problem with the paragraph transclusion (see Portal:Ancient Japan/Selected article/5). It seems to include a small amount from the fourth paragraph, even though I have defined it not to. This problem only seems to happen if the paragraph parameter is defined (not seen at Portal:Ancient Japan/Selected article/1). Dreamy Jazz (talk) 20:25, 29 May 2018 (UTC)
That's a useful example and I think it shows the same problem. Like paragraph 1, paragraph 4 starts with a template. Templates at the start of a paragraph are not yet being recognised as part of the paragraph, so the module does not understand that paragraph 4 has already started. Certes (talk) 20:33, 29 May 2018 (UTC)
@Dreamy Jazz:  Fixed. Templates which are followed by text which is not a template are now treated as part of that text rather than as a template. Certes (talk) 21:43, 29 May 2018 (UTC)

Removal of "citation needed"-like templates

@Certes: I know the module already removes {{cn}} but it misses several other in the same vein. See here for details. — AfroThundr (u · t · c) 11:46, 1 June 2018 (UTC)

Paragraphs and images parameters

I assume that the "paragraphs" parameter will select the same paragraphs for all articles in the group, and the "files" parameter will do the same. How is this useful? Most articles would need different paragraphs and files for optimum display. This feature only makes sense for a single selected article. If I am wrong, an explanation would be helpful. Cheers, · · · Peter (Southwood) (talk): 06:56, 30 April 2018 (UTC)

Paragraphs= and files= exist because the Lua module is shared with {{Transclude lead excerpt}} and it was easier to provide those features than to remove them. Paragraphs=1,3,5 makes no sense unless the articles being transcluded all follow one strict pattern. However, something like paragraphs=1-4 may be useful to keep extracts reasonably short without tailoring each one individually. (If the lead contains fewer than four paragraphs, it quietly includes them all.) Files=1 includes the article's first image if any. That sounds like a good thing to do, especially if we enhance the module to lift an image from the infobox.
As an aside, I've called the parameter files= rather than images= because it counts audio samples, etc. too. (They're hard to distinguish, especially if a new filename suffix appears in future.) I could add images as a synonyms but it might be confusing when it pulls out something that's not a picture.
At least this way anyone who thinks my way can use the parameters, and anyone who prefers your approach can omit them. Certes (talk) 08:54, 30 April 2018 (UTC)
Update: despite its name, files= now chooses only images, not other media such as audio files. Certes (talk) 16:52, 1 June 2018 (UTC)

Images

I'm currently seeing that images grabbed from articles will give the full thumbnail in return. I would ask if it's possible to resize an image when calling the template but I believe unlogged users will still see the default thumbnail size? – TheGridExe (talk) 12:50, 1 June 2018 (UTC)

I wrote the image code behind this template but I don't know the answer to that question. Perhaps someone else can help. One problem is that the template chooses randomly between articles with different images, so it's hard to find one size that suits them all. Originally I left the images at the same size used in the article but that was unpopular, so I picked thumbnail as a good compromise. Certes (talk) 16:52, 1 June 2018 (UTC)

Are the tags {{what?}} and {{Primary source inline}} supposed to be removed?

Are the tags {{what?}} ({{Clarify}}) and {{Primary source inline}} supposed to be removed? As from my experimentation {{Citation needed}} is removed, so I would presume that the same would go with the other two tags. See an example at Portal:Bangladesh/Selected_article/14 Dreamy Jazz (talk) 10:43, 1 June 2018 (UTC)

This makes sense to me. Those should only really appear on the main article. — AfroThundr (u · t · c) 11:18, 1 June 2018 (UTC)
 Fixed: Module:Excerpt now removes "clarification needed", "Primary source inline" and their dozens of aliases. Certes (talk) 17:24, 1 June 2018 (UTC)

This template fails when using a wikitable in the introduction

See Portal:Ancient Japan/Selected article/4 and National Treasure (Japan). The wiki table causes a strange result and returns some of the wikitable code and no text from the lead. Dreamy Jazz (talk) 20:14, 29 May 2018 (UTC)

 Comment: It seems to be due to the way that this template is recognizing the wikitable. It seems to see each row of the wikitable is seen as a paragraph. Dreamy Jazz (talk) 20:19, 29 May 2018 (UTC)
I have reverted the changes on the selected article. Dreamy Jazz (talk) 20:20, 29 May 2018 (UTC)
I never thought of someone putting in a table before the lead had even started! I think it would normally work, but in this case it's complicated by the presence of images which are stripped out leaving a barely legal table syntax. Unless someone has a bright idea, I think we may have to draw the line at this one: the risk of adding extra complexity to handle such an unusual format would probably outweigh the advantages. Certes (talk) 20:29, 29 May 2018 (UTC)
Ok, thanks. Dreamy Jazz (talk) 21:52, 29 May 2018 (UTC)
These templates respect the noinclude tag, so one option is to mark <noinclude>problematic text</noinclude> thus. Certes (talk) 11:27, 2 June 2018 (UTC)

Short description and DISPLAYTITLE

Hi Certes. The template appears to transclude the short description and DISPLAYTITLE templates. These are not useful. DISPLAYTITLE seems to be ignored and only triggers a warning in edit mode, but the transcluded short description overrides the portal's own short description, as it is later in the page code, which is a problem. Cheers, · · · Peter (Southwood) (talk): 14:47, 18 June 2018 (UTC)

@Pbsouthwood: Thanks; I'll add them to the removal list. I was hoping that they would only appear before the lead. To help with testing, please do you have any real-world examples of where they cause a problem? Certes (talk) 15:19, 18 June 2018 (UTC)
Certes, I noticed them while working on Portal:Underwater diving. One of the cases that came up was Kursk submarine disaster for DISPLAYTITLE (it has italics in the title). The short description problem is not happening at the moment. Either it has been fixed or it is intermittent and only happens in some cases. Unfortunately I didn't record the short descriptions that came up so can't track down which articles were responsible. I will do that if it happens again. · · · Peter (Southwood) (talk): 16:02, 18 June 2018 (UTC)
Aha! Kursk is (quite correctly) using the {{DISPLAYTITLE:… magic word rather than the {{DISPLAYTITLE|… template. I'll check for that too. Certes (talk) 16:09, 18 June 2018 (UTC)
I've set up excerpts from Kursk and the similar Sinking of the Rainbow Warrior in my sandbox and they work fine. My sandbox also wikilinks the Warrior article near the start of the lead, but the Portal page doesn't. Failing to wikilink italicised titles is a bug that I fixed on 22 May. I suspect that purging the portal page would fix this problem. I've not done that as it would destroy the evidence, but please feel free to go ahead. You may have to try a few times before an italic title appears! Certes (talk) 16:39, 18 June 2018 (UTC)
Warning: Display title "<i>Kursk</i> submarine disaster" was ignored since it is not equivalent to the page's actual title. is still coming up occasionally in edit mode. Purging resets the random selection, so it will only happen when the Kursk or Rainbow Warrior article is selected. The short description override could actually cause confusion in a mobile search, so relatively important to be fixed, but it has not come up recently, so may be fixed.
Warning: Display title "Portal:Underwater divingUnder '<b></b>" was ignored since it is not equivalent to the page's actual title. has also come up a couple of times, but may be unrelated. I have no idea what is causing it or how to track it down. I assume it is called from one of the randomising templates, because it only comes up occasionally, but I don't know of anything in any of the lists for random display that would refer to a portal. · · · Peter (Southwood) (talk): 04:44, 19 June 2018 (UTC)
@Evad37: From experiment, this seems to be caused by local expandedContent = frame:preprocess(text), which now runs on every template to check that it's not an infobox. Can we run this check in some other way? This is also an expensive call, which may be a problem for portals that quote from many articles each with many templates. Certes (talk) 10:02, 19 June 2018 (UTC)
Would using frame:expandTemplate be any better? It would just need the template name to be extracted, which isn't difficult (the args can probably just be left out, since it only needs to check if there's a table with the class 'infobox' in the output). - Evad37 [talk] 10:44, 19 June 2018 (UTC)
Probably. It's worth a try if we can't find a cheaper way. DISPLAYTITLE is a special case because it's normally used as a magic word (with colon), though the deprecated template of that name (with |) also works, but it would be good to solve the more general problem. I think most infoboxes produce a table with class list including infobox (for example, mw.getCurrentFrame():expandTemplate{title = "Infobox journal"} produces <table class="infobox hproduct"…), so we could match something like <table class="[^"]*infobox in the output (%s* etc. omitted for clarity). Certes (talk) 11:01, 19 June 2018 (UTC)
Some boxes construct a table out of wikitext though, e.g. {{Subspeciesbox}} calls {{Taxobox/core}} which outputs {| class="infobox biota"... rather than a <table> element - Evad37 [talk] 11:33, 19 June 2018 (UTC)
I think that's now all fixed. I've also blocked a few more reference syntaxes. Portal:Underwater diving still shows one ref, but that's from #section-h:Outline of underwater diving and not from this template. Certes (talk) 10:47, 20 June 2018 (UTC)
Looks good at the moment. Thanks. · · · Peter (Southwood) (talk): 12:58, 20 June 2018 (UTC)
On a related point, Portal:Underwater diving reads {{Transclude random excerpt | Kursk submarine disaster#Salvage operation…. #Salvage operation is ignored. Respecting #section is an interesting idea for an enhancement but I'm not sure it would help here. The section begins The Russian government committed to raising the wreck… and it would be a while before it reminds the reader what the article is about. (|section= works but is not designed for random picks as it would seek the same section name in all articles.) Certes (talk) 10:02, 19 June 2018 (UTC)

Image from Infobox

I understand that as of now the template cannot source images from the infobox. However, the image in the infobox is often the most representative image on the topic. Given this, can we have an enhancement in this template to include the images from infobox subject to free image license verification? Arman (Talk) 05:13, 21 June 2018 (UTC)

The template does attempt to source images from the infobox, but fails on some specialised infobox templates which use unusual syntax. Please can you link to an example where it fails? We may be able to enhance the template to handle that case. Certes (talk) 10:36, 21 June 2018 (UTC)

Nice work

Next step would be to combine this with the slideshow functionality of {{Transclude excerpts as random slideshow}} as {{Transclude list item excerpts as random slideshow}}. · · · Peter (Southwood) (talk): 04:46, 25 June 2018 (UTC)

Collapsed infobox section begin

Peter Sellers is, somewhat appropriately I guess, acting strange. Please see User:Waggers/sandpit/peter, which consists only of {{transclude lead excerpt}}. I think it's something to do with the {{Collapsed infobox section begin}} template that appears inside the infobox. WaggersTALK 13:39, 25 June 2018 (UTC)

 Fixed, thanks for the report. As you say, it wasn't handling the nested infobox templates well. Certes (talk) 16:20, 25 June 2018 (UTC)

Possible exclusion of low quality articles

Would it be possible to add a minimum article quality parameter? For example if you only want to display articles of B-class or better. eg | minimum-class=B . Alternatively a parameter set that specifies all the classes that may be displayed, eg | class=C,B,GA to display only articles of classes C, B, and GA would be more versatile, though I don't see any obvious use for it. Cheers, · · · Peter (Southwood) (talk): 05:03, 25 June 2018 (UTC)

This template is designed to work in cooperation with JL-Bot, which can limit the source list to good and/or featured articles. However, it may be possible for Module:Excerpt to limit the scope as you suggest. We'd have the usual problem that editors find inventive alternatives to adding the expected text string, but at least that would be a right-side failure in that we'd display some other good article instead. It may involve substantial work, both in coding and in parsing talk pages at run time, especially for an article such as The Hague which has been assessed by multiple wikiprojects. Certes (talk) 11:36, 25 June 2018 (UTC)
That should also work. Can JL-Bot be requested to include B-class? I don't remember that as an option, though it might be less processor intensive depending on how it identifies the class. If the check was made according to the category used by the WikiProject associated with the portal to filter out the unwanted articles it might be quicker. Actually I have no idea how JL-Bot goes about its allotted tasks, so may be making useless suggestions. Anyway, just in case something might work... Cheers, · · · Peter (Southwood) (talk): 17:53, 25 June 2018 (UTC)
This may be relevant.· · · Peter (Southwood) (talk): 18:21, 25 June 2018 (UTC)

Bug reports

Hello. I've been playing around with using this on Portal:Scottish Islands and have encountered a few bugs...

Thanks for any assistance with these! Espresso Addict (talk) 20:37, 12 July 2018 (UTC)

@Espresso Addict: I've updated the image detection code, can you check if there's any still missing an image? - Evad37 [talk] 08:58, 13 July 2018 (UTC)
Thanks, @Evad37:, that looks a lot better. As far as I can tell (the script started timing out all the time before I'd finished), the only ones missing an image now are Whisky Galore! (1949 film), which I assume is because it's correctly assessing the poster as copyright, and all the ones where the only infobox image is a generic map with a location dot.
The only new problem I saw is that the caption for the Orkney image is wrong -- it shows the flag, but gives the caption for the coat of arms.
There are still the other two issues noted above, and in particular quite a few articles aren't linking besides those I noticed earlier -- I can do you a list if that would help? Cheers, Espresso Addict (talk) 14:01, 13 July 2018 (UTC)
For Orkeny, the problem is probably the order of paramneters – the module assumes that each caption parameter is for the immediately preceding image parameter. This edit [1] should fix it. I haven't yet looked at the code for the other issues, but the TOC is presumably from another template that needs to be removed by the code; and the article title link can probably be fixed for most cases by checking the non-disambiguate version of the title, i.e removing parentheses and everything after and including the final comma. - Evad37 [talk] 02:46, 14 July 2018 (UTC)
Fixed the TOC issue - Evad37 [talk] 03:16, 16 July 2018 (UTC)
@Espresso Addict: Fixed the bold text linking too (for most cases, probably) . - Evad37 [talk] 03:50, 16 July 2018 (UTC)

Placement of image in excerpt

It looks like the images are placed where they are found, so if the firat image is below the lead in the original that is where it will display in the excerpt. I suggest that stacking them on the right starting at the top of the box is more generally useful. Having a moderately long excerpt with an image below it creates a lot of non-functional whitespace. Cheers, · · · Peter (Southwood) (talk): 08:18, 13 July 2018 (UTC)

Noting that Portal:Heavy metal has an example in the intro section (per Wikipedia talk:WikiProject Portals/Design#Portal:Heavy metal) - Evad37 [talk] 02:45, 16 July 2018 (UTC)
An interesting idea. We'd be overriding layout choices made in the article, but maybe they don't apply to the excerpt. Perhaps we should stack images in the default way, respecting the module's fileargs=left flag or any other settings. (Arabic Wikipedia uses a copy of this module and prefers images on the left.) Certes (talk) 08:42, 16 July 2018 (UTC)
Heavy metal has exactly the effect we should avoid. It would be nice to be able to choose which side the stack displays, but the images should generally not take up a lot more vertical space than the text, or we end up with big whitespace. Obviously this depends on page width, but for a wide screen it would be preferable if there is not an extra image below the bottom of the text. Alternating between left and right looks fine on a wide screen, but really bad when the text sandwiched between images gets narrow. Adjusting the display of images to respond to screen width would be nice, but is it feasible? Limiting column width might also be feasible. It may be good for redability - the eye finds the start of the next line more easily if the number of characters in the line is smaller. Some of this may be beyond the scope of templates, as the screen characteristics would have to be available.
I don't think that overriding display choices made in the article is an issue. We already do that by not displaying infoboxes. The article may continue for hundreds of lines below the lead. Our excerpts may not even include the whole lead. Stacked images is the easy way to give an unsurprising effect and the highest probability of consistently acceptable display. We can't expect it to be infallible. · · · Peter (Southwood) (talk): 16:22, 16 July 2018 (UTC)
@Pbsouthwood:  Done That sounds very reasonable. I've updated Module:Excerpt to output images first. The change shouldn't affect left or right positioning. Certes (talk) 17:13, 16 July 2018 (UTC)

Free image not appearing

See Template:Transclude_lead_excerpt/testcases#Germany. The problem seems to be that the file has a local description page File:Flag of Germany.svg which includes the words "non-free", but only as part of the phrase in the template {{insignia}} (which is unrelated to copyright status). - Evad37 [talk] 12:47, 17 July 2018 (UTC)

Enhancements

@Broter, Épine, Pbsouthwood, The Transhumanist, and Waggers:

This list of possible near-future changes was inspired by talk above and at WT:WikiProject Portals. Comments are welcome. Certes (talk) 14:17, 16 May 2018 (UTC)

Internationalisation

As the module is being used on non-English Wikipedias, it might benefit from splitting into two pages: one for core functionality; one for language dependent text. One option is to have an optional submodule which simply defines a Lua table to override the English language defaults in the code. For example, Arabic Wikipedia can have something like langtext = { more = "اقرأ المزيد...", file = {"ملف" ,"صورة", "[Ff]ile", "[Ii]mage"} }. Where the module currently uses "Read more...", it can instead use (langtext.more or "Read more..."). Where it searches for File:Foo or Image:Foo, it can instead search for any of the given namespace patterns. There are other strings to include. The submodule will be optional (if it's missing, you get English) and should only need to be edited when a new string appears. This looks like the largest enhancement and will take quite a bit of work, so let's make sure the design is right first! Certes (talk) 14:17, 16 May 2018 (UTC)

Longer text

When transcluding an excerpt from an article with a short lead, you get a short excerpt. The preferred way to fix this is to edit the article to lengthen the lead, perhaps by moving text from a later section, as this will normally improve the article itself. No enhancements are planned in this area but this may change. Certes (talk) 14:17, 16 May 2018 (UTC)

I agree that this is the correct strategy.· · · Peter (Southwood) (talk): 13:42, 17 July 2018 (UTC)

Excluding files other than images

files= can transclude files other than images, such as audio files. There seems to be consensus for ignoring non-image files, so files=1 will transclude the first image, even if preceded by a non-image file. This is potentially a breaking change, e.g. someone may have coded files=2 to skip a leading audio file. Certes (talk) 14:17, 16 May 2018 (UTC)

 Done: only files with image extensions now appear. Certes (talk) 15:43, 21 May 2018 (UTC)

Later images

There is some demand for transcluding images which appear in later sections of the article rather than the lead. This could be achieved without breakage by a new optional argument such as sectionfiles=true. It may be resource hungry but should not impact existing usage without the new flag. Certes (talk) 14:17, 16 May 2018 (UTC)

File:File:Foo.jpg
All look like good ideas. There are sometimes problems with images in infoboxes. Getting them to display would be great, but there is also the problem of occasional blank image display with File:File:Foo.jpg in the thumbnail frame (as shown at right). Cheers, · · · Peter (Southwood) (talk): 14:37, 16 May 2018 (UTC)
@Pbsouthwood: File:File:Foo.jpg is a separate bug, which I just fixed. If a portal still has that problem after purging, please give me a link. Certes (talk) 16:31, 16 May 2018 (UTC)

Non-random selection

Allow {{Transclude random excerpt}} or a new template to pick from a list in a non-random way, e.g. based on the week number or day of the year, to provide a slowly and predictably rotating carousel of extracts. Certes (talk) 22:41, 18 May 2018 (UTC)

 Done — see {{Transclude selected excerpt}}. Certes (talk) 15:39, 20 May 2018 (UTC)

Most articles have a beginning like A pig is..., with the article title or a synonym in bold. We could wikilink this to the article itself. It's not quite as easy as it looks; see for example Elton John. Certes (talk) 18:06, 20 May 2018 (UTC)

 Done Certes (talk) 21:38, 20 May 2018 (UTC)

Image from nowhere?

In Portal:Royal Navy the lead excerpt is displaying File:Flag of Scotland (traditional).svg which is not visible in the lead, infobox or any of the following sections. The only place it exists is in footnote 5, which is linked from the infobox under "insignia", so I assume it is getting it from there. It is not even the first image in the infobox, so I can't guess why it is getting it and not one of the others. Maybe some weird infobox coding. Cheers, · · · Peter (Southwood) (talk): 14:33, 17 July 2018 (UTC)

@Pbsouthwood: There were actually two problems: the first image wasn't being detected, and the order they were being transcluded in was getting mucked up. Both issues have been  fixed now – File:Naval Ensign of the United Kingdom.svg is now detected by the module, and the order is back to being the same as the order they appear in the wikitext. - Evad37 [talk] 07:54, 19 July 2018 (UTC)

Bug with {{Transclude lead excerpt}}: Lua error: bad argument #2 to 'find' (pattern is longer than 10000 bytes).

@Evad37 and Certes: On Portal:Napoleonic Wars the lead excerpt is not transcluded, but instead, this message is shown:

Lua error: bad argument #2 to 'find' (pattern is longer than 10000 bytes).

Trace:

1. [C]: in function "v"
2. mw.ustring.lua:84: in function "find"
3. Module:Excerpt:97: in function "argimage"
4. Module:Excerpt:314: in function "parse"
5. Module:Excerpt:438: in function "main"
6. Module:Excerpt:515: ?
7. (tail call): ?
8. mw.lua:511: ?
9. [C]: ?

(Article attempted to be shown: Napoleonic Wars). — Preceding unsigned comment added by Dreamy Jazz (talkcontribs) 20:25, 18 July 2018 (UTC)

@Evad37, Certes, and Dreamy Jazz: I changed it using a very ugly hack. basically, we need a way to cut the size of the input before the string processing starts, or, a way to pass only the lead section to the module using LST. Frietjes (talk) 22:29, 18 July 2018 (UTC)
same problem with Portal:Montreal and Portal:Philippines. Frietjes (talk) 22:39, 18 July 2018 (UTC)
I've put a suggested fix in Module:Excerpt/sandbox. I haven't tested it properly as that would require reverting the portal change. I won't be online much for the next week but please copy to Module:Excerpt if someone else can look after it. Certes (talk) 22:54, 18 July 2018 (UTC)
 Done, looks good and it worked for Napoleonic Wars on the Template:Transclude lead excerpt/testcases page - Evad37 [talk] 06:37, 19 July 2018 (UTC)

thank you. FYI for The Transhumanist and others, you can't use {{PAGENAME}} when the page includes an apostrophe or ampersand. this could be addressed in the module (e.g., by changing the &#38; to & within the module), or just conclude that it's "garbage in" = "garbage out" and address it at the module call level as I have done here and here. Frietjes (talk) 13:45, 19 July 2018 (UTC)

@Frietjes: Thank you for the heads up.    — The Transhumanist   23:18, 19 July 2018 (UTC)

Issue

Hey! {{Transclude lead excerpt}} seems to not ignore {{Efn}} (and possibly its sub-templates as well) in the ckb wiki (check here) I don’t know if this problem is present in the enwiki though.--▸ ‎épine talk 13:11, 6 August 2018 (UTC)

Efn is first in the list of unwanted templates in Module:Excerpt on enwiki. I added it on 25 April. Perhaps ckb is using an older version. Certes (talk) 13:22, 6 August 2018 (UTC)
@Certes: nope, we use a translated version, but I fixed it. Thanks.--▸ ‎épine talk 13:24, 6 August 2018 (UTC)

{{Unreliable source?}} not being removed

The template {{Unreliable source?}} is used to mark a reference as potentially unreliable. This shouldn't be included when the reference it is referring to is not included.

See Portal:British Columbia and British Columbia. Dreamy Jazz 🎷 talk to me | my contributions 20:12, 26 August 2018 (UTC)

 Done; thanks for the report. Certes (talk) 21:14, 26 August 2018 (UTC)

footnote not being removed

Seems {{efn-lr}} isn't being removed – see Template:Transclude_lead_excerpt/testcases#Matcha. I thought this edit would have fixed it, but apparently not. Any ideas Certes? - Evad37 [talk] 04:20, 2 September 2018 (UTC)

@Evad37: The {{efn-lr}} is nested within {{cite-web}}. I'm busy today but will look at it tonight unless you manage to fix it first. Certes (talk) 07:56, 2 September 2018 (UTC)
efn-lr was actually buried in {{nihongo}}, which we're correctly leaving in. I've changed the code to recursively remove unwanted templates which are nested within wanted ones. I've also added templates beginning with "cite-" (hyphenated) to the blacklist. The one visible side-effect is that fewer images appear when the testcases page transcludes from Royal Navy: the excerpt no longer displays historical flags from the footnote. Certes (talk) 21:00, 2 September 2018 (UTC)

Bogus file options lint errors

Template:Transclude list item excerpt causes Bogus file options lint errors in probably about 80 articles in the Portal namespace. For example, in Portal:Milan is the code

{{Transclude list item excerpt | 1=Outline of {{PAGENAME}} | section= Environment of {{PAGENAME}} | paragraphs=1-2 | files=1 | fileargs= | more= | errors= }}

which reduces to

{{Transclude list item excerpt | 1=Outline of Milan | section= Environment of Milan | paragraphs=1-2 | files=1 | fileargs= | more= | errors= }}

which causes a Bogus file options lint error, viz: "A typical foggy day in central Milan." The bogus file option text comes from Milan#Climate, which begins,

[[File:Milan foggy panorama with Velasca Tower.jpg|thumbnail|A typical foggy day in central Milan.]]

So, Template:Transclude list item excerpt is sucking up valid Caption parameters from articles and stuffing them into file markup, but followed by a pipe, or in some way not in the final position, so the Caption parameter becomes bogus. —Anomalocaris (talk) 18:50, 27 August 2018 (UTC)

The presence of an empty | fileargs= causes Module:Excerpt to add a pipe at the end of the image code: [[File:Milan foggy panorama with Velasca Tower.jpg|thumbnail|A typical foggy day in central Milan.|]] . Either the module should be modified or the calls should omit the parameter when it's empty. Modifying the module is best but I'm not a Lua coder. PrimeHunter (talk) 19:48, 27 August 2018 (UTC)
Yeah, this a Module:Excerpt issue. Though Module:Excerpt slideshow does already trim whitespace and remove empty parameters (via the function cleanupArgs) before passing any through to Module:Excerpt, so what PrimeHunter describes might not be the only issue - Evad37 [talk] 01:10, 28 August 2018 (UTC)
I don't do Lua, but I have found similar issues in templates. One way to fix it is to test for the presence of a variable, and then insert the pipe for that variable's value only if the variable is present. Otherwise, omit the pipe. Here's an example fix. Maybe Trappist the monk could help us with the Lua. – Jonesey95 (talk) 06:31, 28 August 2018 (UTC)
 Fixed (at least the empty fileargs issue) with [2]. Lua is a bit funny in that empty strings are truthy instead of falsey, and that (unlike regular temlplate coding) parameters don't have whitespace trimmed or present-but-empty parameters ignored. You have to do it yourself, either at the start with something like the cleanupArgs function I use in modules I create, or else when needed (which isn't always obvious, like in this case) - Evad37 [talk] 07:08, 28 August 2018 (UTC)
Thank you, Evad37. That appears to have worked. The number of Portal pages in the "Bogus file options" "category" (still not an actual category, but we can hope for it someday) has been greatly reduced. The ones that are left appear to be actual errors, as far as I can tell (although Portal pages are ... strange). – Jonesey95 (talk) 19:56, 28 August 2018 (UTC)
Thank you, Evad37!

The remaining Bogus file options in the Portal namespace are all connected to Template:Flex columns. For example, Portal:Oklahoma City has a bogus file option

The first [[Brookville Liberty Modern Streetcar|Brookville Liberty]] streetcar for Oklahoma City, a few weeks after its arrival. It wears one of three different paint schemes planned.

which comes in from Oklahoma City Streetcar, which includes

{{Infobox rail line
...
| caption = The first [[Brookville Liberty Modern Streetcar|Brookville Liberty]] streetcar for Oklahoma City, a few weeks after its arrival. It wears one of three different paint schemes planned.<ref name="deliveries"/>
...}}

There are 14 affected items in the Portal namespace. —Anomalocaris (talk) 23:50, 2 September 2018 (UTC)

Entirely unrelated to flex columns, which just wraps whatever content it is given in divs with flexbox styling via TemplateStyles. Putting {{Transclude lead excerpt|Oklahoma City Streetcar|files=1}} into Special:ExpandTemplates shows that the file syntax this modules is generating from the infobox parameters is
[[File:OKC Streetcar (38923640550).jpg|The first [[Brookville Liberty Modern Streetcar|Brookville Liberty]] streetcar for Oklahoma City, a few weeks after its arrival. It wears one of three different paint schemes planned.|alt=on|allk=on|first=imp}}|thumb]]
which makes me think that it's somehow mistaking on|allk=on|first=imp}} (from the |gauge= parameter further down the infobox) for the alt text, which has in fact been left blank. - Evad37 [talk] 01:43, 3 September 2018 (UTC)
Should be fixed with this edit - Evad37 [talk] 08:33, 3 September 2018 (UTC)

{{self-published source}} not being removed when transcluded

The template {{self-published source}} is not removed when transcluding an article lead. Seeing as the template being there refers to a reference not seen in the lead, it could confuse readers and so shouldn't be there. Thanks for continual improvements. Dreamy Jazz 🎷 talk to me | my contributions 09:09, 11 September 2018 (UTC)

@Dreamy Jazz: I've removed the tag. Thanks for the report. I'm guessing that this affected Portal:United States Territories but I can't see any improvement: perhaps it messed up a randomly selected article which isn't appearing today. Certes (talk) 10:51, 13 September 2018 (UTC)
@Certes: The article in question is Kingman Reef. However, it does not seem to be removed. Have purged the page etc., but it still remains in the transclusion. Dreamy Jazz 🎷 talk to me | my contributions 10:59, 13 September 2018 (UTC)
@Evad37 and Dreamy Jazz: If it's Portal:United States Territories then this is using {{Transclude excerpts as random slideshow}} which uses Module:Excerpt slideshow. That article is randomly not appearing on the portal at the moment but I've reproduced it in my sandbox. Evad: does that template do its own template removal here, or are you calling a buggy function in Module:Excerpt? Certes (talk) 11:18, 13 September 2018 (UTC)
@Certes: Both. First there's the stuff this module does, from Module:Excerpt slideshow calling Module:Excerpt's main function to get the excerpt. Later, Module:Excerpt slideshow does further removal of block-level templates and tables, which could otherwise mess up the gallery syntax. In this case the problem is definitely with Module:Excerpt, since it can be replicated with {{Transclude lead excerpt | paragraphs=1-3 | files=1 | more= | Kingman Reef }} - Evad37 [talk] 12:55, 13 September 2018 (UTC)
Fixed. I forgot to escape the hyphen (should be self%- not self-). Certes (talk) 13:04, 13 September 2018 (UTC)

Vogelsberg

@Evad37: As you've spotted, this template breaks the Vogelsberg media link. The bug is in the bit that turns the bold title into a wikilink (search for "replace the bold title"). Commenting out that block of code removes the problem (but of course breaks other articles). I'm busy fixing a different bug at the moment but we should think about how we can detect cases like this and refrain from making an unwanted link. Certes (talk) 11:06, 13 September 2018 (UTC)

What should appear in the extract for Vogelsberg? The article itself is unusual in that the bold title in the lead isn't unlinked text but a wikilink to a useful destination. Should the extract look the same, with no link to the article? Should the link lead to the article, with no way of playing the sound? Perhaps the sound symbol should link to the sound, and the text to the article, but that's not how {{audio}} normally behaves and I'm reluctant to code for one very special case. Certes (talk) 13:41, 13 September 2018 (UTC)

{{Failed verification}} shouldn't transcluded

@Evad37 and Certes: The template {{Failed verification}} is transcluded when it shouldn't be, as it refers to the reference it is next to.

See Portal:Classical music lead and Classical Music. Thanks, Dreamy Jazz 🎷 talk to me | my contributions 20:32, 15 September 2018 (UTC)

 Fixed, thanks. Certes (talk) 20:45, 15 September 2018 (UTC)

{{when}} is not being removed

@Evad37 and Certes: The template {{when}} is not being removed when the page Issam Eid is transcluded. The template is an article improvement tag, which probably shouldn't be transcluded. See Special:Diff/860705299. Thanks, Dreamy Jazz 🎷 talk to me | my contributions 14:16, 22 September 2018 (UTC)

 Fixed, thanks for the useful testing sandbox. Certes (talk) 23:22, 22 September 2018 (UTC)