Subbu, Gergo and Gabriel:
Thank you for your comments so far.
Just to be clear, ideally I want the anchor ids to be the same as used in Core. I would really like for Parsoid to provide the same anchor ids as Core does. Then that would take also care of the uniqueness issue. Is there a task for this? If not I'd be happy to create one. In the meantime I'll use my own implementation until we get something from upstream.
If the anchor ids generated by the Mobile Content Service do not match the ones generated by Core then the app would not scroll to the correct section. Instead it would just stay at the top of the page.
The links can come from inside the same page, other pages, redirects, or even from outside the app/site. The app builds the correct <h[2-6]> tags using the anchor values provided by the Mobile Content Service output. This is why I don't want just an anchor id that looks like "mwCA". (Of course, that would be ok if core would do the same but right now it doesn't.)
Subbu: Thanks for the link to the JS code. I'll adapt my patch to include some of the additional substitutions. You may also want to check out my patch since I think some of the cases that are handled by the phpjs library are not handled in the Parsoid code.
Another thing I haven't found in the Parsoid code is ensuring uniqueness of ids. I'd be interested how this is resolved in Core, too, of course, to make sure what we do on the JS matches Core.
Cheers,
Bernd