200 points by c0d3_w4r10r 6 months ago flag hide 14 comments
swizec 6 months ago next
This is really cool! I've been looking for a way to embed Rust code snippets in my blog without having to worry about escaping characters and other issues. Rust Rocket seems like a solid option.
bob3574 6 months ago next
@swizec Thanks for sharing! I've been struggling with the same issue and I'm glad to see there's a solution. One question: how does Rust Rocket handle syntax highlighting? Does it work out of the box or do you need to set it up separately?
swizec 6 months ago next
@bob3574 It works out of the box with some popular PPs, but you might need to do some tinkering if you want to use something specific. I just use a simple syntax highlighter that's built into the blogging platform I'm using.
sarah120 6 months ago next
@swizec Thanks for the info! I'll have to give Rust Rocket a try and see how it works for me. Do you have any examples of blog posts where you've embedded Rust code using Rust Rocket that you could share?
swizec 6 months ago next
@sarah120 Sure! Unfortunately, I can't link to them directly here, but if you Google my name and the phrase "Rust Rocket", you should be able to find a few examples of blog posts that use Rust Rocket to embed Rust code. Let me know if you have any issues!
joe111 6 months ago prev next
This is really interesting. I've never heard of Rust Rocket before, but I'm intrigued. How does it handle code snippets when they're embedded in the middle of a paragraph? Does it automatically add the necessary HTML tags?
swizec 6 months ago next
@joe111 Yes, it handles code snippets in the middle of a paragraph automatically. It adds the necessary HTML tags to make sure the code is displayed correctly. I've found it to be very easy to use, even if you don't have a lot of experience with HTML.
joe111 6 months ago next
@swizec That's great to hear! I'm definitely going to give it a try the next time I need to embed some Rust code in my blog. Thanks for sharing!
annaguz 6 months ago prev next
I'm not a Rust programmer, but I'm interested in learning more about it. How does Rust Rocket compare to other options for embedding code snippets in a blog?
swizec 6 months ago next
@annaguz Rust Rocket is one of the newer options for embedding Rust code in a blog, but it seems to be gaining popularity quickly. It's user-friendly and has a lot of great features. However, if you want more control over the HTML and CSS, you might want to try some of the other options out there. It really depends on what you're looking for in a code-embedding solution.
annaguz 6 months ago next
@swizec Thanks for the advice! I'll take a closer look at Rust Rocket and see if it's the right solution for me. If not, I might try some of the other options you mentioned.
cd56 6 months ago prev next
I'm not sure if this is the right place to ask, but I'm having some issues with Rust Rocket. I've installed it and I've followed the instructions, but when I try to embed code in my blog, it doesn't work. Do you know what I might be doing wrong?
swizec 6 months ago next
@cd56 I'm sorry to hear that you're having issues. It's difficult to say without more information, but it's possible that you might have missed a step when installing Rust Rocket. I recommend double-checking the installation instructions and making sure you've installed all the necessary dependencies. If you're still having issues, you might want to check the Rust Rocket documentation or try searching for solutions on the Rust forums.
cd56 6 months ago next
@swizec Thanks for the advice. I'll double-check the installation instructions and see if that helps. If not, I'll check the documentation and see if I can find a solution there. Appreciate your help!