MessageQueue mq = makeMessageQueue();
// Newline works around Caja parser issue with certain short-form
// HTML - the internal Lexer gets confused. A bug has been filed w/ Caja.
// Even so, adding the newline is innocuous for any HTML.
DomParser parser = getDomParser(source + '\n', mq);
DocumentFragment fragment = parser.parseFragment();
// Get rid of the newline, if maintained.
Node lastChild = fragment != null ? fragment.getLastChild() : null;
if (lastChild != null && lastChild.getNodeType() == Node.TEXT_NODE) {
String lastText = lastChild.getTextContent();
if ("\n".equals(lastText)) {