• Home
  • API Documentation
  • wte.text_formatter

wte.text_formatter¶

This module contains functions for formatting the instruction texts shown to the student.

class wte.text_formatter.HTMLLineNumbersTranslator(document)[source]¶

The HTMLLineNumbersTranslator extends the html4css1.HTMLTranslator, outputting source line numbers for all nodes that have one.

starttag(node, tagname, suffix='\n', empty=False, **attributes)[source]¶

Construct and return a start tag given a node (id & class attributes are extracted), tag name, and optional attributes.

wte.text_formatter.compile_rst(text, request, part=None, line_numbers=False)[source]¶

Compiles the given ReStructuredText into HTML. Returns only the actual content of the generated HTML document, without headers or footers.

Parameters:
  • text (unicode) – The ReST to compile
  • line_numbers (boolean) – Whether to generate a “data-source-ln” attribute with source line-numbers (default: false)
Returns:

The body content of the generated HTML

Return_type:

unicode

wte.text_formatter.init(settings)[source]¶

Initialise the module and all docutils extensions.

  • wte.scripts.timed_tasks – Script to run timed tasks
  • wte.text_formatter.docutils_ext