use of org.eclipse.mylyn.wikitext.parser.HtmlParser in project mylyn.docs by eclipse.
the class HtmlParserTest method testCanParseSomething.
@Test
public void testCanParseSomething() throws Exception {
HtmlParser parser = new HtmlParser();
assertCanParseSomething(parser);
}
use of org.eclipse.mylyn.wikitext.parser.HtmlParser in project mylyn.docs by eclipse.
the class HtmlParserTest method parseHtmlToHtml.
private String parseHtmlToHtml(String input, boolean asDocument) throws IOException, SAXException {
HtmlParser parser = new HtmlParser();
StringWriter out = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
parser.parse(new InputSource(new StringReader(input)), builder, asDocument);
return out.toString();
}
use of org.eclipse.mylyn.wikitext.parser.HtmlParser in project mylyn.docs by eclipse.
the class HtmlParserTest method parsePreservesAsDocumentSetting.
@Test
public void parsePreservesAsDocumentSetting() throws IOException, SAXException {
HtmlParser parser = new HtmlParser();
StringWriter out = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
builder.setEmitAsDocument(false);
parser.parse(new InputSource(new StringReader("before <em>emphasis</em> after")), builder);
assertEquals("before <em>emphasis</em> after", out.toString());
}
use of org.eclipse.mylyn.wikitext.parser.HtmlParser in project mylyn.docs by eclipse.
the class HtmlLanguage method processContent.
@Override
public void processContent(MarkupParser parser, String markupContent, boolean asDocument) {
HtmlParser htmlParser = createHtmlParser();
InputSource source = new InputSource(new StringReader(markupContent));
try {
htmlParser.parse(source, parser.getBuilder(), asDocument);
} catch (IOException e) {
throw Throwables.propagate(e);
} catch (SAXException e) {
throw Throwables.propagate(e);
}
}
use of org.eclipse.mylyn.wikitext.parser.HtmlParser in project mylyn.docs by eclipse.
the class HtmlToMarkupTask method processFile.
private void processFile(MarkupLanguage markupLanguage, File folder, File source) {
// $NON-NLS-1$
log(MessageFormat.format(Messages.getString("MarkupToHtmlTask.14"), source), Project.MSG_VERBOSE);
if (isValidate()) {
// $NON-NLS-1$
log(MessageFormat.format(Messages.getString("HtmlToMarkupTask.1"), source), Project.MSG_WARN);
}
String name = source.getName();
if (name.lastIndexOf('.') != -1) {
name = name.substring(0, name.lastIndexOf('.'));
}
File outputFile = computeTargetFile(markupLanguage, source, name);
if (!outputFile.exists() || overwrite || outputFile.lastModified() < source.lastModified()) {
Writer writer;
try {
// $NON-NLS-1$
writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(outputFile)), "utf-8");
} catch (Exception e) {
throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.16"), outputFile, e.getMessage()), // $NON-NLS-1$
e);
}
try {
DocumentBuilder builder = markupLanguage.createDocumentBuilder(writer);
Reader input;
InputStream in;
try {
in = new BufferedInputStream(new FileInputStream(source));
input = getSourceEncoding() == null ? new InputStreamReader(in) : new InputStreamReader(in, getSourceEncoding());
} catch (Exception e) {
throw new BuildException(MessageFormat.format(Messages.getString("MarkupTask.cannotReadSource"), source, e.getMessage()), // $NON-NLS-1$
e);
}
try {
new HtmlParser().parse(new InputSource(input), builder);
} catch (Exception e) {
throw new BuildException(MessageFormat.format(Messages.getString("HtmlToMarkupTask.failedToProcessContent"), source, e.getMessage()), // $NON-NLS-1$
e);
} finally {
try {
in.close();
} catch (Exception e) {
throw new BuildException(MessageFormat.format(Messages.getString("MarkupTask.cannotReadSource"), source, e.getMessage()), // $NON-NLS-1$
e);
}
}
} finally {
try {
writer.close();
} catch (Exception e) {
throw new BuildException(MessageFormat.format(// $NON-NLS-1$
Messages.getString("MarkupToHtmlTask.17"), // $NON-NLS-1$
outputFile, e.getMessage()), e);
}
}
}
}
Aggregations