(Bug 56983) Correctly serialize magic words added on client

* Added generic support for serialization of magic words added
  on the client.

* Unrecognized magicword directives in HTML are silently dropped
  on serialization.

* Minor code cleanup associated with adding support for this.

* Added new parser test to test this (passes with this patch
  and fails without).

Change-Id: I4afef6a1e8a5acbe5b0ac673fabe1d9bcd3cc0bf
Merge "(Bug 56983) Correctly serialize magic words added on client"