@environmentfilter
def restructuredtext(env, value):
 try:
  from docutils.core import publish_parts
 except ImportError:
  logger.error(u'Cannot load the docutils library.')
  raise TemplateError(u'Cannot load the docutils library.')
 highlight_source = False
 if hasattr(env.config, 'restructuredtext'):
  highlight_source = getattr(env.config.restructuredtext, 'highlight_source', False)
  extensions = getattr(env.config.restructuredtext, 'extensions', [])
  import imp
  for extension in extensions:
   imp.load_module(extension, *imp.find_module(extension))
 if highlight_source:
  import hyde.lib.pygments.rst_directive
 parts = publish_parts(source=value, writer_name='html')
 return parts['html_body']

@ environmentfilter def restructuredtext ( env , value ) : try : from docutils . core import publish_parts except ImportError : logger . error ( u'Cannot load the docutils library.' ) raise TemplateError ( u'Cannot load the docutils library.' ) highlight_source = False if hasattr ( env . config , 'restructuredtext' ) : highlight_source = getattr ( env . config . restructuredtext , 'highlight_source' , False ) extensions = getattr ( env . config . restructuredtext , 'extensions' , [ ] ) import imp for extension in extensions : imp . load_module ( extension , * imp . find_module ( extension ) ) if highlight_source : import hyde . lib . pygments . rst_directive parts = publish_parts ( source = value , writer_name = 'html' ) return parts [ 'html_body' ]
restructuredtext processing with optionnally custom settings .