`wikiutils.normalize_pagename()` obsolete?
The "rst_in" converter cleans up links to other pages with the function wikiutils.normalize_pagename().
However, wikiutils.normalize_pagename() drops a leading slash (the syntax for a subitem of the current item) during the process:
"\subitem" becomes "subitem".
Is this intended or a bug?
Is normalizing page names for use in wiki-internal links (wiki.local:) required?
(It seems no other module uses the function.)
The existing unit tests indicate this is the expected behavior:
https://github.com/moinwiki/moin/blob/8e84bff2841acf5deff9c3d1ce1737e0184c52a8/src/moin/_tests/test_wikiutil.py#L102
Probably the converter is expected to deal with a leading CHILD_PREFIX in the case of links to subitems.
Thank you for the pointer. Is seems like unnecessary code duplication, if every converter would have to use something like
wikiname = normalize_pagename(linktext, None) # second arg is ignored
# `wikiutils.normalize_pagename()` drops a leading slash (denotes "subitem")
if linktext.startswith("/"):
wikiname = "/" + wikiname
though.
OTOH, currently no other converter uses "normalize_pagename", instead Whitespace is only normalized in the HTML browser (the following line creates two different pages)
[[another page]] and yet [[another page]]
and strange space characters and rtl switches are kept in the page name
[[with embedded rtl switches]]
in a local "moinwiki" test page.
I wonder, whether I'd rather just drop the "page name normalization" from the rst converter as well.
I agree with your last sentence.
Item names provided in moin internal links or reST links should better not be "normalized" besides removal of leading/trailing whitespace.
In my opinion the function normalize_pagename seems to be made for other purposes, like .e.g normalizing a name as a result of user input or deriving a valid page name from an arbitrary name allowed to contain characters not allowed in item names.
In my opinion the function
normalize_pagenameseems to be made for other purposes, like .e.g normalizing a name as a result of user input or deriving a valid page name from an arbitrary name allowed to contain characters not allowed in item names.
Indeed, I used the function to gain a wiki-local URI reference from the descriptive link text. PR #2019 changes this to just normalizing whitespace --- restoring the behaviour in Moin up to 1.9.
As far as I know (tested with a grep on the sources), the function wikiutils.normalize_pagename() is no longer used in Moin2.
It also seems the function is either incomplete or underdocumented:
the mandatory second argument cfg is undocumented and ignored!
Unless there is a use case in ACL lines (as hinted in its doc), I suggest to deprecate the function and schedule it for removal.