Jump to content

User:Benhatsor/sandbox

From Wikipedia, the free encyclopedia

Adding titles to web citations that lack them using their URLs

[edit]

Basic example:

[edit]

https://x.com/i/status/1910223261582925987. {{cite web}}: Missing or empty |title= (help)

"Test".

Spaces between keywords:

[edit]

"Test".

URLs in title:

[edit]

"NOELREPORTS 🇪🇺 🇺🇦 on X: 'A Ukrainian air defense soldier from the 47th Separate Mechanized Brigade successfully intercepted a Shahed drone using the Igla MANPADS https://t.co/xEteAezpUx' / X". {{cite web}}: External link in |title= (help)

"NOELREPORTS 🇪🇺 🇺🇦 on X: 'A Ukrainian air defense soldier from the 47th Separate Mechanized Brigade successfully intercepted a Shahed drone using the Igla MANPADS / X".

More extensive URL sanitization:

[edit]

"test test2https://test.com/test test123 http://test2.net https://test3.com test test.com". {{cite web}}: External link in |title= (help)

"test test123 test test.com".

Multiple titles (only the last one takes):

[edit]

"Test". "Test".

"Test2".

"Test2". "Test2".

Different template specifier (cite web) capitalization:

[edit]

"Cite web". "Cite Web". "cite Web". "CITE WEB".


Template parsing notes:

[edit]

1. The characters |, {{, }}, [ and ] (see here) cannot appear inside citation arguments (titles and URLs). The character = can appear.

2. Newlines (\n) and carriage returns (\r) cannot appear anywhere inside a template.

  1. There are also other characters that can't appear inside templates, but we don't handle them as they're very uncommon.

3. We escape the HTML of titles to prevent stuff like <code></code> elements inadvertently appearing.

Other notes:

[edit]

1. Detect 404's and other errors (eg. 403's) when fetching page titles.

2. Exempt PDFs.



Unused:

1. News citations: https://www.nytimes.com/2025/05/12/well/eat/mangoes-health-benefits-recipes.html. {{cite news}}: Missing or empty |title= (help)

2. You can also capitalize the citation URL argument (but not the title argument): "|URL=".