fenjalien / obsidian-typst

Renders typst code blocks in Obsidian into images using Typst through the power of WASM!
Apache License 2.0
337 stars 16 forks source link

Feature Request: Disable Math Block Override in a File #4

Open ftiasch opened 1 year ago

ftiasch commented 1 year ago

I already had lots of files in my Obsidian vault written with LaTeX syntax, and I am going to apply typst syntax in my newly created file.

However, doing so makes many my old files unreadable. Could you please use a piece of special meta data to determine whether to enable/disable math block override in the file?

fenjalien commented 1 year ago

I guess something can be set in the front matter to override the override? I'll have a look into it :)

ftiasch commented 1 year ago

@fenjalien Cool! Having something in the front matter should make the transition process smooth.

fenjalien commented 1 year ago

sooo after having a look into this I'm afraid its not exactly possible. Currently the function Obsidian calls to render math is overidden. That function only takes the source and whether or not its a block, there is no information on where or which file its used in. So if theres some information in the frontmatter describing the correct behaviour, there is no easy way to check it.

It might be possible to say which ever is the active file is where the math will be rendered, but this would cause any other files rendering math to have the same settings as the active. This could occur when you hover over a link for a preview or you use split screen for multiple files.

That being said it could still be implemented with a warning that it only properly works as intended with only one file being rendered at once.

ftiasch commented 1 year ago

Thanks for your explanation! Then I assume it's OK to postpone until Obsidian provides corresponding API or simply reject my request (

fenjalien commented 1 year ago

The API change is unlikely to happen without alot of people asking. Tbh the way I've done it is really hacky and not recommended. I wouldn't mind doing this with a BIG disclaimer attached as I do understand the issue.

teoc98 commented 4 months ago

@ftiasch I've just started using this plugin. I have the same problem, and after seeing this open issue I solved it by not enabling the math block override, and whenever I need to format a math block I use another plugin (typing-transformer-obsidian) to insert

```typst
$  $
```

with a keyboard shortcut.