Map<String, String> secondAttrs = new HashMap<String, String>();
// TODO(patcoleman): use StringMap<String> instead?
// copy whitelisted attributes
CMutableDocument doc = element.getMutableDoc();
Map<String, String> currentAttrs = line.getAttributes();
if (currentAttrs != null) {
for (Entry<String, String> entry : currentAttrs.entrySet()) {
if (attributeKeptOnNewline(entry.getKey(), entry.getValue())) {
secondAttrs.put(entry.getKey(), entry.getValue());
}
}
}
// rewrite to null if no attributes
if (secondAttrs.isEmpty()) {
secondAttrs = Attributes.EMPTY_MAP;
}
ContentElement newLineElement = doc.createElement(
doc.locate(doc.getLocation(point)), LineContainers.LINE_TAGNAME, secondAttrs);
ContentElement newLocalParagraph = Line.fromLineElement(newLineElement).getParagraph();
element.getSelectionHelper().setCaret(
Point.start(element.getRenderedContentView(), newLocalParagraph));