Open YonatanRubin opened 8 months ago
I can't reproduce this with the ObsidianRTL plugin. Are you sure you're getting an error with that one?
The DynamicRTL plugin seems to be deprecated.
yes. I recreated it now in a new vault having only obsidian-rtl and typst-renderer. I used the following file to check if the direction matters, and got it even when the page was set to ltr (which is weird because it is the first time it behaved like this that I have seen)
test for only ltr in my code.
a few lines
inline $f_x (t) = integral_0^oo e^(k/2) d t$
block :
$$f_x (t) = integral_0^oo e^(k/2) d t$$
multiline block:
$$f_x (t) = integral_0^oo e^(k/2) d t\
F'_x (t)=f_x (t)
$$
with your example I was able to reproduce it.
e.g. this is OK.
Lorem $Alpha$ ipsum.
Lorem $Beta$ ipsum.
but this will get an error.
Lorem $Alpha$ ipsum.
Lorem $Beta$ ipsum.
Obsidian recognises it as a single <p>
element and insert a <br>
line break. In this case obsidian-rtl creates a <div>
.
with obsidian-rtl enabled
with obsidian-rtl disabled
obsidian-rtl separates each element inside the <p>
element that contains a <br>
line break and creates a <div>
in each element.
the typst compiler is probably losing the reference of the element it is rendering.
To be honest, I don't know anything about Right-to-Left. The content inside each inline maths have to change position?
I can reproduce this as well, it looks like at some point the custom HTML element that renders the Typst source code gets reset or recreated. The error is from the source string being undefined
but still being read as a string. This shouldn't happen as it gets given the source code so I'm not entirely sure whats happening.
what do you mean by change position? if you mean change position in relation to the normal text then probably (since a line with n chars before the math block should position it either n pixels to the correct alignment). if you mean compared to itself then no, the math should be in the same direction orientation and position.
I can reproduce this as well, it looks like at some point the custom HTML element that renders the Typst source code gets reset or recreated. The error is from the source string being
undefined
but still being read as a string. This shouldn't happen as it gets given the source code so I'm not entirely sure whats happening.
I've been debugging for a while, and it seems to be a problem with the CustomElements
lifecycle.
obsidian-rtl modifies before draw, but after obsidian-typst creating the element.
In the TypstRenderElement
class the draw
method only has an idea of the fontSize
and this.size
because it is defined inside it, everything else that is passed in the .compile
is undefined
.
obsidian just added better rtl support, the obsidian rtl plugin no longer gives this error!
I am not sure if this plugin is the cause for the problem or the rtl plugin, but since this plugin shows the error I assume this one. while using either dynamic rtl or obsidian-rtl with the math block options on. writing math blocks seem to most of the time show the error "TypeError: Cannot read properties of undefined (reading 'length')" on some blocks, but only when in read mode. this issue persisted both on android and linux.
in edit mode:
in read mode:
after disabling the rtl plugin: