ReadYou icon indicating copy to clipboard operation
ReadYou copied to clipboard

Add latex support for math blogs

Open aualbert opened this issue 1 year ago • 4 comments

1. Environment

  • Device: [RedmiNote 11]
  • OS: [Android 13]
  • APP: [0.9.12]

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:

  • the blog site includes mathjax or katex, and latex be included using an HTML element or DIRECTLY in the text by surrounding it by a usual latex math notation ($$, $$$$, etc)

  • latex formulas are directly concerted into images, like on WordPress.

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 avatar May 24 '24 18:05 aualbert

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.

aualbert avatar May 31 '24 15:05 aualbert

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

Ashinch avatar Jun 05 '24 14:06 Ashinch

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!

aualbert avatar Jun 05 '24 14:06 aualbert

#568 has been merged, we can start from the Webview

Ashinch avatar Aug 09 '24 10:08 Ashinch