I usually like to collect some text document materials. I originally wanted to make a batch processing for converting txt to htm, to convert a large amount of collected things into htm, and then compile them into CHM e-books. Unexpectedly, I was first stumped by the problem of converting txt to htm just when I started. I was going to post in the batch processing column, but thought this is not a DOS problem, so I posted here. I hope the moderator won't say I posted in the wrong place..
One method is that some e-book making software itself supports compiling txt, which maintains the original appearance of the text, but there is a fatal weakness that it cannot support full-text search. This is quite bad for larger CHM. Weakness two is that for lines that are longer in a single line, when browsing, it cannot wrap automatically, and you have to drag the horizontal scroll bar to finish reading.
There are also very few such small software on the Internet. There is one on Huajun, which is just a method of inserting text between <pre></pre>. The htm converted by this method can maintain the original style of txt, and after compiling into CHM, it can support full-text search, but it is also for lines that are longer in a single line, and when browsing, it cannot wrap automatically. It feels very inconvenient.
I actually used a clumsy method, that is, first replace all spaces in the text with , then add <br> at the beginning of each line, then put the entire text between <p></P>, and finally add the start and end codes, change the extension to htm. This first converts the text to htm and then compiles it into chm, which maintains the original style of the text, and can also wrap automatically for longer lines, and also supports full-text search. But there is one shortcoming, that is, the converted htm file is nearly twice as large as the original txt file (this is caused by the replacement of spaces, but this is the price to maintain the original style of the text). This is also not ideal for a large amount of text. Since I have limited knowledge in web pages, I hope that those who are more proficient can talk about the best method for converting text to htm.
The best method is simple, easy to implement, and overcomes the above shortcomings.
[ Last edited by zzhh612 on 2007-4-6 at 11:50 AM ]
One method is that some e-book making software itself supports compiling txt, which maintains the original appearance of the text, but there is a fatal weakness that it cannot support full-text search. This is quite bad for larger CHM. Weakness two is that for lines that are longer in a single line, when browsing, it cannot wrap automatically, and you have to drag the horizontal scroll bar to finish reading.
There are also very few such small software on the Internet. There is one on Huajun, which is just a method of inserting text between <pre></pre>. The htm converted by this method can maintain the original style of txt, and after compiling into CHM, it can support full-text search, but it is also for lines that are longer in a single line, and when browsing, it cannot wrap automatically. It feels very inconvenient.
I actually used a clumsy method, that is, first replace all spaces in the text with , then add <br> at the beginning of each line, then put the entire text between <p></P>, and finally add the start and end codes, change the extension to htm. This first converts the text to htm and then compiles it into chm, which maintains the original style of the text, and can also wrap automatically for longer lines, and also supports full-text search. But there is one shortcoming, that is, the converted htm file is nearly twice as large as the original txt file (this is caused by the replacement of spaces, but this is the price to maintain the original style of the text). This is also not ideal for a large amount of text. Since I have limited knowledge in web pages, I hope that those who are more proficient can talk about the best method for converting text to htm.
The best method is simple, easy to implement, and overcomes the above shortcomings.
[ Last edited by zzhh612 on 2007-4-6 at 11:50 AM ]
