From fded70e68cfb40a67426d60ca20975d64144ba2e Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Wed, 13 Mar 2013 20:18:08 -0400 Subject: [PATCH] removing pygments --- site/app.hy | 3 -- site/pygments_extension.py | 81 -------------------------------------- site/templates/repl.html | 2 +- 3 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 site/pygments_extension.py diff --git a/site/app.hy b/site/app.hy index ec07637..c72b76b 100644 --- a/site/app.hy +++ b/site/app.hy @@ -4,8 +4,6 @@ (import-from flask Flask render-template request make-response) -(import-from pygments-extension PygmentsExtension) - (import-from hy.errors HyError) (import-from hy.lex LexException) (import-from hy.importer import_string_to_ast) @@ -15,7 +13,6 @@ (def app (Flask "__main__")) ; long story, needed hack -(.add_extension app.jinja_env PygmentsExtension) (defn hy-to-py [hython] diff --git a/site/pygments_extension.py b/site/pygments_extension.py deleted file mode 100644 index 1e9d497..0000000 --- a/site/pygments_extension.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) 2011 Larry Myers -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - - -from jinja2 import nodes -from jinja2.ext import Extension - -from pygments import highlight -from pygments.formatters import HtmlFormatter -from pygments.lexers import guess_lexer, get_lexer_by_name - - -class PygmentsExtension(Extension): - """ - A Pygments extension for use with the Jinja2 template language. - - Setup: - - import PygmentsExtension - from jinja2 import Environment - - jinja2_env = Environment(extensions=[PygmentsExtension]) - - Usage: - - {% code 'javascript' %} - function foo() { console.log('bar'); } - {% endcode %} - """ - tags = set(['code']) - - def __init__(self, environment): - super(PygmentsExtension, self).__init__(environment) - - # add the defaults to the environment - environment.extend( - pygments=self - ) - - def parse(self, parser): - lineno = parser.stream.next().lineno - - args = [] - lang_type = parser.parse_expression() - - if lang_type is not None: - args.append(lang_type) - - body = parser.parse_statements(['name:endcode'], drop_needle=True) - - return nodes.CallBlock(self.call_method('_pygmentize', args), - [], [], body).set_lineno(lineno) - - def _pygmentize(self, lang_type, caller): - lexer = None - formatter = HtmlFormatter() - content = caller() - - if lang_type is None: - lexer = guess_lexer(content) - else: - lexer = get_lexer_by_name(lang_type) - - return highlight(content, lexer, formatter) diff --git a/site/templates/repl.html b/site/templates/repl.html index 72181bb..0d55e46 100644 --- a/site/templates/repl.html +++ b/site/templates/repl.html @@ -14,7 +14,7 @@ {% endblock %} -{% block content %}{#{% autoescape off %}{% code "clojure" %} (print "foo bar") {% endcode %}{% endautoescape %}#} +{% block content %}