Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 08-19-2012, 03:00 PM   #16
vri
Junior Member
vri began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2012
Device: none
Thank you so much! You have beaten my expectations in every possible way; the support you offer is unsurpassed!
vri is offline   Reply With Quote
Old 08-20-2012, 12:31 AM   #17
pkra
Junior Member
pkra began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2012
Device: all
Hi Kovid,

Sorry for the delay -- for a couple of these I had to ask our lead developer Davide Cervone for advice.

1) Can we use the unpacked javascript? I much prefer using unpacked javascript as it allows easier debugging and local modifications.

No reason not to use the unpacked version for a local installation. But I don't recommend making local modifications directly to the code. The "right" way (from a MJ point of view) is having your configuration include the patches -- easier to update MathJax that way. There are examples of this on the MathJax-user forum. I also tend to suggest a configuration file, not inline configurations. Generally, see http://www.mathjax.org/docs/2.0/configuration.html

2) Are there any other config options apart from imageFonts:null to use to suppress warnings with svg output and no fonts? Though looking at the code, it seems like imageFonts is no longer needed.

SVG doesn't use imageFonts:null, only the HTML-CSS output, so no need to specify it for SVG. Since you have disabled the menu, they can't switch to that renderer, but you don't want to allow that anyway, since you don't include the code. So if you ever re-enable to menu, you will want to include

MathMenu: {
showRenderer: false
}

to disable the renderer menu.

3) What would be a good way of allowing the user to specify parts of the config via a script tag in the document while still setting most of it in calibre code. I suppose I could define my own config function, but I was hoping that there exists a canonical way to do it.

MathJax looks for <script type="text/x-mathjax-config">...</script> blocks to do its configuration. If the user can include those (before(!) the script that loads MathJax.js itself), then those can be used for user-configuration of MathJax. Alternatively, (if you choose to switch to configuration files), you can keep the user configuration in a separate file and load both. Again, see http://www.mathjax.org/docs/2.0/configuration.html

One caveat: given that you've shrunk MathJax so much that you've lost functionality, user configurations might call features you've removed (like html+css output).

4) For some reason, none of the right click menu entries work in the calibre viewer.

(see 5)

4.5) Is there a config option that will allow mathjax to log errors using console.log? This makes debugging easier.

File errors can be obtained from MathJax.Message.Log() -- see http://www.mathjax.org/docs/2.0/api/message.html. Other errors during processing will generate error signals, which can be trapped by a signal listener. The simplest would be to use

MathJax.Hub.signal.Interest(function (message) {console.log(message)});

but this will show ALL the messages, not just errors.
UNTESTED: You could do something like

MathJax.Hub.signal.Interest(function (message) {if (String(message).match(/error/i) {console.log(message)}});

5) The HTML/CSS output and the right click menus dont work with calibre's viewer in paged mode. This is because the paged mode is implemented using the CSS3 columns module, which causes all the CSS positioning you use to break. You could probably fix that by using getBoundingClientRect to calculate positions rather than the usual offsetParent techniques.

Yes, this needs to be addressed. Thanks for the suggestion!

6) Equations do not reflow when the viewer window is too narrow for them, I assume that's by design? I see the same behavior in Chrome with both html/css output and svg output

There is a line breaking algorithm, but it is not enabled by default (it slows down processing). Note that it is not dynamic, so the equations don't reflow if the window changes, but it will break according to the size when the equations are first processed. To get it, use

MathJax.Hub.Config({
SVG: {linebreaks: {automatic: true}}
});

The algorithm is not perfect, but it should help. Note that it applies only to display equations, not in-line ones (unless they are too long to fit on a line by themselves).
pkra is offline   Reply With Quote
Advert
Old 08-20-2012, 02:15 AM   #18
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,419
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Thanks, that was helpful.

