artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes
MIT License
357 stars 18 forks source link

[Question] Building Obsidian TikZJax #8

Open iamrecursion opened 2 years ago

iamrecursion commented 2 years ago

Rightyo! I'm starting to have a look at #4 whilst also keeping an eye out for a resurgence of #7, and I'm wondering what your development workflow is like.

In particular, I'm interested in what's required to build and use an updated version of your TikZJax fork in the plugin, as well as how you tend to work whilst developing changes to the plugin directly! I've been poking at the output-single-file branch in your TikZJax fork, and I'm assuming that it's as simple as npm run devbuild or npm run build for building with any changes there, but I'm a bit confused as to how I then integrate changes with the Obsidian plugin!

I'm very happy to write whatever tips you can give me into a little dev guide for the repo (CONTRIBUTING.md or whatever you feel is suitable) if that's helpful!

artisticat1 commented 2 years ago

I'm assuming that it's as simple as npm run devbuild or npm run build for building with any changes there, but I'm a bit confused as to how I then integrate changes with the Obsidian plugin!

Yup! Running either of those commands produces a folder, dist, containing tikzjax.js. You then copy tikzjax.js to the obsidian-tikzjax folder. Then you can build the plugin like any other Obsidian plugin using npm run dev.

Some notes:

I'm very happy to write whatever tips you can give me into a little dev guide for the repo (CONTRIBUTING.md or whatever you feel is suitable) if that's helpful!

Yeah, that'd be useful! :)

iamrecursion commented 2 years ago

Yup! Running either of those commands produces a folder, dist, containing tikzjax.js. You then copy tikzjax.js to the obsidian-tikzjax folder. Then you can build the plugin like any other Obsidian plugin using npm run dev.

Makes sense. I was wondering if there was any automated integration but couldn't find any!

You can grab those from a previous version of this repo

Can I ask what the reasoning is behind the removal of these files in the current state of the repo?

So, it might be best if you used copies of my tex files? I can provide those here if you want. Or I could commit them to the TikZJax repo.

It would make sense to me to commit them to the repo (potentially as LFS files depending on size). Getting these builds as reproducible as possible makes the most sense to me at this stage, and relying on individual TeX distributions seems...risky.

Yeah, that'd be useful! :)

Will do! I'll probably post the WIP guide here so I can get your feedback before PRing it! I wanna make sure I've understood everything correctly.

artisticat1 commented 2 years ago

Makes sense. I was wondering if there was any automated integration but couldn't find any!

Ah yeah, thankfully copying a single file over isn't too bad. Maybe you could set webpack to output directly to the obsidian-tikzjax folder though!

Can I ask what the reasoning is behind the removal of these files in the current state of the repo?

Previously, the TikZjax files were stored in the repo to make them available for fetching via jsdelivr. With #3, the core.dump.gz and tex.wasm.gz files are embedded directly in tikzjax.js, and no longer need to be fetched from a CDN. So we no longer need to store them (or any of the contents of the old dist folder) in the repo.

It would make sense to me to commit them to the repo (potentially as LFS files depending on size). Getting these builds as reproducible as possible makes the most sense to me at this stage, and relying on individual TeX distributions seems...risky.

Done! With that, you can remove the npm run gen-tex-files command from the build scripts in package.json (so the tex_files don't get overwritten whenever you run a build).

Will do! I'll probably post the WIP guide here so I can get your feedback before PRing it! I wanna make sure I've understood everything correctly.

Sounds good 👍

iamrecursion commented 2 years ago

Ah yeah, thankfully copying a single file over isn't too bad. Maybe you could set webpack to output directly to the obsidian-tikzjax folder though!

Yeah it's definitely not too painful!

Previously, the TikZjax files were stored in the repo to make them available for fetching via jsdelivr. With #3, the core.dump.gz and tex.wasm.gz files are embedded directly in tikzjax.js, and no longer need to be fetched from a CDN. So we no longer need to store them (or any of the contents of the old dist folder) in the repo.

Makes sense. With all that said, though, for consistency it makes sense to me for them to be committed to the tikzjax repo so that builds can be reproducible there. Would you be up for doing that?

Done! With that, you can remove the npm run gen-tex-files command from the build scripts in package.json (so the tex_files don't get overwritten whenever you run a build).

Sounds great!

artisticat1 commented 2 years ago

Makes sense. With all that said, though, for consistency it makes sense to me for them to be committed to the tikzjax repo so that builds can be reproducible there. Would you be up for doing that?

Good idea! I've done that now (:

iamrecursion commented 2 years ago

Perfect, thank you so much! I'll try and write up some building instructions in the next few days!

iamrecursion commented 2 years ago

Actually, a question. Would it make sense to remove the npm run gen-tex-files from the repo as well? If the assumption is that people should use the provided tex files, only those that know what they're doing should then run that.

artisticat1 commented 2 years ago

Yes, you're right! I'll go ahead and do that when I get the chance.

iamrecursion commented 2 years ago

I can PR it if that's easier?

artisticat1 commented 2 years ago

That'd work too :)

iamrecursion commented 2 years ago

Done here!

mayurankv commented 4 months ago

I'm also interested in potentially making some FRs to this plugin, was any progress made on a CONTRIBUTING doc?