forked from robertkrimen/gist-it
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add highlight option (prettify, deferred-prettify)
- Loading branch information
1 parent
c1db146
commit 1f52a01
Showing
6 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
{% if gist.highlight == 'prettify' %} | ||
if ( 'prettyPrint' in window ) {} else { | ||
document.write( '<script type="text/javascript" src="{{ base }}/assets/prettify/prettify.js"></script>' ); | ||
} | ||
{% endif %} | ||
{% if gist.style != '0' %} | ||
document.write( '<link rel="stylesheet" href="{{ base }}/assets/embed.css"/>' ); | ||
{% endif %} | ||
{% if gist.highlight == 'prettify' %} | ||
document.write( '<link rel="stylesheet" href="{{ base }}/assets/prettify/prettify.css"/>' ); | ||
{% endif %} | ||
document.write( '{{ gist_html.encode( 'string_escape' ) }}' ); | ||
{% if gist.highlight == 'prettify' %} | ||
document.write( '<script type="text/javascript">prettyPrint();</script>' ); | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
# vim: ft=python: | ||
import random | ||
import unittest2 | ||
import sys; | ||
import os; | ||
|
||
sys.path.append( os.path.join( sys.path[0], ".." ) ) | ||
import gist_it | ||
|
||
class t( unittest2.TestCase ): | ||
def runTest( self ): | ||
self.assertEqual( gist_it.parse_highlight( 0 ), '0' ) | ||
self.assertEqual( gist_it.parse_highlight( '0' ), '0' ) | ||
self.assertEqual( gist_it.parse_highlight( False ), '0' ) | ||
self.assertEqual( gist_it.parse_highlight( True ), 'prettify' ) | ||
self.assertEqual( gist_it.parse_highlight( None ), 'prettify' ) | ||
self.assertEqual( gist_it.parse_highlight( ' 1' ), 'prettify' ) | ||
self.assertEqual( gist_it.parse_highlight( 'yes ' ), 'prettify' ) | ||
self.assertEqual( gist_it.parse_highlight( ' no' ), '0' ) | ||
self.assertEqual( gist_it.parse_highlight( 'none ' ), '0' ) | ||
self.assertEqual( gist_it.parse_highlight( 'deferred-prettify' ), 'deferred-prettify' ) | ||
|
||
if __name__ == '__main__': | ||
unittest2.main() |