Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// 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: a3ff43d23b0f452a

Jump to content

Module talk:Excerpt

Page contents not supported in other languages.
Add topic
From Wikipedia, the free encyclopedia
Latest comment: 4 days ago by Aidan9382 in topic Template Excerpt sentence

Bolded, unlinked word in source turns into linked, unbolded term

[edit]

Something odd going on here, excerpting a paragraph from Template:Uw-coi:

{{Excerpt |Template:Uw-coi |only=paragraphs|lists=1 |paragraphs=2 |hat=no |inline=yes}}
In addition, you are required by the Wikimedia Foundation's terms of use to disclose your employer, client, and affiliation for any contribution which forms all or part of work for which you receive compensation. See Wikipedia:Paid-contribution disclosure.

The bolded, unlinked word '''required''' in the source, turns into the unbolded word linked to the template source. Mathglot (talk) 17:32, 30 May 2026 (UTC)Reply

Here's another clue, perhaps. These two cases do the same thing in adding linkage to a bolded term, but only to the first item in a list that has bolded text in the source, not to the other ones:
Note that in the both examples, the first bullet has linkage added which was not there in the original. The second example shows the original bolding, and retains the anomalous, added link, but only in bullet #1. Mathglot (talk) 18:09, 30 May 2026 (UTC)Reply
The Excerpt template tries to link to the page being excerpted, as this is normally useful. It relies on our convention that, when an article first mentions its own subject, it does not link to itself but uses bold text. Excerpt tries to replace the first such mention by a wikilink. In {{Excerpt|Meatloaf}},
  • Meatloaf is a dish... gets replaced by Meatloaf is a dish...
The link need not be the first bold text. In {{Excerpt|Meat Loaf}},
  • Michael Lee Aday... known professionally as Meat Loaf... gets replaced by Michael Lee Aday... known professionally as Meat Loaf...
When the title does not appear in bold, but other early text does, Excerpt guesses that the first bold text is a synonym for the title. In {{Excerpt|Alisha (singer)}},
  • Alisha Ann Itkin... is an American freestyle and dance-pop singer... gets replaced by Alisha Ann Itkin... is an American freestyle and dance-pop singer... (with a piped link in case there was no redirect)
Excerpt wasn't designed for inserting a template (usually we just transclude) and the guess seems inappropriate here. Certes (talk) 18:31, 30 May 2026 (UTC)Reply
Okay, that explanation makes sense. I can undo the linkage with a {{replace}}, so no worries. I just wondered if there was something unintended going on here, but if not, then we're good. Thanks, Mathglot (talk) 18:37, 30 May 2026 (UTC)Reply
Thinking further: I wonder if linking the first bold item that matches the title could be kept for main and draft space, suppressed for the others. Haven't thought this through yet, probably have to think further one by one, to see if it makes sense for every namespace but those. Just an idea. Mathglot (talk) 18:42, 30 May 2026 (UTC)Reply
I think it makes sense. Generally, we only use the A title is a... opening in those namespaces. Maybe include Wikipedia: namespace e.g. Protection restricts the modification of pages... in WP:PROTECT, but that feature might never get used or might do more harm than good. Certes (talk) 19:43, 30 May 2026 (UTC)Reply
If we decide to go with it, in theory it could be a breaking change for any existing use of Excerpt that excerpts other namespaces that have bolding. We could have a param |boldtitle=yes to override. (The longish param name is on analogy with MOS:BOLDTITLE, but we could find a shorter alternative.)
Another thing that occurs to me is that outside of {{excerpt}}, when we bold a title, it is almost always in the first paragraph (usually the first sentence) if bolded at all, and invariably in paragraph context. I can't think of a case where it might be in a table, link, list item, reference, or anything else. So we could add some robustness with something like:
if paragraph-context and paragraph-number = 1 and (arg-boldtitle missing or not=yes) then bold first occurrence
As far as the extent of possibly breaking changes, in template space, there are 78 templates that directly use Excerpt. Wikipedia project space=311; Draft: 19; Help: 1; Module: 0; Event: 2; Portal: 47; Category: 12. But I suspect very few of these would involve a bolded term in the source matching the target page title. We could spot-check a subset, to get a feeling for it. Count me in if you want to assign me a couple dozen to examine. Mathglot (talk) 20:34, 30 May 2026 (UTC)Reply
I don't think we're losing much (if anything) by restricting the linking to excerpts from mainspace. By default, Excerpt prepends This section is an excerpt from [link to page], so there's a link anyway. We should check the namespace of the donor page rather than the recipient. For example, a portal showing an excerpt from a mainspace article (which was this template's original purpose) should still add the link. We don't currently excerpt from Draft:, and probably never should. Certes (talk) 22:21, 30 May 2026 (UTC)Reply

Edit request 2 June 2026

[edit]

Description of suggested change: The config doesn't exclude the template {{Italic disambiguation}}, which can cause errors or unintended changes to the articles this template is used in. (Example: ) It is likely also reasonable to exclude {{Italic dab}} as it redirects to {{Italic disambiguation}}. This is required because {{Italic disambiguation}} calls {{#invoke:Italic title|dabonly}} directly instead of using the template {{Italic title}}.

