Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,10 @@ private void process(final Element parent, final StreamReceiver receiver) {
addedValueAsSubfield = handleAttributeValuesAsSubfields(receiver, element, attributes, attribute);
receiver.literal(attribute.getKey(), attribute.getValue());
}
if (element.children().isEmpty()) {
final String text = element.text().trim();
final String value = text.isEmpty() ? element.data() : text;
if (!value.isEmpty() && !addedValueAsSubfield) {
receiver.literal("value", value);
}
final String text = element.text().trim();
final String value = text.isEmpty() ? element.data() : text;
if (!value.isEmpty() && !addedValueAsSubfield) {
receiver.literal("value", value);
}
process(element, receiver);
receiver.endEntity();
Expand Down Expand Up @@ -133,7 +131,7 @@ private boolean handleAttributeValuesAsSubfields(final StreamReceiver receiver,
* @param mapString the attributes to be added as subfields
*/
public void setAttrValsAsSubfields(final String mapString) {
this.attrValsAsSubfields = new HashMap<String, String>();
this.attrValsAsSubfields = new HashMap<>();
final String input = mapString.startsWith("&") ? DEFAULT_ATTR_VALS_AS_SUBFIELDS + mapString : mapString;
for (final String nameValuePair : input.split("&")) {
final String[] nameValue = nameValuePair.split("=");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ public void nestedEntities() {

}

@Test
public void mixedContent() {
htmlDecoder.process(new StringReader("<p>This is the <strong>full</strong> text</p>"));
final InOrder ordered = inOrder(receiver);
ordered.verify(receiver).startEntity("p");
ordered.verify(receiver).literal("value", "This is the full text");
// elements above plus body, html
ordered.verify(receiver, times(4)).endEntity();

}

@Test
public void htmlAttributesAsLiterals() {
htmlDecoder.process(new StringReader("<p class=lead>Text"));
Expand Down