use of org.commonmark.node.Node in project symja_android_library by axkr.
the class RenderMarkdown method main.
public static void main(String[] args) {
Set<Extension> EXTENSIONS = Collections.singleton(TablesExtension.create());
Parser parser = Parser.builder().extensions(EXTENSIONS).build();
Node document = parser.parse(TABLE);
HtmlRenderer renderer = HtmlRenderer.builder().extensions(EXTENSIONS).build();
String html = renderer.render(document);
System.out.println(html);
}
use of org.commonmark.node.Node in project diary by billthefarmer.
the class Diary method updateWidgets.
// updateWidgets
@SuppressWarnings("deprecation")
private void updateWidgets(CharSequence text) {
Calendar today = Calendar.getInstance();
if (currEntry != null && currEntry.get(Calendar.YEAR) == today.get(Calendar.YEAR) && currEntry.get(Calendar.MONTH) == today.get(Calendar.MONTH) && currEntry.get(Calendar.DATE) == today.get(Calendar.DATE)) {
// Get date
DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM);
String date = format.format(today.getTime());
if (markdown) {
// Use commonmark
Parser parser = Parser.builder().build();
Node document = parser.parse(text.toString());
HtmlRenderer renderer = HtmlRenderer.builder().build();
String html = renderer.render(document);
text = Html.fromHtml(html);
}
AppWidgetManager manager = AppWidgetManager.getInstance(this);
ComponentName provider = new ComponentName(this, DiaryWidgetProvider.class);
RemoteViews views = new RemoteViews(getPackageName(), R.layout.widget);
views.setTextViewText(R.id.header, date);
views.setTextViewText(R.id.entry, text);
manager.updateAppWidget(provider, views);
}
}
Aggregations