Diff:

'[Dd]isplay ?title', 'DISPLAYTITLE', '[Ii]talic title',
+
'[Dd]isplay ?title', 'DISPLAYTITLE', '[Ii]talic title', '[Ii]talic disambiguation', '[Ii]talic dab',

Not Invisible (talk) 13:48, 2 June 2026 (UTC)Reply

 Done * Pppery * in solidarity 21:49, 2 June 2026 (UTC)Reply

Articles which end in full stops

[edit]

On List of English-language placeholder names for people, there is an excerpt from the article G.I. The MOS makes it clear that in this situation, a second full stop should not be added afterwards (see MOS:!). Could this be added to the module? I.e. if the article the excerpt is from ends with punctuation such as "." or "?", the text is changed from "This section is an excerpt from PAGENAME!." to "This section is an excerpt from PAGENAME!" (in solidarity), JacobTheRox(talk|contributions) 18:48, 21 July 2026 (UTC)Reply

Opposed. The styling of the name with page title punctuation inside, means that dropping the sentence final period would mean a sentence with no terminal punctuation. Mathglot (talk) 04:00, 22 July 2026 (UTC)Reply
I think the OP is proposing that the module check for terminal punctuation and omit the period when it is present, as recommended at MOS:CONSECUTIVE. – Jonesey95 (talk) 15:19, 22 July 2026 (UTC)Reply
I mean checking if it already ends with punctuation. For example
{{excerpt|British Rail}} "This section is an excerpt from British Rail."
{{excerpt|G.I.}} "This section is an excerpt from G.I." (i.e. not "...from G.I..", with the double full stop)
I don't know how the module works but I think the code in wikipedia templates would be:
''This section is an excerpt from {{{1}}}{{#switch: {{str index|{{{1|}}}|-1}} |.|,|!|?|:|; = |#default=.}}''
Thus it is only if the article ends in these punctuation that the ending full stop is removed. (in solidarity), JacobTheRox(talk|contributions) 15:26, 22 July 2026 (UTC)Reply

Broken parameter

[edit]

The hat= parameter doesn't work. I'm currently seeking to merge a bunch of year articles to decades that use transcluded excerpts (WP:DECMER), and this makes my work very inconvenient. I tried several possible values, including 0, no, and false. –LaundryPizza03 (d) 00:25, 7 August 2026 (UTC)Reply

Can you share an example? I'm testing excerpting a random article with |hat=no and it seems to be working just fine. Aidan9382 (talk) 06:15, 7 August 2026 (UTC)Reply

False positives

[edit]

Hi! Someone at the Spanish Wikipedia just reported the following bug: if a template is excluded by name via /config, then if another template contains that template name within its name, it will be excluded too. This can lead to unexpected and undesired behavior. For example, in the Spanish Wikipedia, "PA" is excluded, but that also unexpectedly excludes the template "PAR". This can be fixed by changing the ambiguous "PA" for a more precise "^PA$", but the bug is more general than that. Any pattern in /config could be matching more templates than intended. The solutions I can think of are:

  1. Ignore this bug and just adjust the patterns as the need arises
  2. Rewrite all the patterns to include ^ and $
  3. Add ^ and $ to mw.ustring.match here. However, I tried (diff) and most testcases fail, for some reason I couldn't figure out yet.

Thoughts? Sophivorus (talk) 12:01, 25 August 2026 (UTC)Reply

Good analysis, and I'm not sure which solution is best. For 3., does the initial have a different case (are you trying to match Foo using ^foo$)? It looks as if most /config entries are of the form [Ff]oo, which should match either (though they're never going to == lcvalue or == ucvalue). Certes (talk) 12:17, 25 August 2026 (UTC)Reply
Option three is risky, as some of the matches in the config are intentionally partial (for example the [Ee]conomy of sidebar regex), and would need adjusting to have a trailing .* to work in those cases. Aidan9382 (talk) 12:23, 25 August 2026 (UTC)Reply

Template Excerpt sentence

[edit]

I am playing around with a template {{Excerpt sentence}} to grab a given sentence from a paragraph. It's still in its initial stages (rated alpha–limited use), and may have breaking changes going forward, but I thought I'd mention it here in case anyone is interested. It's working fine for my purposes at Draft:List of ancient civilizations doing what it's supposed to, but it has weaknesses and is not yet a mature template, and I cannot recommend it for general use at this time. Comments welcome at Template talk:Excerpt sentence or here. Mathglot (talk) 08:47, 18 September 2026 (UTC)Reply

The idea is interesting, but my main worry is how stable it would actually be. It's already a bit shaky to excerpt paragraphs by number with excerpt due to major rewrites shuffling stuff around, and specific sentences feels like it might be pushing that a bit too much, though it's hard to actually test that. Aidan9382 (talk) 10:38, 19 September 2026 (UTC)Reply