Jwrede / Anki-KaTeX-Markdown

Creates a new Basic and a new Cloze Note Type that support Markdown and KaTeX
74 stars 5 forks source link

katex.min.js load fail in andorid #3

Closed b-y-f closed 3 years ago

b-y-f commented 3 years ago
  1. katex.min.js load fail in andorid
  2. img not supported?
icearchimage commented 3 years ago

On my phone, this is just a warning. Katex expressions are rendered correctly. WeChat Image_20210317125057 Maybe the author could make some improvements to avoid the warning? I also tried on my iPad, no warning at all :smile:.

The images are shown fine on my PC.

b-y-f commented 3 years ago

problem solved for me, i am using Firefox add-on:

Copy Selection as Markdown

and set copy image as \<img>

b-y-f commented 3 years ago

image worked, with add-on paste plaint text.

2. img not supported? ![](xx)
Jwrede commented 3 years ago

Do I understand correctly that the only problems left in this Issue are the warnings that appear? I didn't know yet that Anki on the phone shows these warning (should've tested that), I'll try to catch them!

b-y-f commented 3 years ago

Do I understand correctly that the only problems left in this Issue are the warnings that appear? I didn't know yet that Anki on the phone shows these warning (should've tested that), I'll try to catch them!

Yes, If add one more option after basic , clonz for highlight syntax would be perfect(because highlight is not used frequently so make it optional to save JS loading time)

Jwrede commented 3 years ago

Sadly I see no way to supress the warning in Ankidroid, I use Javascript to test if the KaTeX and Markdown scripts are saved locally which is not the case with phones and if this returns a 404 Error I use a CDN for these files, Javascript doesn't allow supression of 404 Errors and as far as I know doesn't support looking up beforehand how to check if a file exists, and Ankidroid misinterprets these Errors as trying to load media files (These warnings are also just in the latest Version of Ankidroid, thats why I didn't see them).

I will write to the Ankidroid Team if they could implement an option to turn of these notifications or if there is a way to insert Javascript files in Ankidroid!

Jwrede commented 3 years ago

Do I understand correctly that the only problems left in this Issue are the warnings that appear? I didn't know yet that Anki on the phone shows these warning (should've tested that), I'll try to catch them!

Yes, If add one more option after basic , clonz for highlight syntax would be perfect(because highlight is not used frequently so make it optional to save JS loading time)

Thanks for the suggestion, could you rephrase it again, I'm not quite sure if I understand it correctly, sorry!

Also the loading time of JS shouldn't really be noticable, The only reason why its slow should be that the KaTeX and Markdown files have to be downloaded on all other devices but PC's first because they don't support Add-ons natively, hope they someday will but until then we sadly have to settle with this :/

b-y-f commented 3 years ago

Thanks for the suggestion, could you rephrase it again, I'm not quite sure if I understand it correctly, sorry!

I mean add a syntax highlighter would make this add-on works better.

Jwrede commented 3 years ago

Yea that would probably help alot, this is out of scope for me tho because because at least from what i saw there is until now no syntax highlighter available for KaTeX or even MathJax, which would mean I'd have to write one on my own which could take a few month which sadly I don't have. Also Anki works with basic HTML Divs which dont support coloring very well from what I've seen.

If you have any Idea on how to implement that feature without taking too long I'm open for suggestions tho!

Jwrede commented 3 years ago

But I managed to get rid of the warning on AnkiDroid, please manually update to the newest version by going into Anki and then Tools -> Add-ons -> Check for Updates and then press sync and also sync on the AnkiDroid app, please tell me if it worked!

b-y-f commented 3 years ago

But I managed to get rid of the warning on AnkiDroid, please manually update to the newest version by going into Anki and then Tools -> Add-ons -> Check for Updates and then press sync and also sync on the AnkiDroid app, please tell me if it worked!

I reckon both my desktop, android client are latest, because I just start using it since this week...

b-y-f commented 3 years ago

can you also fix bug in inline code displayed with block code?

Jwrede commented 3 years ago

But I managed to get rid of the warning on AnkiDroid, please manually update to the newest version by going into Anki and then Tools -> Add-ons -> Check for Updates and then press sync and also sync on the AnkiDroid app, please tell me if it worked!

I reckon both my desktop, android client are latest, because I just start using it since this week...

No i meant the latest version of the Add-on, I think I fixed the Card Content Loaded error yesterday, Anki just takes 1 or 2 days to update Add-ons automatically

Jwrede commented 3 years ago

can you also fix bug in inline code displayed with block code?

Should be fixed now as well!

icearchimage commented 3 years ago

can you also fix bug in inline code displayed with block code?

Should be fixed now as well!

It's not fixed on my PC. I noticed the inline code in your example gif image is rendered as a block code:rofl:. Maybe you should update that gif too.

Jwrede commented 3 years ago

True didn't even notice that :D, it's just css styling, just took a code style I like from the internet and didn't notice the wrong formating,

If i use inline code like this in the latest update: image
It looks like this now: image if not, especially if the code block looks very different with grey background make sure to update again, sorry for the amount of updates :D

Jwrede commented 3 years ago

Ahh no I see the problem, the css doesn't get updated when I update the Add-on, 1 sec

Edit: Pretty sure it should work now

b-y-f commented 3 years ago

THANK YOU! Which tag should I use to DIY CSS for code block? I want code block wrapped within width 100% div

b-y-f commented 3 years ago

I think your code used bad a horizontal scroll bar when read code in mobile device

b-y-f commented 3 years ago

image

pre code {
  background-color: #eee;
  border: 1px solid #999;
  display: block;
  padding: 20px;
}
b-y-f commented 3 years ago

inline and block using same \<code>?

Jwrede commented 3 years ago

image

pre code {
  background-color: #eee;
  border: 1px solid #999;
  display: block;
  padding: 20px;
}

I'm pretty sure thats a problem with Anki's styling, if you do

pre code { 
   width: 100vw;
   background-color: grey;
}

the div's definitly not getting 100vw. I think you should use overflow: auto for these, thats probably the best.

Also I'd advice against changing CSS in the "KaTeX and Markdown Basic / Cloze" Notetypes itself, because if I update the css cause of a bug or anything else it will delete your CSS template, but I could implement your code block with overflow: auto if you're okay with that because I also like the styling. You could also just make a copy of the Notetype and change it as much as you like!

Jwrede commented 3 years ago

inline and block using same ?

Yea, markdown-it does that by default, inline code is rendered with <code> and block style code with <pre><code>

b-y-f commented 3 years ago

Thank you !! works great now

Jwrede commented 3 years ago

Thats great to hear, tomorrow I'll add the code block styling you suggested if you don't mind!