Skip to content

Commit

Permalink
TIKA-4361 (#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison authored Dec 4, 2024
1 parent 92053ea commit 8adac3e
Showing 1 changed file with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ private void processControlWord(int param, PushbackInputStream in)
} else {
// In document
if (equals("b")) {
//TIKA-4361 -- need to make sure we're not in an href?
// b0
assert param == 0;
if (groupState.bold) {
Expand Down Expand Up @@ -1085,6 +1086,9 @@ private boolean isUnorderedList(int listID) {
}

private void end(String tag) throws IOException, SAXException, TikaException {
if ("b".equals(tag)) {
System.out.println("ending b");
}
out.endElement(XHTML, tag, tag);
}

Expand Down Expand Up @@ -1479,29 +1483,31 @@ private void processGroupEnd() throws IOException, SAXException, TikaException {
if (groupStates.size() > 0) {
// Restore group state:
final GroupState outerGroupState = groupStates.removeLast();

// Close italic, if outer does not have italic or
// bold changed:
if (groupState.italic) {
if (!outerGroupState.italic || groupState.bold != outerGroupState.bold) {
end("i");
groupState.italic = false;
//only modify styles if we're not in a hyperlink
if (fieldState == 0) {
// Close italic, if outer does not have italic or
// bold changed:
if (groupState.italic) {
if (!outerGroupState.italic || groupState.bold != outerGroupState.bold) {
end("i");
groupState.italic = false;
}
}
}

// Close bold
if (groupState.bold && !outerGroupState.bold) {
end("b");
}
// Close bold
if (groupState.bold && !outerGroupState.bold) {
end("b");
}

// Open bold
if (!groupState.bold && outerGroupState.bold) {
start("b");
}
// Open bold
if (!groupState.bold && outerGroupState.bold) {
start("b");
}

// Open italic
if (!groupState.italic && outerGroupState.italic) {
start("i");
// Open italic
if (!groupState.italic && outerGroupState.italic) {
start("i");
}
}
groupState = outerGroupState;
}
Expand Down

0 comments on commit 8adac3e

Please sign in to comment.