Hello.
I want to highlight the paragraph in converted html from docx.
I have two type of data.
- paragraph text data.
- Split/converted HTML pages.
I processed paragraph text data. and select one paragraph. after then I want to display highlight that paragraph in converted HTML page.
Simple text match is not feasible. because one simple paragraph can have many runs. and same text can be occur in same page.
Example:
docx:
hello, allganize.
how are you?
html:
<div ..><span ..>hello,</span><span .. >allganize</span></div>
<div ..><span ..>how are you?</span></div>
paragraph index, text:
1, hello, allganize
2, how are you?
I tried to using insert paragraph index made by invisible chars. but It broke layout. (invisible chars are like \u2060 ~ \u2064)
example html)
<div ..><span ..>\u2061</span><span ..>hello,</span><span .. >allganize</span><<span ..>\u2061</span>/div>
<div ..><span ..>\u2062</span><span ..>how are you?</span><span ..>\u2062</span></div>
I found zero-width space is not broken layout. \u200b
But it is just single char. So it is not feasible for describe paragraph index. So I will try to insert hyperlink with zero-width space display and link that described paragraph index.
Question 1.
I make hyperlink like this.
DocumentBuilder builder = new DocumentBuilder(doc);
String marker = "\u200B";
builder.moveTo(paragraph);
builder.insertHyperlink(marker, "http://foo.com", false);
But this hyperlink is not rendered at html.
How can I make html like this?
example html)
<div ..><a href="1">\u200b</a><span ..>hello,</span><span .. >allganize</span><a href="1">\u200b</a>/div>
<div ..><a href="2">\u200b</a><span ..>how are you?</span><a href="2">\u200b</a></div>
Question 2.
Can I make hyperlink over the specific paragraph? It also solve my needs.
example html)
<div ..><a href="1"><span ..>hello,</span><span .. >allganize</span></a>/div>
<div ..><a href="2"><span ..>how are you?</span></a></div>
Question 3.
Can I insert maker while converting html? In this case, maker can be any not displayed.
example html)
<div ..><!-- 1 --><span ..>hello,</span><span .. >allganize</span><!-- 1 --></div>
<div ..><!-- 2 --><span ..>how are you?</span><!-- 2 --></div>