static string prepareTagHandle(string handle) {
if (string.IsNullOrEmpty(handle)) {
throw new EmitterException("tag handle must not be empty");
} else if (handle[0] != '!' || handle[handle.Length-1] != '!') {
throw new EmitterException("tag handle must start and end with '!': " + handle);
} else if ("!" != handle && !HANDLE_FORMAT.IsMatch(handle)) {
throw new EmitterException("invalid syntax for tag handle: " + handle);
}
return handle;
}