gtg922r / obsidian-numerals

An obsidian plugin which turns a math code block into a full featured calculator
Other
391 stars 8 forks source link

Line-breaks in formats other than "math" #12

Closed Ra0R closed 1 year ago

Ra0R commented 1 year ago

In "math" format line breaks are done as expected:

image

For "math-highlight" or "math-tex" we get this: image

Should probably be possible to set a width for the other formats aswell.

gtg922r commented 1 year ago

Thanks, I can reproduce this for math-tex. I'll have to give some thought how to handle it.

I can not reproduce this for math-highlight - are you sure that is affected as well?

Interestingly if you have a long line of mathjax in base obsidian using $$ it overflows the margins too.

Will have to experiment a bit.

gtg922r commented 1 year ago

It doesn't seem to be as straightforward as I hoped with some simple CSS fixes. Also the underlying Mathjax does not currently support automatic line break which would make this much easier. Will have to keep thinking abou tit

Ra0R commented 1 year ago

Yes the issue seems to be present also for math-highlight: image

The markdown is used:

```math-highlight
# Points
points = 8pt + 9.8pt + 4pt + 6.6pt + 7.5pt + 5.5pt + 10pt

# Average
avg = points / 7
\`\`\`

I did not look at the plugin code (and don't know much about Obsidian under the hood either). But MathJax seems to support rendering as HTML or SVG, could you not simply force the output to not overlapp the right-hand result pane? (E.g. in HTML by using something like max-width: 70%.

gtg922r commented 1 year ago

Ahh, I was checking reader mode. I'm able to repro the math-highlight bug in live preview as well. Thanks, looking in to it

gtg922r commented 1 year ago

Still broken for TeX, which might be harder to fix

gtg922r commented 1 year ago

There doesn't seem to be a straightforward solution to getting around the lack of MathJax support in v3 for automatic line breaks (I tried max width, forcing word-break, etc).

It looks like Release MathJax v4.0.0-alpha.1 does incorporate automatic line breaking. Once that gets pushed out, hopefully the devs will incorporate it in Obsidian, which should then fix it for Numerals.

Going to mark this as won't fix. If its still broken if/when MathJax v4 is incorporated and Obsidian supports automatic line breaks natively, then can re-open

gtg922r commented 1 year ago

For future reference, see this obsidian bug report: Latex math newline line break \ - Bug reports - Obsidian Forum