Here is sample of embedding highlighted code stored at GitHub gist
Source xml:
XQuery to be run:
Resulting in following elements:
How to do this
- Go to https://gist.github.com/
- Fill in the fields
- Short description of the code (not required)
- file name - extension of the file will determine the language. I guess using filename extemsions from Pygments lexers is what would help in case you are in doubt.
- copy paste the code into edit window or use Add another file... to upload the file
- Click "Create Public Gist".
This shows new page with some header and highlighted code - Find the link "embed" on the page and click it.
It shows short html snippet with content like:
<script src="https://gist.github.com/1090934.js"> </script>
- In your blog entry change to html editing and copy paste this snippet in there
- Preview the entry
Note, that it can take few seconds, till the content is rendered, as it has to be downloaded from another web page.
That is all.
If you have account at github, you can log in before you create the sample code and this allows you to have your name with it, edit the content and release new versions (did not test) and even keep discussion about it at Github website.
Small details to be aware of
- The code itself does not live in your blog entry, but elsewhere. This way googling will not point to your entry in blog, but possibly in the Github Gist. At least this is what I assume as I am not aware of robots fetching dynamically created content (I can be wrong).
- Your blog entry is dependent on github.
I am sure, one can live happily with this.
This comment has been removed by the author.
ReplyDelete