Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for web assembly output #52

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

vicapow
Copy link

@vicapow vicapow commented Nov 19, 2024

  • Setup a workspace to have multiple projects, like tex-fmt, tex-fmt-lib and tex-fmt-wasm.
  • Pull out the main functionality in main, to a library, and just have the main binary call the library.
  • Make some changes to ensure cross compilation works, like:
    • usingweb_time::Instant instead of std::time::Instant.
    • change init() to try_init() on env_logger::Builder from logging.rs because in JS we'll be calling the main function, multiple times.
    • Adding the ability to provide the input and output as strings instead of stdin, or from files.
  • I'm sorry, I think some of the tests are failing now, but I don't really understand the output. Could I get some help? I did try running the binary and it seems to work the same after this change. (it seems like it's something about the logging mechanism that might have changed.)

To test things out, I published the module to @vicapow/tex-fmt-wasm if anyone wants to try it out. You need to include it in a client side javascript file and also call the init method as required by wasm-pack. ie.,

import runTexFmtInit, { run_tex_fmt } from "@vicapow/tex-fmt-wasm";

// some place later...
await runTexFmtInit();
// even laterer...
let result = run_tex_fmt(value);
console.log(result.code);
console.log(result.output);

You can also play with it live at https://crixet.com by right clicking and selecting "Format Latex Document" (or watch the demo here: https://x.com/vicapow/status/1858735708758044963)

@WGUNDERWOOD
Copy link
Owner

WGUNDERWOOD commented Nov 24, 2024

Thanks for working on this! I will try to understand this better soon when I have some time. I'll see if I can fix the tests too. Could you ensure everything is formatted with rustfmt and then rebase this onto the develop branch?

@vicapow vicapow changed the base branch from main to develop November 27, 2024 05:24
@vicapow
Copy link
Author

vicapow commented Nov 27, 2024

You got it! And thank YOU for creating an awesome project.

okay, I think I successfully changed the base to be develop and ran rustfmt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants