On Tue, Aug 24, 2010 at 10:59:04AM +0200, Petr Kadlec wrote:
On 24 August 2010 10:43, lampak llampak@gmail.com wrote:
How can I generate in JavaScript such a link which would be identical to the one generated by MediaWiki? Has somebody written such a function? Or at least, do you know where it is done in MediaWiki php code?
See Parser.php, function guessSectionNameFromWikiText; most of the work is done in Sanitizer::escapeId.
The problem there is that the output of guessSectionNameFromWikiText depends on the configuration of the particular wiki. $wgHtml5 and $wgExperimentalHtmlIds are used, and maybe others.
Sometimes it may be easiest to just ask the API.