本文整理汇总了Java中org.eclipse.mylyn.wikitext.core.parser.MarkupParser类的典型用法代码示例。如果您正苦于以下问题:Java MarkupParser类的具体用法?Java MarkupParser怎么用?Java MarkupParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MarkupParser类属于org.eclipse.mylyn.wikitext.core.parser包,在下文中一共展示了MarkupParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
static String parse(Path path) {
if (!path.toFile().exists()){
return "";
}
StringWriter sw = new StringWriter();
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(new MarkdownLanguage());
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(sw);
builder.setEmitAsDocument(false);
parser.setBuilder(builder);
try {
parser.parse(new StringReader(new String(Files.readAllBytes(path))));
} catch (IOException e) {
e.printStackTrace();
}
return sw.toString();
}
示例2: toHtml
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
static String toHtml(String markdown) {
if (markdown == null) {
return "";
}
StringWriter sw = new StringWriter();
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(new MarkdownLanguage());
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(sw);
builder.setEmitAsDocument(false);
parser.setBuilder(builder);
try {
parser.parse(new StringReader(markdown));
} catch (IOException e) {
e.printStackTrace();
}
return sw.toString();
}
示例3: toHtml
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
private static String toHtml(String markdown) {
if (markdown == null) {
return "";
}
StringWriter sw = new StringWriter();
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(new MarkdownLanguage());
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(sw);
builder.setEmitAsDocument(false);
parser.setBuilder(builder);
try {
parser.parse(new StringReader(markdown));
} catch (IOException e) {
e.printStackTrace();
}
return sw.toString();
}
示例4: loadMarkDown
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
/**
* Загружает документ markdown из classpath
*
* @param resource путь к документу в classpath
* @return Подготовленный html документ
* @throws java.io.IOException if any.
*/
public static String loadMarkDown(final String resource) throws IOException {
// Читаем файл помоци
final InputStream contentStream = HelpContent.class.getResourceAsStream(resource);
final String content = CharStreams.toString(new InputStreamReader(contentStream, Charsets.UTF_8));
Closeables.close(contentStream, true);
// Читаем файл стилей
final InputStream cssStream = HelpContent.class.getResourceAsStream("/help/rest/help.css");
final String cssContent = CharStreams.toString(new InputStreamReader(cssStream, Charsets.UTF_8))
.replaceAll(System.getProperty("line.separator"), "");
Closeables.close(contentStream, true);
// Преобразуем в html
final StringBuilder out = new StringBuilder();
final HtmlDocumentBuilder builder = new HtmlDocumentBuilder(CharStreams.asWriter(out));
final HtmlDocumentBuilder.Stylesheet stylesheet = new HtmlDocumentBuilder.Stylesheet(new StringReader(cssContent));
builder.addCssStylesheet(stylesheet);
final MarkupParser markupParser = new MarkupParser();
markupParser.setMarkupLanguage(new TextileLanguage());
markupParser.setBuilder(builder);
markupParser.parse(content);
return out.toString();
}
示例5: getHtml
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
public String getHtml() {
StringWriter writer = new StringWriter();
BlogHtmlBuilder builder = new BlogHtmlBuilder(writer, entry, fileBasePath);
MarkupParser parser = new MarkupParser(new TextileLanguage());
parser.setBuilder(builder);
String contents = entry.getContents();
Pattern pattern = Pattern.compile("\\[\\[([^\\]]*?)\\]\\]");
Matcher matcher = pattern.matcher(contents);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
String title = matcher.group(1);
matcher.appendReplacement(sb, "<a href=\"" + linkBasePath + "/" + title.replace(' ', '_') + "\">" + title + "</a>");
}
matcher.appendTail(sb);
parser.parse(sb.toString());
return writer.toString();
}
示例6: getHtmlFormatText
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
public static String getHtmlFormatText(String wikiFormatText, String language) {
if (language == null || language.isEmpty()) {
LOG.log(Level.FINE, "Wiki language name is empty"); //NOI18N
return null;
}
MarkupLanguage markupLanguage;
ClassLoader originalContextCL = null;
try {
originalContextCL = setupContextClassLoader();
markupLanguage = ServiceLocator.getInstance().getMarkupLanguage(language);
} catch (IllegalArgumentException ex) {
// issue #258571
String msg = ex.getMessage();
if(msg.startsWith("Cannot load markup language")) { // NOI18N
LOG.log(Level.INFO, null, ex);
markupLanguage = null;
} else {
throw ex;
}
} finally {
restoreContextClassLoader(originalContextCL);
}
if (markupLanguage == null) {
LOG.log(Level.FINE, "Markup language for name {0} not found",language); //NOI18N
return null;
}
MarkupParser parser = new MarkupParser(markupLanguage);
String dirtyHtml = parser.parseToHtml(wikiFormatText);
return cleanHtmlTags(dirtyHtml);
}
示例7: execute
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
public void execute( ExecutionContext executionContext ) throws ParsingException, ExecutionException
{
HtmlDocumentBuilder builder = new HtmlDocumentBuilder( executionContext.getWriter() );
MarkupParser markupParser = new MarkupParser( adapter.markupLanguage );
markupParser.setBuilder( builder );
markupParser.parse( sourceCode, false );
}
示例8: printHelloWorld
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
private static void printHelloWorld(MarkupLanguage markupLanguage, String languageName, String text) {
printHeader(languageName);
StringWriter writer = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
builder.setEmitAsDocument(false);
MarkupParser parser = new MarkupParser(markupLanguage, builder);
parser.parse(text);
System.out.println(writer.toString());
System.out.println();
}
示例9: extractPlainText
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
public static String extractPlainText(String wikiMarkup) {
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(new MediaWikiLanguage());
PlaintextDocumentBuilder builder = new PlaintextDocumentBuilder();
parser.setBuilder(builder);
parser.parse(wikiMarkup);
return builder.getResult();
}
示例10: convert
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
public void convert(Reader reader, Writer writer) throws IOException {
DocBookDocumentBuilder builder = new DocBookDocumentBuilder(writer);
MarkupParser parser = new MarkupParser();
parser.setMarkupLanguage(markupLanguage);
parser.setBuilder(builder);
parser.parse(reader);
writer.flush();
}
示例11: convert
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
@Override
public String convert(String content) {
MarkupParser parser = getMarkupParser();
StringWriter writer = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
// avoid the <html> and <body> tags
builder.setEmitAsDocument(false);
parser.setBuilder(builder);
parser.parse(content);
parser.setBuilder(null);
return writer.toString();
}
示例12: getMarkupParser
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
@Override
protected MarkupParser getMarkupParser() {
return parser;
}
示例13: createMarkupParser
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
private MarkupParser createMarkupParser() {
final MarkupParser markupParser = new MarkupParser();
markupParser.setMarkupLanguage(createMarkupLanguage());
return markupParser;
}
示例14: parse
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
void parse(inputType inputFormat, Reader inputReader, outputType outputType, Writer outputWriter) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, IOException {
DocumentBuilder builder = outputType.getBuilder(outputWriter);
MarkupLanguage language = inputFormat.getMarkupLanguage();
MarkupParser parser = new MarkupParser(language, builder);
parser.parse(inputReader);
}
示例15: getMarkupParser
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser; //导入依赖的package包/类
/**
* Return the MarkupParser instance.
*
* @return MarkupParser for this converter.
*/
protected abstract MarkupParser getMarkupParser();