Skip to content

Is it possible to embed a small wasm app in an mdbook? #1780

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

Closed
max-sixty opened this issue Apr 5, 2022 · 3 comments
Closed

Is it possible to embed a small wasm app in an mdbook? #1780

max-sixty opened this issue Apr 5, 2022 · 3 comments

Comments

@max-sixty
Copy link
Contributor

Firstly thanks for building such a wonderful library!

I'm hoping to include a small wasm app in an mdbook. I have some rust experience but very little web experience.

I'm including this snippet in an md page, which was build by trunk:

<script type="module">import init from './dist/index-aa17a837077bf43a.js';init('./dist/index-aa17a837077bf43a_bg.wasm');</script></body></html>

This almost works — initially the normal md page appears, and then a moment later the wasm app appears. But the wasm app fills the whole screen — there's no sidebar remaining.

Possibly this question could be reduced to "embed an HTML page within an mdbook", and the wasm aspect is tangential? If so, has anyone succeeded at this? It seems related to #773.

Thank you

@ehuss
Copy link
Contributor

ehuss commented Apr 5, 2022

This sounds like more of a web-development question. My understanding is that WASM just provides a means to call functions, not unlike javascript, there's nothing fundamental about it taking control of the page. Your WASM app would need to know where and how to manipulate the existing DOM. You could also investigate something like iframe, but that can have its own issues.

I also notice you have </body></html> which seems a bit unusual.

I doubt you'll be able to find much help for general web development here. I might suggest trying to find some forum or site where you can ask questions of that nature.

@max-sixty
Copy link
Contributor Author

Thanks @ehuss . I'll close this.

It sounds like this was accurate:

Possibly this question could be reduced to "embed an HTML page within an mdbook", and the wasm aspect is tangential? If so, has anyone succeeded at this?

...and possible even more reduced to "embed an HTML page within another". Though if anyone has done this successfully in an mdbook, I'd be grateful to learn how.

@max-sixty
Copy link
Contributor Author

If any future travelers have a similar need — I eventually got this working. I'm sure there are more elegant approaches! https://lang.prql.builders/editor.html
https://github.com/max-sixty/prql/pull/312,
image

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

No branches or pull requests

2 participants