<s> import logging <EOL> import os <EOL> from pyjade import Compiler as _Compiler , Parser , register_filter <EOL> from pyjade . runtime import attrs <EOL> from pyjade . exceptions import CurrentlyNotSupported <EOL> from pyjade . utils import process <EOL> from django . conf import settings <EOL> class Compiler ( _Compiler ) : <EOL> autocloseCode = '<STR_LIT>' . split ( '<STR_LIT:U+002C>' ) <EOL> useRuntime = True <EOL> def __init__ ( self , node , ** options ) : <EOL> if settings . configured : <EOL> options . update ( getattr ( settings , '<STR_LIT>' , { } ) ) <EOL> super ( Compiler , self ) . __init__ ( node , ** options ) <EOL> def visitCodeBlock ( self , block ) : <EOL> self . buffer ( '<STR_LIT>' % block . name ) <EOL> if block . mode == '<STR_LIT>' : self . buffer ( '<STR_LIT>' ) <EOL> self . visitBlock ( block ) <EOL> if block . mode == '<STR_LIT>' : self . buffer ( '<STR_LIT>' ) <EOL> self . buffer ( '<STR_LIT>' ) <EOL> def visitAssignment ( self , assignment ) : <EOL> self . buffer ( '<STR_LIT>' % ( assignment . name , assignment . val ) ) <EOL> def visitMixin ( self , mixin ) : <EOL> self . mixing += <NUM_LIT:1> <EOL> if not mixin . call : <EOL> self . buffer ( '<STR_LIT>' % ( mixin . name , mixin . args ) ) <EOL> self . visitBlock ( mixin . block ) <EOL> self . buffer ( '<STR_LIT>' ) <EOL> elif mixin . block : <EOL> raise CurrentlyNotSupported ( "<STR_LIT>" ) <EOL> else : <EOL> self . buffer ( '<STR_LIT>' % ( mixin . name , mixin . args ) ) <EOL> self . mixing -= <NUM_LIT:1> <EOL> def visitCode ( self , code ) : <EOL> if code . buffer : <EOL> val = code . val . lstrip ( ) <EOL> self . buf . append ( '<STR_LIT>' % ( val , '<STR_LIT>' if code . escape else '<STR_LIT>' ) ) <EOL> else : <EOL> self . buf . append ( '<STR_LIT>' % code . val ) <EOL> if code . block : <EOL> self . visit ( code . block ) <EOL> if not code . buffer : <EOL> codeTag = code . val . strip ( ) . split ( '<STR_LIT:U+0020>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> if codeTag in self . autocloseCode : <EOL> self . buf . append ( '<STR_LIT>' % codeTag ) <EOL> def attributes ( self , attrs ) : <EOL> return "<STR_LIT>" % attrs <EOL> from django import template <EOL> template . add_to_builtins ( '<STR_LIT>' ) <EOL> from django . utils . translation import trans_real <EOL> def decorate_templatize ( func ) : <EOL> def templatize ( src , origin = None ) : <EOL> html = process ( src , compiler = Compiler ) <EOL> return func ( html , origin ) <EOL> return templatize <EOL> trans_real . templatize = decorate_templatize ( trans_real . templatize ) <EOL> try : <EOL> from django . contrib . markup . templatetags . markup import markdown <EOL> @ register_filter ( '<STR_LIT>' ) <EOL> def markdown_filter ( x , y ) : <EOL> return markdown ( x ) <EOL> except ImportError : <EOL> pass </s>