Enabling line breaks causes equations that are longer than the viewer window to disappear. This happens both in paged mode and in normal mode (without css3 columns). I have the viewer calling Hub.Rerender() every time the window width changes. So when I make the window narrow, equation disappers, when I make it wide again, it re-appers. I guess for the moment I will will just leave it as is.
kovidgoyal is offline   Reply With Quote
Old 08-20-2012, 02:54 AM   #19
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,419
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Another bug I noticed is that in the viewer I use a custom handler for users clicking on links. When using equation references, the viewer calls (effectively)

elem = document.getElementById(id)
elem.scrollIntoView()

This does not scroll properly, it seems to scroll so that the bottom of the svg tag containing the element with the given id is at the top of the screen, which means the element is hidden. To workaround it, I am instead scrolling to the parent of the svg tag, which works ok as long as there are not too many equations in that block.

I have no idea why scrollIntoView() misbehaves, would you happen to know why?
kovidgoyal is offline   Reply With Quote
Old 08-22-2012, 06:48 PM   #20
pkra
Junior Member
pkra began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2012
Device: all
Hi Kovid,

The first one seems to be a bug -- I'll check with our devs. (EDIT: did you see our docs? http://www.mathjax.org/docs/2.0/typeset.html -- MathJax.Hub.Queue(["Typeset",MathJax.Hub]); is the official way, unless there are serious reasons not to).

Thanks for the second one. Scrolling is usually tricky since MathJax changes a lot on the page, so I'm not sure if this is just our known problem or something more. Could you file a bug report on github.com/mathjax/mathjax about it?

IIRC, calibre viewer uses webkit, so this is likely a generic issue that we would like to fix.

Last edited by pkra; 08-22-2012 at 06:51 PM. Reason: link to docs
pkra is offline   Reply With Quote
Advert
Old 08-22-2012, 11:31 PM   #21
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,419
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It's inefficient to call typeset on a resize, since that would cause all the input jax to be constructed again, when that hasn't changed. Note that this is not modifying math, just relaying out the equations on resize.

As far as I could see from the docs, Rerender is the "best" way to do that. More importantly, if I use Typeset instead of Rerender, I find that the equations with numbers are not re-aligned.
kovidgoyal is offline   Reply With Quote
Old 08-23-2012, 11:23 AM   #22
pkra
Junior Member
pkra began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2012
Device: all
ah, sorry, you're right of course. Thanks for the bug reports on our tracker!
pkra is offline   Reply With Quote
Old 02-14-2013, 06:43 PM   #23
ste_fan
Junior Member
ste_fan began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Feb 2013
Device: Kobo Glo
Convert MathML to image?

Hi, I think I experience a similar problem: The formulas appear very nicely in calibre's internal reader, but look messy on my ebook reader device. Would it not be a workaround to have the MathML parts converted to images (SVG/PNG) to generate a EPUB that also looks nice on the reader devices?

Cheers
Stefan
ste_fan is offline   Reply With Quote
Old 03-31-2017, 07:27 PM   #24
knorris
Member
knorris began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Apr 2016
Device: kindle
Not exactly relevant to the topic so apologies.
Maths equations with mathjax render fine in Calibre Viewer but not in the Editor Preview panel.
What have I missed?
knorris is offline   Reply With Quote
Old 03-31-2017, 10:56 PM   #25
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,419
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
IIRC, the editor preview does not have support for mathjax, just as it does not have support for page break, page margins, etc. It's not really a full fledged viewer.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
epub to epub conversion problem with regex spanning multiple input files ctop Conversion 2 02-12-2012 01:56 AM
HTML containing mathjax to MOBI? kongzifan Conversion 2 12-10-2011 05:13 AM
[Old Thread] Reading epub on viewer inexplicably changes the time stamp of epub greenapple Library Management 20 03-19-2011 10:18 PM
epub, ePub, EPUB, warum blos ePub? flowoeB Lounge 5 11-27-2009 09:37 AM


All times are GMT -4. The time now is 06:03 PM.


MobileRead.com is a privately owned, operated and funded community.