noties / Markwon

Android markdown library (no WebView)
https://noties.io/Markwon/
Apache License 2.0
2.68k stars 298 forks source link

How to make Latex show in RemoteView? #403

Closed zhouzhuo810 closed 1 year ago

zhouzhuo810 commented 2 years ago
  1. Please specify expected/actual behavior

I need to display the Latex formula in an Android AppWidget. I use Markwon inside the App, but I can't assign a value because I can't get the TextView object in the AppWidget. Is there any way to solve this?

  1. Please specify conditions/steps to reproduce (layout, code, markdown used, etc)
Spanned xxx = markwon.toMarkdown("$$\n"+"xxx"+"\n$$");
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_xxx);
views.setTextViewText(R.id.tv_xxx, xxx);

ask for help

zhouzhuo810 commented 2 years ago

@noties ask for help

noties commented 1 year ago

Hello @zhouzhuo810 ,

unfortunately it won't be possible to display Markwon in a widget. Widgets use IPC (interprocess communication), so to display a spanned content - only platform spans can be used (that come from Android directly). Markwon uses own spans, so they won't be displayed - not only LaTeX, but others too.

You can take a look at the RemoteViewsSample, which substitutes custom spans with platform ones. But still LaTeX won't be possible, as internally it uses Drawable, which cannot be sent between processes