use of org.eclipse.egit.github.core.service.MarkdownService in project Bitocle by mthli.
the class WebViewTask method doInBackground.
@Override
protected Boolean doInBackground(Void... params) {
GitHubClient client = fragment.getClient();
RepositoryId id = RepositoryId.create(owner, name);
DataService dataService = new DataService(client);
MarkdownService markdownService = new MarkdownService(client);
Blob blob;
try {
blob = dataService.getBlob(id, sha);
} catch (IOException i) {
return false;
}
if (isCancelled()) {
return false;
}
String base64 = blob.getContent();
if (!MimeType.isImage(filename)) {
byte[] bytes = EncodingUtils.fromBase64(base64);
content = new String(bytes);
}
if (MimeType.isImage(filename)) {
String imageUrl = GetImage.getImageUrl(base64, MimeType.getImageExtension(filename));
image = GetImage.getImage(imageUrl);
} else if (MimeType.isMarkdown(filename)) {
try {
content = markdownService.getHtml(content, MarkdownService.MODE_GFM);
content = StyleMarkdown.styleMarkdown(content);
} catch (IOException i) {
return false;
}
} else {
content = SyntaxCode.syntaxCode(content, css);
}
if (isCancelled()) {
return false;
}
return true;
}
Aggregations