Skip to content
Browse files

Merge pull request #6 from kashif-umair/chore/update_readme

Chore/update readme
  • Loading branch information...
2 parents 85ee074 + 779825d commit ca54b20de4bd51496113e4cdc87251749eb3ef2b @kashif-umair committed
Showing with 24 additions and 10 deletions.
  1. +23 −8
  2. +1 −2 gist-embed.js
@@ -1,16 +1,31 @@
##How to use gist-embed to spice up code snippets on your blog
-### Include jQuery:
+### Include jQuery and gist-embed:
- <script type="text/javascript" src=""></script>
-### Include gist-embed (If your blog doesn't accept local file includes, then simply copy paste the contents into a script tag):
+ You should include them in your HEAD tag for better performance
- <script type="text/javascript" src="gist-embed.js"></script>
+ <script type="text/javascript" src=""></script>
+ <script type="text/javascript" src=""></script>
### Add a code element to your page with an id attribute in the following format:
- e.g.:
- <code id="gist-1741"></code>
- <code id="gist-4147951" data-file="file1.txt"></code>
+### To embed the whole gist you should put this code element in your body where ever you want it to be displayed.
+ <code id="gist-4672365"></code>
+### To embed a single file from gist, add the data-file attribute to your code element like this.
+ <code id="gist-4672365" data-file=""></code>
+### To embed a single line of a file from gist, add the data-line attribute to your code element like this.
+ <code id="gist-4672365" data-file="" data-line="5"></code>
+ This will embed only line number 5.
+### To embed multiple lines of a file from gist, change the data-line attribute's value to something like MS Word printing page ranges. e.g.
+ <code id="gist-4672365" data-file="" data-line="2-5,10-14,11,20"></code>
+ This will embed line numbers 2,3,4,5,10,11,12,13,14,11,20 in the same order. If lines are duplicated then they will be duplicated in code too.
+#### If you are embedding multiple lines then make sure about following points.
+ - You can put a range like "2-5", or single line numbers separated with commas like "11,20", or mix of both like "2-5,11,10-14,20"
+ - Spaces are not allowed in data-line value
+#### Follow the above instructions to avoid getting any undesired results.
3 gist-embed.js
@@ -60,7 +60,6 @@ $(function(){
var lineNumbers = getLineNumbers(line);
$('#' + random).find('.line').each(function(index){
if(($.inArray(index + 1, lineNumbers)) == -1){
@@ -113,4 +112,4 @@ function getLineNumbers(lineRangeString){
return lineNumbers;

0 comments on commit ca54b20

Please sign in to comment.
Something went wrong with that request. Please try again.