obsidian-tikzjax icon indicating copy to clipboard operation
obsidian-tikzjax copied to clipboard

[Question] Building Obsidian TikZJax

Open iamrecursion opened this issue 3 years ago • 12 comments

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!

iamrecursion avatar Jun 19 '22 21:06 iamrecursion

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:

  • The person I forked TikZJax from wrote some build instructions for TikZJax you can find here. However, you can skip the entire section involving web2js and just use the core.dump.gz and tex.wasm.gz files that I've already gone and generated myself. You can grab those from a previous version of this repo

  • Before every build, genTexFiles.js is run which pulls in all the files listed in tex_files.json for embedding into TikZJax. However, this might lead to issues if we're running different TeX distributions/versions and it pulls in different versions of files which might be incompatible with my particular core.dump and tex.wasm. (Further, I haven't listed some package files in tex_files.json due to some awkward issues, like only an older version of chemfig working! So I instead manually copied the chemfig files to the tex_files folder for embedding. But these won't be picked up by genTexFiles.js.) 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.

  • In the dist folder, you'll also see a fonts.css has been produced. You can ignore this as it doesn't change between builds and I've already embedded it into Obsidian TikZJax

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! :)

artisticat1 avatar Jun 20 '22 09:06 artisticat1

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.

iamrecursion avatar Jun 20 '22 12:06 iamrecursion

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 👍

artisticat1 avatar Jun 21 '22 11:06 artisticat1

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!

iamrecursion avatar Jun 22 '22 13:06 iamrecursion

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 (:

artisticat1 avatar Jun 25 '22 17:06 artisticat1

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

iamrecursion avatar Jun 26 '22 01:06 iamrecursion

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.

iamrecursion avatar Jun 26 '22 03:06 iamrecursion

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

artisticat1 avatar Jun 26 '22 16:06 artisticat1

I can PR it if that's easier?

iamrecursion avatar Jun 26 '22 16:06 iamrecursion

That'd work too :)

artisticat1 avatar Jun 26 '22 16:06 artisticat1

Done here!

iamrecursion avatar Jun 26 '22 17:06 iamrecursion

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

mayurankv avatar Feb 23 '24 16:02 mayurankv