convert non-string items to Category objects in textlib.categoryFormat()

Ib0701600a300b2435ac8f2c3b8a55c89faf2c2fe introduced the use of
the .aslink() method instead of .title() to support the sortKey.
However, aslink() on Page objects works differently,
so we convert them to Categories to ensure that the correct
version of aslink() is called.

If I4e7e67ec855d366fcf90005481093de64e5465c1 is merged,
simple strings could also be passed through Category(),
with the proper 'source' argument.

IMPORTANT BUGFIX:
preserve Category-specific properties (like sortKey)
when passing the object back to the constructor

bug: 68564
Change-Id: I3a343e42ce9b9562dfaad5d2d7737dc3ebe3c369
Merge "convert non-string items to Category objects in textlib.categoryFormat()"