Package qm :: Module structured_text
[hide private]
[frames] | no frames]

Module structured_text
source code

Functions for parsing, processing, and formatting Python structured text.

See "Structured Text Formatting Rules":http://www.python.org/sigs/doc-sig/stext.html for more information.

Classes [hide private]
Formatter Interface for output formatters for the 'StructuredTextProcessor'.
TextFormatter Formatter for generating plain text from structured text.
HtmlFormatter Formatter for generating HTML from structured text.
StructuredTextProcessor Parser and formatter for Python structured text.

Functions [hide private]
  escape_html_entities(text)
Return 'text' with special characters converted to HTML entities.
  __format(text, formatter)
Process structured text 'text' with 'formatter'.
  to_html(structured_text)
Return 'structured_text' formatted as HTML.
  to_text(structured_text, width=78, indent=0)
Return 'structured_text' formatted as plain text.
  get_first(structured_text)
Return the first line of 'structured_text'.
  get_rest(structured_text)
Return the contents of 'structured_text' minus the first line.
  get_paragraphs(structured_text)
Split 'structured_text' into paragraphs.
  get_first_paragraph(structured_text)
Return the first paragraph of 'structured_text'.
  __entity_char_replacement(match, replacement_map={'\xa3': '&pound;', '\xa7': '&sect;', '\xab': '&laquo;', '\xaf': '&macr;', '\xb3': '&sup3;', '\xb7': '&middot;', '\xbb': '&raquo;', '<': '&lt;', '\xbf': '&iquest;', '\xc3': '&Atilde;', '\xc7': '&Ccedil;', '\xcb': '&Euml;', '\xcf': '&Iuml;', '\xd3': '&Oacute;', '\xd7': '&times;', '\xdb': '&Ucirc;', '\xdf': '&szlig;', '\xe3': '&atilde;', '\xe7': '&ccedil;', '\xeb': '&euml;', '\xef': '&iuml;', '\xf3': '&oacute;', '\xf7': '&divide;', '\xfb': '&ucirc;', '\xff': '&yuml;', '\xa0': '&nbsp;', '\xa4': '&curren;', '\xa8': '&uml;', '\xac': '&not;', '\xb0': '&deg;', '\xb4': '&acute;', '\xb8': '&cedil;', '\xbc': '&frac14;', '\xc0': '&Agrave;', '\xc4': '&Auml;', '\xc8': '&Egrave;', '\xcc': '&Igrave;', '\xd0': '&ETH;', '\xd4': '&Ocirc;', '\xd8': '&Oslash;', '\xdc': '&Uuml;', '\xe0': '&agrave;', '\xe4': '&auml;', '\xe8': '&egrave;', '\xec': '&igrave;', '\xf0': '&eth;', '\xf4': '&ocirc;', '\xf8': '&oslash;', '\xfc': '&uuml;', '\xa1': '&iexcl;', '"': '&quot;', '\xa5': '&yen;', '&': '&amp;', '\xa9': '&copy;', '\xad': '&shy;', '\xb1': '&plusmn;', '\xb5': '&micro;', '\xb9': '&sup1;', '\xbd': '&frac12;', '>': '&gt;', '\xc1': '&Aacute;', '\xc5': '&Aring;', '\xc9': '&Eacute;', '\xcd': '&Iacute;', '\xd1': '&Ntilde;', '\xd5': '&Otilde;', '\xd9': '&Ugrave;', '\xdd': '&Yacute;', '\xe1': '&aacute;', '\xe5': '&aring;', '\xe9': '&eacute;', '\xed': '&iacute;', '\xf1': '&ntilde;', '\xf5': '&otilde;', '\xf9': '&ugrave;', '\xfd': '&yacute;', '\xa2': '&cent;', '\xa6': '&brvbar;', '\xaa': '&ordf;', '\xae': '&reg;', '\xb2': '&sup2;', '\xb6': '&para;', '\xba': '&ordm;', '\xbe': '&frac34;', '\xc2': '&Acirc;', '\xc6': '&AElig;', '\xca': '&Ecirc;', '\xce': '&Icirc;', '\xd2': '&Ograve;', '\xd6': '&Ouml;', '\xda': '&Uacute;', '\xde': '&THORN;', '\xe2': '&acirc;', '\xe6': '&aelig;', '\xea': '&ecirc;', '\xee': '&icirc;', '\xf2': '&ograve;', '\xf6': '&ouml;', '\xfa': '&uacute;', '\xfe': '&thorn;'})

Variables [hide private]
html_help_text  
__entity_char_regex  
__paragraph_regexp  
_verbatim_regexp  
long_options  
formatter  
processor  
inputs  
character  
entity  

Function Details [hide private]

escape_html_entities(text)

source code 
Return 'text' with special characters converted to HTML entities.

__format(text, formatter)

source code 
Process structured text 'text' with 'formatter'.

to_html(structured_text)

source code 
Return 'structured_text' formatted as HTML.

to_text(structured_text, width=78, indent=0)

source code 

Return 'structured_text' formatted as plain text.

'width' -- The width of the text (including the indentation).

'indent' -- The width of the block indentation of the formatted output.

get_first(structured_text)

source code 

Return the first line of 'structured_text'.

By convention, the first line of a structured text description is a short summary.

get_rest(structured_text)

source code 
Return the contents of 'structured_text' minus the first line.

get_paragraphs(structured_text)

source code 

Split 'structured_text' into paragraphs.

'structured_text' -- A string consisting of structured text.

returns -- A sequence of pagraphs of structured text. Each element in the sequence corresponds to a successive pagraph in the 'structured_text'. If 'structured_text' is the empty string, the sequence returned will consist of a single paragraph, itself empty.

