From: Edward L. <ed...@us...> - 2004-04-15 19:49:05
|
Update of /cvsroot/docutils/sandbox/edloper/roles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4973 Added Files: states.py Log Message: initial import --- NEW FILE: states.py --- # Author: David Goodger # Contact: go...@us... # Revision: $Revision: 1.1 $ # Date: $Date: 2004/04/15 19:48:57 $ # Copyright: This module has been placed in the public domain. """ This is the ``docutils.parsers.restructuredtext.states`` module, the core of the reStructuredText parser. It defines the following: :Classes: - `RSTStateMachine`: reStructuredText parser's entry point. - `NestedStateMachine`: recursive StateMachine. - `RSTState`: reStructuredText State superclass. - `Inliner`: For parsing inline markup. - `Body`: Generic classifier of the first line of a block. - `SpecializedBody`: Superclass for compound element members. - `BulletList`: Second and subsequent bullet_list list_items - `DefinitionList`: Second+ definition_list_items. [...2832 lines suppressed...] while 1: found = text.find('\\', start) if found == -1: parts.append(text[start:]) return ''.join(parts) parts.append(text[start:found]) parts.append('\x00' + text[found+1:found+2]) start = found + 2 # skip character after escape def unescape(text, restore_backslashes=0): """ Return a string with nulls removed or restored to backslashes. Backslash-escaped spaces are also removed. """ if restore_backslashes: return text.replace('\x00', '\\') else: for sep in ['\x00 ', '\x00\n', '\x00']: text = ''.join(text.split(sep)) return text |