Help talk:HTML in wikitext

From Meta, a Wikimedia project coordination wiki

How to embed link to file:// resource[edit]

We're using an internal deployment of MediaWiki and we've had many occasions where we'd like to provide a link to an internal file server - either a single, large file (that's too big and changes too often to simply upload to the MediaWiki server), or a folder with multiple documents. Migrating this content to SharePoint may happen in the longer term, but for the forseeable future we need to support the existing repositories.

We've tried to embed links to these shares using a number of different format variations, none of which work the way file:// links work in native HTML pages:

Each time, these either create *no* link or they create a link that gets pre-pended with a URL stub referring to the current server: http://wiki.company.com/?title=

This ends generating a query for a non-existent page on the Wiki server (i.e. the browser tries to retrieve a page like http://wiki.company.com/?title=File://server/proj/_A_file://_type_link&action=edit, rather than instantiating the protocol handler to call up a Windows Explorer instance.

Q: Does anyone know the "secret" way to make a working link to a file:// resource?--Poseidon 01:18, 18 March 2008 (UTC)[reply]

  • No definite answer, only an idea that worked with our local wiki software: Would defining a special interwiki link like "localfile" which expands to "file://server/" help in MediaWiki as well? Vigilius 22:23, 14 April 2008 (UTC)[reply]
  • My solution for IE and Firefox was to add three additional / after file://, leading to something like [file://///server/proj]
    Additionally, as Firefox blocks local file links, I had to add a file users.js to my Firefox Profiles .default directory with the following content:
   user_pref("capability.policy.policynames", "localfilelinks");
   user_pref("capability.policy.localfilelinks.sites", "http://intranet");
   user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
Werner--80.254.185.253 09:06, 4 March 2010 (UTC)[reply]
MediaWiki blocks unknown file protocols by default. You'll need to define it in $wgUrlProtocols. For more information, check out MediaWiki's page on $wgUrlProtocols. Jkmartindale (talk) 00:55, 24 October 2016 (UTC)[reply]

removeHTMLtags function in wrong place[edit]

In 1.4rc1, the removeHTMLtags function is located in Parser.php, not OutputPage.php... This should be fixed in the documentation on this page.

how can i allow the <a> and <img> tags??

In 1.5 this function has been moved to Sanitizer.php. It would be nice to have the list of acceptable tags be configurable from LocalSettings.php. I am working on a site where I can trust some of the other tags to be (relatively) safe and very useful. --Cuthbert 07:25, 14 November 2005 (UTC)[reply]

Bad practice[edit]

This page encourages bad practice (e.g. setting colour without setting background colour); and says nothing about accessibility in general. 80.86.36.97 12:23, 23 November 2005 (UTC)[reply]

That's something that's typically covered by your skin anyway. Why would you change text color in a standard article? James Kevin Martindale (talk) 00:56, 24 October 2016 (UTC)[reply]

Means to enable <a> tags[edit]

We have a need to enable <a> to create tags like:

<a href='LaunchMenu.exe MENUID, 145’ > text to link </a>

These enable links to interact with an application.

mcl 10:36, 20 September 2006 (UTC)[reply]

Updated 2011-06-08 by an anonymous user . . . Also - the ability to link to lower sections in a large wiki page is sorely missed.

This is pretty easy. Just make an internal link to the target. This would look something like [[#Heading name]] unless you have multiple headings with the same name, in which case you'll probably have to dig into the source and look for the id attribute of the header you want to link. James Kevin Martindale (talk) 01:00, 24 October 2016 (UTC)[reply]

<pre> stops wikitext parsing?[edit]

<pre><b>[[Help:HTML in wikitext]]</b></pre> produces

<b>[[Help:HTML in wikitext]]</b>.

Surely that's not correct? The wikicode should be parsed unless <nowiki> is added. Why this "feature"? Adding a space to the beginning of every line in a block of code can be a significant nuisance, but if the code contains any markup at all (such as if you want to highlight a portion of it), <pre> is unusable. Simetrical 03:08, 1 February 2006 (UTC)[reply]

It's better with '''...''' and to link Main Page
simply without <pre>...</pre>, better use a space at the beginning of each line...
Hégésippe | ±Θ± 03:30, 1 February 2006 (UTC)[reply]
I know that works, but it can be a nuisance when you're talking a big block of code. Simetrical 03:32, 1 February 2006 (UTC)[reply]
You can create a bug entry in Bugzilla... :o) Hégésippe | ±Θ± 03:33, 1 February 2006 (UTC)[reply]

Need for a manual anchor[edit]

Hi,

I just came up with a case where I must use anchor (<a>), in order for the text to behave correctly. This is not about presentation, this is about structure.

The page itself is is in French (here), but I'll give an English example

  1. This is on Wiktionary, which has two practices, which are technically exclusive without resorting to true HTML.
    • any instance of the defined word is in bold
    • a proverb/maxim/saying… will be hyperlinked to the page related to it
  2. Now here's the problem.
    • The word is theme (translating from your native language to a foreign tongue)
    • The expression is, roughly translated to be skillful in theme. Theme being considered has difficult and delicate, to be skillful in such an exercise means to be very good.
  3. And now for the coding
    • Idea — italic -- anchor -- expression -- bold -- word -- /bold -- /anchor -- italic
    • tags —<q><a>to be skillful in <strong>theme</strong></a>/<q>
    • expected result — to be skillful in theme

Problem is it is not possible to insert bold in a link. But here, it is required by the formatting guideline. For now on, I just made an exception and left the word without particular weighting.

Any idea on how to deal with this?
Reply to David Latapie 15:08, 26 February 2006 (UTC)[reply]

A piped link works fine:
Patrick 08:27, 11 March 2006 (UTC)[reply]

<rss></rss> documentation?[edit]

I found <rss> </rss> used for newsfeed transclusion here: http://www.moreperfect.org/wiki/index.php?title=NewsFeeds

Where is this documented?

--jwalling 22:51, 13 July 2006 (UTC)[reply]

Avoid closing tags in templates[edit]

In MW 1.7.1, is there a way to avoid automatically closing some tags, or even all tags on some pages, when a page is included? I'm trying to do something similar to w:Portal:Box-header and w:Portal:Box-footer, where the header template opens a div and the footer template closes it, but Sanitizer.php keeps closing all the open tags in the header and converting the "unopened" tags in the footer to HTML entities, even when the templates are transcluded, not accessed directly. Is there a way to fix this in MW 1.7.1, or do I need to upgrade to 1.8? It, obviously, does not happen on the WikiMedia sites running 1.8. --Jimmy 07:35, 25 July 2006 (UTC)[reply]

I have the same problem for exactly the same use on my own wiki using Mediawiki 1.8.2 and i'm not able to find an answer anywhere (didn't try irc for now) -- Lenaic 08:06, 29 November 2006 (UTC)[reply]
I've finally found the answer through wikipedia en (i think, already forgot the source)
Anyway, here is the link to the relevant ressource -- Lenaic 08:31, 29 November 2006 (UTC)[reply]

span[edit]

why isn't span listed as permitted HTML?? JanCK 19:29, 15 August 2006 (UTC)[reply]

in current version it is Vigilius 22:25, 14 April 2008 (UTC)[reply]

tr and td tags not rendering[edit]

i am running a non-modified 1.7.1 installation of mediawiki, and i'm using #if in a template for a table. i've run into a problem where the <tr> and <td> tags get misinterpreted in a table

for example, if i put this in the template

{{#if:{{{birth|}}}|<tr valign="top"><td>'''Birthday:'''</td><td>{{{birth}}}</td></tr>}}

a page loading the template would display this on screen (if birth is given a value of January 1, 2002), instead of rendering a table row and 2 cells as intended

<tr valign="top"><td>Birthdate:</td><td>January 1, 2002</td></tr>

(in bold text)

viewing the html source of the page would reveal that mediawiki rendered this html

& lt;tr valign="top"& gt;& lt;td& gt;<b>Birthdate:</b>& lt;/td& gt;& lt;td& gt;January 1, 2002& lt;/td& gt;& lt;/tr& gt;

(i inserted spaces between & and lt; and gt; so you can see them)

the b tag was rendered, yet tr and td were not. all this was inside a table so i'm confused as to why it's happening. also if i put a linebreak anywhere in the template code, a p tag is rendered. i think the sanitizer might be doing something but i'm not sure. i need a wiki expert to help me out!

if this is not the right place to ask for help, please let me know where i could go. any help is appreciated. my email is my user name at yahoo .com--Hexvoodoo 07:33, 29 September 2006 (UTC)[reply]

See: Talk:ParserFunctions#Solution_to_Tables_Problems for a solution that works, but can break other things, see the next question below. --Dr DBW 23:58, 11 December 2006 (UTC)[reply]

Messed up Coding Due to $wgUseTidy[edit]

Due to some problems with the handling of html coding by ParserFunctions, in particular with tables, I enabled $wgUseTidy. This solved the problem I had with the correct rendering of the tables but and it has broken some of the HTML generated associated with displaying images. It effects every single image that is displayed in the wiki. What appears to be happening is that some of the opening and closing tags of the code is generated as & gt; or & lt;. Which then means that things fail, get funny bits of code appearing on the page etc. The code was working fine before enabling $wgUseTidy.

I have also posted this on MediaWiki at Manual talk:$wgUseTidy The original issue I had is outlined here: Talk:ParserFunctions#Further_HTML_.28Tables.29_Problems along with the solution: Talk:ParserFunctions#Solution_to_Tables_Problems. --Dr DBW 23:58, 11 December 2006 (UTC)[reply]

WikiProject Microformats[edit]

Anyone interested in microformats (or metadata in general) and the deployment of microformats on Wikipedia, might like to be aware of, or even join, WikiProject Microformats. AndyMabbett 09:04, 30 March 2007 (UTC)[reply]

Opening links in a new window[edit]

Since I can't use <a> tags, how can I force links within my wikitext to open in a new window?

- brian

Set $wgAllowExternalImages = true; in LocalSettings.php. James Kevin Martindale (talk) 01:02, 24 October 2016 (UTC)[reply]

<pre> wrapping[edit]

Is it worth mentioning (somewhere) the code for getting <pre> tag to word wrap?

It can be found at w:Template:WrapPre. Thanks very much! Drum guy 20:33, 25 February 2008 (UTC)[reply]

Request for revision of Div/HTML comment sections[edit]

I could follow the article as of 2008-04-15 well up to the "<div> Rules". However, starting with "Example:" it completely fails for me. I do not understand the relationship of the examples to the rules. Even worse, nothing in the section on "HTML comment" makes sense to me. I am fairly new to Wikipedia, but so I may be a good tester. I appreciate if someone who can grasp the intended purpose of these sections can help revise them. Vigilius 22:19, 14 April 2008 (UTC)[reply]

Note the quotations marks. Everything between the first pair is the wikitext, and between the second pair is the result.--Patrick (talk) 22:33, 14 April 2008 (UTC)[reply]

Please give me a list of accepted wikipedia span and div attributes[edit]

Please tell me the sub attributes I can place in span and div. I know things like<span="color:red;">, but not much else.— The preceding unsigned comment was added by Ipatrol (talk)

Request for <colgroup> and <col> tags[edit]

Since mediawiki's support for tables is basic, HTML is needed for more advanced tables. thead and tfoot isn't really needed often, but the colgroup and col tags are essential tools for formatting columns. These should be put into the whitelist or however it works in mediawiki. Miqademus 130.243.247.165 13:32, 23 July 2009 (UTC)[reply]

embed badges, etc.[edit]

Perhaps add examples of best ways to embed complete badges etc. e.g., http://www.facebook.com/badges/ , without installing extensions. Probably via setting several $wg... variables. Jidanni 05:42, 6 January 2012 (UTC)[reply]

Time to support HTML5 inline MathML and SVG?[edit]

Is it time yet to add support for math and svg elements inline? Then they could be pasted directly into the wiki as part of an article instead of posted as a separate file for every single item. It seems like a more organized approach to me.

There's also extensions available for this. James Kevin Martindale (talk) 01:04, 24 October 2016 (UTC)[reply]

This doc in mediawiki.org[edit]

Is there a page equivalent to this in mediawiki.org? I got here following a link at mw:HTML restriction. "What HTML can I use in MediaWiki pages is a frequent question coming also from non/Wikimedia editors.--Qgil (talk) 18:03, 27 February 2014 (UTC)[reply]

<img> tags[edit]

can we use <img> tags to add external images to wikipedia? example: <img src="lorem ipsum" /> Thanks, 108.53.80.246 18:14, 5 September 2015 (UTC)[reply]

No. We don't link external images to Wikipedia. Images must be uploaded (if rights are ok), not just linked from another site. --Stryn (talk) 18:56, 5 September 2015 (UTC)[reply]

Sanitizer.php is a deadlink[edit]

[1] is currently linked in the External Links section. However, it is a dead link. Does anyone know where it was moved to? I don't see a "Sanitizer.php" in includes. --TheSandDoctor Talk 00:37, 10 April 2020 (UTC)[reply]

Fixed * Pppery * it has begun 04:00, 10 April 2020 (UTC)[reply]
Thanks Pppery! --TheSandDoctor Talk 05:18, 10 April 2020 (UTC)[reply]