Add escapeCSSIdent, from my parse-css project. Use it in fixIntrDocumentReferences so you can point to things with non-ident IDs.