Page 1 of 1

Converting HTML hyperlinks

PostPosted: Fri May 11, 2012 10:00 am
by conphident4
Thanks for the quick response Jason.
tried wrapping it within div & still getting the same error.

Also noticed while trying to import urls that it is printing the link name once as a hyperlink (without the hyperlink font style of blue color & underline - but i read somewhere that you have not implemented font features yet - guess that's y) and another time as a simple word
eg. when i give the following input:

Code: Select all
        String xhtml= "<div><p>Sent: 5/2/2012 5:53 PM (<i>53 seconds ago</i>)<br/>Source:\n" +
                "<a href=\"http://twitter.com/\">web</a>\n" +
                "</p></div>";


instead of importing into word as

Sent: 5/2/2012 5:53 PM (53 seconds ago)
Source:web
with web hyperlinked to http://twitter.com/

it imports as:
Sent: 5/2/2012 5:53 PM (53 seconds ago)
Source:webweb
with the first "web" being hyperlinked & 2nd instance of "web" being a simple word

Probably needs to be fixed?

Re: Converting HTML hyperlinks

PostPosted: Sun May 20, 2012 1:49 pm
by jason
Thanks for the report re importing hyperlinks.

The case I had tested had a span inside the hyperlink. Following https://github.com/plutext/docx4j/commi ... orter.java it works for your case and each of the following:

Code: Select all
        String xhtml= "<p ><a href=\"http://davidpritchard.org/images/pacsoc-s1b.png\"><span>http://davidpritchard.org/images/pacsoc-s1b.png</span></a></p>";
       
        String xhtml= "<p ><a href=\"http://davidpritchard.org/images/pacsoc-s1b.png\">http://davidpritchard.org/images/pacsoc-s1b.png</a></p>";       
       
        String xhtml= "<p ><a href=\"slashdot.org\" /></p>";       
       
        String xhtml= "<p ><a href=\"slashdot.org\" >slash<b>dot</b>.<span>o<i>r</i>g</span> </a></p>";       



Please note that in the last case, the formatting of the link text is ignored.

Also, please note that I've changed the name of the class to XHTMLImporter.