How to use the code-area in TRPL?


In TRPL, I can see many ‘code-area’ which can compile and is highlighted.
And I want to use that tool in my blog too?
So, how to?


The code area is implemented by mdbook frontend with hljs + ace.js editor and api on the backend side of things. While it is not provided in easily embeddable form at the moment it should be relatively painless to extract it.


OK, I’ll try it later.


I don’t really understand what I’m about to ask, so apologies if it sounds utterly stupid -

Since Rust can compile to WebASM now, and since rustc is bootstrapped, is it possible to use a WebASM rustc compiler for use cases such as OP that can be run entirely in the browser? I don’t like the idea of many sites relying on one central API.

If not it could be nice to do as you said and extract the compiler bits from TRPL site and allow people to run their own instance.


It’s fundamentally possible, but that doesn’t mean it works yet. Note that some parts of the standard library just panic, and rustc uses those parts, for example.