Ashinch / ReadYou

An Android RSS reader presented in Material You style.
GNU General Public License v3.0
4.83k stars 188 forks source link

Add latex support for math blogs #704

Open aualbert opened 4 months ago

aualbert commented 4 months ago

1. Environment

2. Describe the feature request

The app is wonderful but cannot be used on math blog as latex is not managed well. There are two main ways to display latex on a blog:

In the first case, un ReadYou, the latex formula is displayed as text.Screenshot_2024-05-24-19-48-15-616_me.ash.reader.jpg

In the second case, the image is included with the formula as description.Screenshot_2024-05-24-19-48-34-369_me.ash.reader.jpg

In both case the HTML parser could be modified. Katex could then be used to display the math.

aualbert commented 4 months ago

To give a few more details, once the webview renderer is ready (https://github.com/Ashinch/ReadYou/pull/568), it suffices to include the relevant files (at least katex.min.js and katex.min.css, these can be added in the resources) in the head of the html that will be displayed using webview. This deals with in-text Latex formulas. To deal with Latex properly on a WordPress blog, image urls have to be scanned and if an url of the form https://s0.wp.com/latex.php? latex=%7BF_2%28N%29+%3D+%28%5Cfrac%7B6%7D%7B%5Cpi%5E2%7D+%2B+o%281%29%29+N%7D&bg=ffffff&fg=000000&s=0&c=20201002&zoom=4.5 is found, the image could be converted directly into a latex formula that will be displayed locally with Katex.

Ashinch commented 3 months ago

It looks like LaTeX is being treated as an image in native rendering. Maybe turning off the maximize images setting can temporarily fix this.

aualbert commented 3 months ago

It looks like LaTeX is being treated as an image in native rendering. Maybe turning off the maximize images setting can temporarily fix this.

These latex formulas are indeed images. WordPress automatically convert latex formulas into images, so when the article is pulled, the html contains an image instead of text. However, the text can be recovered either from the image URL or image description.

I can take care of the latex rendering once the webview is ready!

Ashinch commented 1 month ago

568 has been merged, we can start from the Webview