(BugId:100980) - Fix inherited categories disappearing when adding new cateogires in view mode.

https://wikia.fogbugz.com/default.asp?100980

RE: https://github.com/Wikia/app/pull/784

The previous fix caused the expanded templates to be saved and had to be reverted. This solution uses the same method of extracting categories from templates but avoids corrupting the original article wikitext.