Note the following:
This is with parser functions (refer to https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions for background info):
- {{formatnum:-8}} and {{formatnum:−8}} both output −8 (using minus sign − U+2212).
- {{#expr 1-9}} and {{#expr 1−9}} both output -8 (using hyphen-minus symbol - U+002D)
This is inconsistent.
Note that {{formatnum}} was set up like this after considerations at T10327: Language::formatNum() should prefix negative values with − (minus sign U+2212).
What should have happened instead?:
#expr should also output negative numbers using minus sign, for consistency with T10327: Language::formatNum() should prefix negative values with − (minus sign U+2212).
#expr and formatnum do both interpret − as a minus sign, so if they are somehow nested, this shouldn't break anything.
Notes
File to be changed:
https://gerrit.wikimedia.org/g/mediawiki/extensions/ParserFunctions/+/master/includes/ExprParser.php
The patch that fixed T10327: Language::formatNum() should prefix negative values with − (minus sign U+2212) by @cscott is at https://gerrit.wikimedia.org/r/c/mediawiki/core/+/635546/14
Suggests we need to add:
# T405240: Make formatted numbers prettier by using a # proper Unicode 'minus' character. $number = strtr( $number, [ '-' => "\u{2212}" ] );
AND also update unit tests to check this is all working properly. These are located in tests/phpunit/unit/ExpressionTest.php:
(URL https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/ParserFunctions/+/master/tests/phpunit/unit/ExpressionTest.php)