MathJax-src icon indicating copy to clipboard operation
MathJax-src copied to clipboard

Linebreaks

Open dpvc opened this issue 2 years ago • 4 comments

This PR is implements both explicit and automatic line breaking in display equations, plus browser-based line breaking for inline expressions. Tables are now broken in a more meaningful way (but this will probably need more testing), taking the sizes of the various columns into account.

It also adds a number of macros to allow line breaking control from within TeX expressions. These include: \vtop and \vbox to aligning multi-line expressions at the top or bottom line (along with the already available \vcenter for centering an expression), \hsize=dimen for setting the width of one of the previous three boxes (or the math expression as a whole), and \break, \nobreak, \goodbreak, \badbreak, and \allowbreak macros, plus \* for discretionary multiplication. The array environment column preamble now includes the declarations from the array.sty package, including p{...}, m{...}, b{...}, w{...}{...}, >{...}, <{...}, @{...}, and !{...}, plus non-standard P{...}, M{...}, and B{...} for math-mode versions of the lower-case forms, along with \newcolumntype for declaring new column types. A new indentalign environment allows the setting of indentshift and indentalign values from within TeX.

Finally, it implements the scroll, scale, and truncate values for the overflow attribute of the <math> tag, in addition to linebreak, and also adds a contextual menu item to control the default overflow value, plus one to control in-line line-breaking separately.

This PR touches a large number of files, including most of the output files. An important change to the toCHTML() and toSVG() functions are that their arguments are now an array of DOM nodes rather than a single one, with the array consisting of one DOM element for each line over which the MathML node must be spread. The functions for things like borders, backgrounds, hrefs, and similar have been updated to handle multiple lines. There is also a subclass of BBox for the bounding boxes for the individual lines that includes the indent values for the breakpoint, among other things.

The automatic linebreaking is controlled by a LinebreakVisitor that can be subclassed and replaced in order to try out other breaking algorithms.

dpvc avatar Jun 10 '22 00:06 dpvc

FYI this branch now has merge conflicts with develop.

pkra avatar Aug 23 '22 14:08 pkra

FYI this branch now has merge conflicts with develop.

Trying to resolve them locally seems straightforward. But then typescript has 9 errors in 4 files.

pkra avatar Aug 23 '22 14:08 pkra

OK, I resolved the conflicts and updated the HtmlNode files that were causing the typescript problems (the linebreaks branch changed the parameters to toSVG and toCHTML, and those files weren't part of the branch from which linebreaks was forked). It should compile now.

dpvc avatar Aug 23 '22 14:08 dpvc

I made good progress with this PR, but it would be good if you could talk me through some of the changes in the baseItem class in an online session

zorkow avatar Sep 05 '22 11:09 zorkow

Great PR.

Thanks! Sorry it is so big, and I appreciate your reviewing it.

I've fixed the issues you have identified, and pushed a new commit. I also commented on the questions that you raised.

Can you check whether this is now acceptable?

The only file I might need to look at again is LinebreakVisitor as I am a bit overwhelmed.

Do you need to look into that again?

dpvc avatar Jan 25 '23 17:01 dpvc