First, the format of the markup language needs to be explained. The first line will be a title, and then subsequent paragraphs are blank-line separated. This can be translated into an HTML file as follows.
Minimark source |
Translated HTML |
---|---|
This is the title A paragraph with some text Another paragraph |
<html><head><title>This is the title</title></head><body><h1>This is the title</h1> <p> A paragraph with some text </p> <p> Another paragraph </p></body></html> |
Create a class called
MinimarkTranslator
in thecom.packtpub.e4.minimark.ui
package as follows:public class MinimarkTranslator { public static void convert(Reader reader, Writer writer) throws IOException { BufferedReader lines = new BufferedReader(reader); String line; String title = String.valueOf(lines.readLine()); writer.write("<html><head><title>"); writer...