corfuitl has asked for the wisdom of the Perl Monks concerning the following question:
Hi perlmonks
I have a problem to solve and I would appreciated your help.
I have a txt file which contains one sentence per line and its html correspondence, and I would like to write in the html which line matches with what sentence in the html. Please note that in html one line may contain more than one sentences.
For example, my TXL file looks like:
This is sentence 1 This is sentence 2 This is sentence 1 This is sentence 3
And the html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <body> <p>This is sentence 1</p> <p>This is <font color="#000000"><font face="Century Gothic, serif">se +ntence 2</font></font></p> <p>This is sentence 1. This is sentence <span style="font-weight: norm +al">3</span> </p> </body> </html>
As you can see, the html file contains some extra html code, which makes things complex.
What I want to do is to add some html code and wrap the sentence:
<p><sentence id=”1”>This is sentence 1></sentence></p> <p><sentence id=”2”>This is <font color="#000000"><font face="Century +Gothic, serif">sentence 2</font></font></p></sentence> <p><sentence id=”3”>This is sentence 1. </sentence><sentence id=”4”>Th +is is sentence <span style="font-weight: normal">3</span></sentence>< +/p>
The order of the TXT corresponds to the order of the HTML. If no match found, then it should go to the next segment. Any ideas?
Thanks in advance for your help
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Match text from txt to html
by marto (Cardinal) on Sep 04, 2019 at 14:17 UTC | |
by corfuitl (Sexton) on Sep 04, 2019 at 15:22 UTC | |
by marto (Cardinal) on Sep 04, 2019 at 15:30 UTC | |
Re: Match text from txt to html
by talexb (Chancellor) on Sep 04, 2019 at 13:41 UTC | |
by corfuitl (Sexton) on Sep 04, 2019 at 13:48 UTC | |
by talexb (Chancellor) on Sep 04, 2019 at 14:16 UTC | |
by corfuitl (Sexton) on Sep 04, 2019 at 14:42 UTC | |
by marto (Cardinal) on Sep 04, 2019 at 14:46 UTC | |
by corfuitl (Sexton) on Sep 04, 2019 at 15:20 UTC | |
Re: Match text from txt to html
by jcb (Parson) on Sep 04, 2019 at 22:21 UTC | |
by Anonymous Monk on Sep 05, 2019 at 01:00 UTC | |
by jcb (Parson) on Sep 05, 2019 at 01:40 UTC | |
by Anonymous Monk on Sep 06, 2019 at 04:04 UTC | |
by jcb (Parson) on Sep 06, 2019 at 04:09 UTC | |
|