get_first_paragraph(structured_text)

source code 

Return the first paragraph of 'structured_text'.

'structured_text' -- A string consisting of structured text.

returns -- A string of structured text that is the first paragraph of the 'structured_text'.

__entity_char_replacement(match, replacement_map={'\xa3': '&pound;', '\xa7': '&sect;', '\xab': '&laquo;', '\xaf': '&macr;', '\xb3': '&sup3;', '\xb7': '&middot;', '\xbb': '&raquo;', '<': '&lt;', '\xbf': '&iquest;', '\xc3': '&Atilde;', '\xc7': '&Ccedil;', '\xcb': '&Euml;', '\xcf': '&Iuml;', '\xd3': '&Oacute;', '\xd7': '&times;', '\xdb': '&Ucirc;', '\xdf': '&szlig;', '\xe3': '&atilde;', '\xe7': '&ccedil;', '\xeb': '&euml;', '\xef': '&iuml;', '\xf3': '&oacute;', '\xf7': '&divide;', '\xfb': '&ucirc;', '\xff': '&yuml;', '\xa0': '&nbsp;', '\xa4': '&curren;', '\xa8': '&uml;', '\xac': '&not;', '\xb0': '&deg;', '\xb4': '&acute;', '\xb8': '&cedil;', '\xbc': '&frac14;', '\xc0': '&Agrave;', '\xc4': '&Auml;', '\xc8': '&Egrave;', '\xcc': '&Igrave;', '\xd0': '&ETH;', '\xd4': '&Ocirc;', '\xd8': '&Oslash;', '\xdc': '&Uuml;', '\xe0': '&agrave;', '\xe4': '&auml;', '\xe8': '&egrave;', '\xec': '&igrave;', '\xf0': '&eth;', '\xf4': '&ocirc;', '\xf8': '&oslash;', '\xfc': '&uuml;', '\xa1': '&iexcl;', '"': '&quot;', '\xa5': '&yen;', '&': '&amp;', '\xa9': '&copy;', '\xad': '&shy;', '\xb1': '&plusmn;', '\xb5': '&micro;', '\xb9': '&sup1;', '\xbd': '&frac12;', '>': '&gt;', '\xc1': '&Aacute;', '\xc5': '&Aring;', '\xc9': '&Eacute;', '\xcd': '&Iacute;', '\xd1': '&Ntilde;', '\xd5': '&Otilde;', '\xd9': '&Ugrave;', '\xdd': '&Yacute;', '\xe1': '&aacute;', '\xe5': '&aring;', '\xe9': '&eacute;', '\xed': '&iacute;', '\xf1': '&ntilde;', '\xf5': '&otilde;', '\xf9': '&ugrave;', '\xfd': '&yacute;', '\xa2': '&cent;', '\xa6': '&brvbar;', '\xaa': '&ordf;', '\xae': '&reg;', '\xb2': '&sup2;', '\xb6': '&para;', '\xba': '&ordm;', '\xbe': '&frac34;', '\xc2': '&Acirc;', '\xc6': '&AElig;', '\xca': '&Ecirc;', '\xce': '&Icirc;', '\xd2': '&Ograve;', '\xd6': '&Ouml;', '\xda': '&Uacute;', '\xde': '&THORN;', '\xe2': '&acirc;', '\xe6': '&aelig;', '\xea': '&ecirc;', '\xee': '&icirc;', '\xf2': '&ograve;', '\xf6': '&ouml;', '\xfa': '&uacute;', '\xfe': '&thorn;'})

source code 

Variables Details [hide private]

html_help_text

Value:
'''
<h4>Structured Text</h4>

<p>Structured text is a simple set of conventions for formatting
ordinary text.  Usually, you can simply type ordinary text where QM
expects structured text; the resulting output will be line-wrapped, wi\
th
paragraph breaks indicated by blank lines.</p>
...                                                                    
      

__entity_char_regex

Value:
[\u00e5>\u00a5\u00f2\u00c8\u00d1\u00dd\u00e6\u00e4\u00c2<\u00ce\u00f4\\
u00b8\u00ca\u00ac&\u00c6\u00f8\u00b4\u00ab\u00ad\u00cc\u00ae\u00d2\u00\
a0\u00c4\u00c3\u00d5\u00df\u00e0\u00d4\u00bc\u00e8\u00a1\u00bd\u00aa\u\
00dc\u00f1\u00de\u00ff\u00c9\u00ea\u00c5\u00be\u00d9\u00c0\u00f0\u00ef\
\u00f7\u00d6\u00ec\u00f5\u00d3\u00d0\u00b1\u00cb\u00b9\u00b2\u00b3\u00\
d8\u00c1\u00a2\u00eb\u00a6\u00ed\u00b6\u00b5\u00fc\u00ee\u00a9\u00cf\u\
00e7\u00db\u00b0\u00a3\u00a4\u00fb\u00f9\u00d7\u00e3"\u00da\u00bf\u00f\
d\u00fa\u00a7\u00af\u00c7\u00ba\u00e1\u00e9\u00b7\u00cd\u00a8\u00fe\u0\
...                                                                    
      

__paragraph_regexp

Value:
(?:\n *)+\n                                                            
      

_verbatim_regexp

Value:
('''.*''')(?:(?:\n *)+\n|\n?$)                                         
      

long_options

Value:
["html","text",]                                                       
      

formatter

Value:
TextFormatter()                                                        
      

processor

Value:
StructuredTextProcessor(formatter)                                     
      

inputs

Value:
map(lambdafile_name:open(file_name,"rt"),arguments)                    
      

character

Value:
'\xf3'                                                                 
      

entity

Value:
'oacute'