I really love the function on the github’s code box, especially the ’embed’ and ‘raw’ function.I am curious about how to implement a code box like that.(Not the code highlight,just the ’embed’ and ‘raw’ function)
Have you every seen any plugins or some other thing can make that?
Thank you.
Here is how they do it: they have the raw file on their server, so when you click raw, it just executes the following script
For the ’embed’ functionality, what they do is they have the code again, and on the server, they convert the code to html with classes added for syntax highlighting. In the script that they give you, the just document.write out the link to the stylesheet and then document.write out the HTML. I have taken a look at the script for the ruby code, here it is:
I deleted a lot of the HTML to shorten the code, but that’s the idea.