Skip to content

Commit

Permalink
Handle br (soft return). Ignore pseudo-elements, so we don't get 2 of…
Browse files Browse the repository at this point in the history
… them.
  • Loading branch information
plutext committed Jan 12, 2021
1 parent 42fed64 commit a8e110a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/main/java/org/docx4j/convert/in/xhtml/XHTMLImporterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,11 @@ private float dotsToTwip(float dots) {

private void processInlineBox( InlineBox inlineBox) {

if (inlineBox.getPseudoElementOrClass()!=null) {
log.debug("Ignoring Pseudo");
return;
}

// Doesn't extend box
Styleable s = inlineBox;

Expand Down Expand Up @@ -2080,22 +2085,22 @@ private void processInlineBoxContent(InlineBox inlineBox, Styleable s,
CTMarkupRange markupRangeForID = bookmarkHelper.anchorToBookmark(inlineBox.getElement(), bookmarkNamePrefix,
getCurrentParagraph(false), this.contentContextStack.peek());


if (inlineBox.getText()==null) {
if (s!=null && s.getElement()!=null && s.getElement().getNodeName().equals("br") ) {

R run = Context.getWmlObjectFactory().createR();
getListForRun().getContent().add(run);
run.getContent().add(Context.getWmlObjectFactory().createBr());

} else if (inlineBox.getText()==null) {
// Doesn't happen anymore, now we're using openhtmltopdf?

if (s == null) {
log.debug("Null Styleable" );
} else if (s.getElement() == null) {
log.debug("Null element " );
} else if (s.getElement().getNodeName() == null) {
log.debug("Null element nodename " );
} else if (s.getElement().getNodeName().equals("br") ) {

R run = Context.getWmlObjectFactory().createR();
getListForRun().getContent().add(run);
run.getContent().add(Context.getWmlObjectFactory().createBr());

} else {
} else {
log.debug("InlineBox has no TextNode, so skipping" );

// TODO .. a span in a span or a?
Expand Down

0 comments on commit a8e110a

Please sign in to comment.