API : kiwikiwi.mainkiwi.corekiwi.blockskiwi.inlineskiwi.formattingkiwi.templateskiwi.kiwi2htmlkiwi.kiwi2twiki
private protected

Module kiwi

Undocumented

Function run

run( arguments, input=None, noOutput=False )

Returns a couple (STATUS, VALUE), where status is 1 when OK, 0 when informative, and -1 when error, and value is a string.

The given arguments can be either a string or an array, the input can be None (it will be then taken from the arguments), or be a file-like object, and the noOutput flag will not output the result on stdout or whatever file is given on the command line.

Function runAsCommand

runAsCommand( )
Undocumented

Function text2htmlbody

text2htmlbody( text, inputEncoding=None, outputEncoding=None )

Converts the given text to HTML, returning only the body.

str

'us-ascii'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

dict

{'latin-2': 'iso-8859-2', 'iso88592': 'iso-8859-2', 'usascii': 'us-ascii', 'latin-1': 'iso-8859-1', 'ascii': 'us-ascii', 'mac-roman': 'macroman', 'iso-8859-2': 'iso-8859-2', 'iso-8859-1': 'iso-8859-1', 'utf-8': 'utf-8', 'text': 'us-ascii', 'iso88591': 'iso-8859-1', 'utf8': 'utf-8', 'iso-88592': 'iso-8859-2', 'iso-88591': 'iso-8859-1', 'iso8859': 'iso-8859-1', 'utf-16': 'utf-16', 'us-ascii': 'us-ascii', 'iso8859-2': 'iso-8859-2', 'iso8859-1': 'iso-8859-1', 'latin1': 'iso-8859-1', 'latin2': 'iso-8859-2', 'macroman': 'macroman', 'plain': 'us-ascii', 'utf16': 'utf-16'}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

dict

{'html': <module 'kiwi.kiwi2html' from '/home/sebastien/Projects/Local/lib/python/kiwi/kiwi2html.pyc'>, 'twiki': <module 'kiwi.kiwi2twiki' from '/home/sebastien/Projects/Local/lib/python/kiwi/kiwi2twiki.pyc'>}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

str

'iso-8859-1'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

str

'iso-8859-2'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

str

'macroman'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

tuple

('iso-8859-1', 'iso-8859-2', 'utf-8', 'utf-16', 'macroman')

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

unicode

u'Kiwi v.0.8.4alpha,\n A flexible tool for converting plain text markup to XML and HTML.\n Kiwi can be used to easily generate documentation from plain files or to\n convert exiting Wiki markup to other formats.\n\n See <http://www.ivy.fr/kiwi>\n\nUsage: kiwi [options] source [destination]\n\n source:\n The text file to be parsed (usually an .stx file, "-" for stdin)\n destination:\n The optional destination file (otherwise result is dumped on stdout)\n\nOptions:\n\n -i --input-encoding Allows to specify the input encoding\n -o --output-encoding Allows to specify the output encoding\n -t --tab The value for tabs (tabs equal N sapces).\n Set to 4 by default.\n -f --offsets Add offsets information\n -p --pretty Pretty prints the output XML, this should only\n be used for viewing the output.\n -m --html Outputs an HTML file corresponding to the Kiwi\n document\n --no-style Does not include the default CSS in the HTML\n --body-only Only returns the content of the <body< element\n --level=n If n>0, n will transform HTML h1 to h2, etc...\n -O --output-format Specifies and alternate output FORMAT\n (see below)\n\t\t\t\t\t\t\t\t \n The available encodings are %s\n The available formats are %s\n \nMisc:\n -h, --help prints this help.\n -v, --version prints the version of Kiwi.\n'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

str

'utf-16'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

str

'utf-8'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Module kiwi.main

Kiwi is an advanced markup text processor, which can be used as an embedded processor in any application. It is fast, extensible and outputs an XML DOM.

tuple

()

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self, documentText, markOffsets=False )
Undocumented

Method _getElementsByTagName

_getElementsByTagName( self, node, name )
Undocumented

Method blockEndReached

blockEndReached( self )

Returns true when the current offset has exceeded the current block end offset

Method clone

clone( self )

Returns a clone of the current context, which can be changed safely without modifying the current context.

Method currentFragment

currentFragment( self )

Returns the current text fragment, from the current offset to the block end offset.

Method declareSection

declareSection( self, node, contentNode, depth )

Declares a section node with the given depth (which can be negative).

Method decreaseOffset

decreaseOffset( self, decrease )

Decreases the offset.

Method documentEndReached

documentEndReached( self )

Returns true if the current offset is greater than the document length

Method ensureElement

ensureElement( self, node, elementName, index=0 )

Ensures that the given element exists in the given node at the given index.

Method ensureParent

ensureParent( self, parentNames, predicate= at 0x822eca4> )

Ensures that the parent node name is one of the following name. This is useful for block parsers which want to ensure that their parent is a specific node

Method findNextInline

findNextInline( self, inlineParsers )

Finds the next inline in the given context, using the given list of inline parsers. This does not modifies the context.

Returns either None or a triple (offset, information, parser), where the offset is relative to the context offset and indicates the start offset where the parser recognised its tag and information is the information returned by the parser.

Method fragment

fragment( self, start, end )

Returns the text fragment that starts and ends at the given offsets.

Method getBlockIndentation

getBlockIndentation( self )

Returns the indentation of the current block.

Method getDepthInSection

getDepthInSection( self, node )

Returns the number of parent sections of the given node.

Method getOffset

getOffset( self )

Returns the current offset.

Method getParentSection

getParentSection( self, depth, indent )

Gets the section that would be the parent section for the given depth.

Method increaseOffset

increaseOffset( self, increase )

Increases the current offset

Method offsetInBlock

offsetInBlock( self, offset )

Tells if the givne offset is in the current block.

Method parseAttributes

parseAttributes( self, text )

Parses attributes expressed in the given text. Attributes have the following form: ATTRIBUTE="VALUE" and are separated by spaces.

Method restoreOffsets

restoreOffsets( self, offsets )

Takes a value returned by saveOffsets and restores the offsets as they were.

Method saveOffsets

saveOffsets( self )

Returns a value that can be later used with the restoreOffsets method to restore the offsets as they were.

Method setCurrentBlock

setCurrentBlock( self, startOffset, endOffset )

Sets the start and end offset of the current block. The current offset is set to the current block start.

Method setCurrentBlockEnd

setCurrentBlockEnd( self, endOffset )
Undocumented

Method setDocumentText

setDocumentText( self, text )

Sets the text of the current document. This should only be called at context initialisation.

Method setOffset

setOffset( self, offset )

Sets the current offset.

Class Context

The context stores information on the currently processed document. It has the following attributes:

  • document: a reference to the current XML document.
  • rootNode: the current XML document root node.
  • header: the XML node corresponding to the header.
  • content: the XML node corresponding to the content.
  • references: the XML node corresponding to the references.
  • appendices: the XML node corresponding to the appendices.
  • currentNode: the XML node to which attributes/nodes are added during parsing.
  • blockStartOffset: the offset in the text where the currently parsed block starts.
  • blockEndOffset: the offset in the text where the currently parsed block ends.
  • parser: a reference to the Kiwi parser instance using the context.

Method __init__

__init__( self, baseDirectory, inputEncoding='utf8', outputEncoding='utf8' )
Undocumented

Method _delimitXMLMarkupBlock

_delimitXMLMarkupBlock( self, context, markupMatch, blockMatch, localOffset )
Undocumented

Method _findNextBlockSeparator

_findNextBlockSeparator( self, context )

Returns a match object that matches the next block separator, taking into account possible custom block objects.

Method _initialiseContextDocument

_initialiseContextDocument( self, context )

Creates the XML document that will be populated by Kiwi parsing.

Method _nodeEnsureOffsets

_nodeEnsureOffsets( self, node, start=None, end=None )
Undocumented

Method _nodeGetOffsets

_nodeGetOffsets( self, node )
Undocumented

Method _nodeHasOffsets

_nodeHasOffsets( self, node )
Undocumented

Method _parseNextBlock

_parseNextBlock( self, context, end=None )

Parses the block identified in the given context, ending at the given end (if end is not None).

Method _parseNextInline

_parseNextInline( self, context, node, textProcessor )

Parses the content of the current block, starting at the context offset, modifying the given node and updating the context offset. This returns the a triple (offset, information, parser) where information is the result of the parser `recognises' method.

Method _print

_print( self, message, context )
Undocumented

Method _propagateElementOffsets

_propagateElementOffsets( self, element, start=None, end=None )

Used by the _updateElementOffsets to ensure start and end offsets in all children and descendants.

Method _updateElementOffsets

_updateElementOffsets( self, context, node=None, counter=0, offsets=None )

This function ensures that every element has a start and end attribute indicating the bit of original data it comes from.

Method charactersToSpaces

charactersToSpaces( self, text )

Returns a string where all characters are converted to spaces. Newlines and tabs are preserved

Method countLeadingSpaces

countLeadingSpaces( self, text )

Returns the number of leading spaces in the given line. A tab will have the value given by the TAB_SIZE global.

Method createBlockParsers

createBlockParsers( self )
Undocumented

Method createCustomParsers

createCustomParsers( self )
Undocumented

Method createInlineParsers

createInlineParsers( self )
Undocumented

Method error

error( self, message, context )
Undocumented

Method expandTabs

expandTabs( self, text, cut=0 )

Expands the tabs in the given text, cutting the n first characters of each line, where n is given by the cut argument. This tabs expansion algorithm works better than Python line expansion algorithms.

Method getIndentation

getIndentation( self, text )

Returns the indentation of a string.

Basically if a string has the first three lines at the same identation level, then it is indentation will be the number of spaces or tabs that lead the first three lines.

Tabs have the value given by the TAB_SIZE variable.

Method normaliseText

normaliseText( self, text )

Treats tabs eols and multiples spaces as single space, plus removes leading and trailing spaces.

Method parse

parse( self, text, offsets=False )

Parses the given text, and returns an XML document. If offsets is set to True, then all nodes of the document are annotated with their position in the original text as well with a number. The document will also have an offsets attribute that will contain a list of (start, end) offset tuples for each element.

Method parseBlock

parseBlock( self, context, node, textProcessor )

Parses the current block, looking for the inlines it may contain.

Method parseContext

parseContext( self, context )
Undocumented

Method removeLeadingSpaces

removeLeadingSpaces( self, text, maximum=None )
Undocumented

Method tip

tip( self, message, context )
Undocumented

Method warning

warning( self, message, context )
Undocumented

Class Parser

Undocumented

unicode

u'<-+>|-+->|<-+'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'(\\w+)\\s*=\\s*(\'[^\']*\'|"[^"]*")'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

tuple

('Block', 'ListItem', 'Definition', 'Content', 'Chapter', 'Section', 'Appendix')

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

unicode

u'\\s*\n\\s*\\|\\s*\n()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\xab([^\xbb]+)\xbb'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'`([^\\`]+)`'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'``((`?[^`])+)``'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u"'([^']+)'"

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^\\s*#.*$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\s*-\\s*"([^"]+)"\\s*[=:]\\s*([\\w\\-_]+)(\\s*\\(\\s*(\\w+)\\s*\\))?'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^(\\s*(\\:[^\\:]|[^\\:])+)\\:\\:+\\s*(\n+\\s*|\\s*\\|\\s*\n)*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

unicode

u'\\.\\.\\.()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\<([\\w.\\-_]+@[\\w.\\-_]+)\\>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\*([^*]+)\\*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

str

'Empty list item.'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

str

"Markup `%s' end found without previous markup start"

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

unicode

u'(&(\\w+|#[0-9]+);)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

str

'Title too deeply nested'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

unicode

u'\\]>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\"'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'<\\['

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\\\"([^"]+)"'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

tuple

('EN', 'FR', 'DE', 'UK')

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

unicode

u'\\[([^\\]]+)\\]\\s*((\\(([^ \\)]+)(\\s+"([^"]+)"\\s*)?\\))|\\[([\\w\\s]+)\\])?'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'(^\\s*[^:{().<]*:)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^(\\s*)(-|\\*\\)|[0-9A-z][\\)/]|\\[[ \\-\\~xX]\\])\\s*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^([^:]+(:\\s*\n\\s*|::\\s*))|([^/\\\\]+[/\\\\]\\s*\n\\s*)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u' -- ()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u' --- ()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\<(\\w+)(\\s*\\w+\\s*=\\s*(\'[^\']*\'|"[^"]*"))*\\s*/?>|\\</(\\w+)\\s*>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\w+\\s*=\\s*(\'[^\']*\'|"[^"]*")'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'(^|\n)\\s*([\\w\\-]+)\\s*:\\s*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\s*(\\w+)\\s*(\\((\\w+)\\))?'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

str

"Unrecognised markup specifier: 'start' or 'end' would be expected"

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

unicode

u'\\s*\\\\n\\s*()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^((\\s*\\>(\t| ))(.*)\n?)+'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^(\\s*\\>(\t| ))(.*)$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u"''(('?[^'])+)''"

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\s+\\[([^\\]]+)]:'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

SRE_Pattern

Compiled regular expression objects

unicode

u'^\\s*((([0-9]+|[A-z])\\.)+([0-9]+|[A-z])?\\.?)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^(\\=+\\s*).+$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^\\s*[\\*\\-\\=#][\\*\\-\\=#][\\*\\-\\=#]+\\s*$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

str

"Markup `%s' start found without following markup end"

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

unicode

u'\\*\\*([^*]+)\\*\\*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\s*\\|\\s*\n()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

str

'^\\s*([\\-\\+]+|[\\=\\+]+)\\s*$'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

unicode

u'^\\s*(([^_]+\\s*)(\\:[^_]+)?)?(____+)\\s*$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\|([\\w\\s]+(:[^\\|]*)?)\\|'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'\\_([^_]+)_'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^\\s*(==)([^=].+)$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^\\s*(--)([^\\:]+):(.+)?$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

unicode

u'\\<([A-z]+://[^\\>]+)\\>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Module kiwi.core

Undocumented

Method __init__

__init__( self, name )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )

Tells wether the given block is recognised or not. This returns this block recognition information, or False (or None) if the block was not recongised.

Class BlockParser

Undocumented

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Class CommentBlockParser

Parses a comment markup block.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method _getParentDefinition

_getParentDefinition( self, node )
Undocumented

Method process

process( self, context, match )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Class DefinitionBlockParser

Parses a definition markup element.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, itemMatch )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Class ListItemBlockParser

Parses a list item. A list item is an element within a list.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Class MarkupBlockParser

Parses a custom markup block.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method _flatify

_flatify( self, text )
Undocumented

Method _parseDateToNode

_parseDateToNode( self, context, content, node )
Undocumented

Method p_abstract

p_abstract( self, context, content )
Undocumented

Method p_ack

p_ack( self, context, content )
Undocumented

Method p_author

p_author( self, context, content )
Undocumented

Method p_creation

p_creation( self, context, content )
Undocumented

Method p_keywords

p_keywords( self, context, content )
Undocumented

Method p_language

p_language( self, context, content )
Undocumented

Method p_last_mod

p_last_mod( self, context, content )
Undocumented

Method p_markup

p_markup( self, context, content )

Parses custom markup and registers the new parsers in the current Kiwi parser

Method p_organisation

p_organisation( self, context, content )
Undocumented

Method p_reference

p_reference( self, context, content )
Undocumented

Method p_revision

p_revision( self, context, content )
Undocumented

Method p_type

p_type( self, context, content )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )

Tells wether the given block is recognised or not. This returns this block recognition information, or False (or None) if the block was not recongised.

Class MetaBlockParser

Parses the content of a Meta block

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Class ParagraphBlockParser

Parses a paragraph block. This parser always recognised the given block, so it should not appear in the block parsers.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Class PreBlockParser

Parses the content of a preformatted block, where every line is prefixed by > .

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method findBlockEnd

findBlockEnd( self, context, indent )
Undocumented

Method getCommonPrefix

getCommonPrefix( self, linea, lineb )
Undocumented

Method isEndLine

isEndLine( self, context, line, indent )
Undocumented

Method isStartLine

isStartLine( self, context, line )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Class PreBlockParser2

Parses the content of a preformatted block which is delimited with <<< and >>> characters.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, match )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Class ReferenceEntryBlockParser

Parses the content of a Reference entry

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Class SectionBlockParser

Parses a section markup element.

Method __init__

__init__( self )
Undocumented

Method __repr__

__repr__( self )
Undocumented

Method _ensureCell

_ensureCell( self, x, y )

Ensures that the cell at the given position exists and returns its pair value.

Method appendCellContent

appendCellContent( self, x, y, text )
Undocumented

Method dataCell

dataCell( self, x, y )
Undocumented

Method dimension

dimension( self )
Undocumented

Method getNode

getNode( self, context, processText )

Renders the table as a Kiwi XML document node.

Method headerCell

headerCell( self, x, y )
Undocumented

Method isHeader

isHeader( self, x, y )
Undocumented

Method setTitle

setTitle( self, title )

Sets the title for this table.

Class Table

The table class allows to easily create tables and then generate the XML objects from them.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Class TableBlockParser

Parses the content of a tables

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method _goToParent

_goToParent( self, thisblock, parent )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Class TaggedBlockParser

Parses a tagged block. Notes are the common example of tagged block.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method _processLine

_processLine( self, line )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Class TitleBlockParser

Parses a title object

Module kiwi.blocks

Write module doc here

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Class ArrowInlineParser

Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method parse

parse( self, context, node, recogniseInfo )
Undocumented

Method processText

processText( self, text )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Class CommentInlineParser

Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Class EntityInlineParser

Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method endOf

endOf( self, recogniseInfo )
Undocumented

Method parse

parse( self, context, node, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Class EscapedInlineParser

Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Class EscapedStringInlineParser

Undocumented

Method __init__

__init__( self, name, regexp, result= at 0x4033595c>, requiresLeadingSpace=False )

Creates a new InlineParser.

Name is the name of the parser, regexp is the string expression of the regular expression that will match the element that the InlineParser is looking for, or regexp can also be a precompiled regular expression object.

Result is a lambda expression that will return the content of the Inline generated by the parse method. The lambda takes two arguments : the match object and the string in which the match object has been found.

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method parse

parse( self, context, node, recogniseInfo )

Parses the given context within the current block range, returning the new offset (relative to the block start offset, ie. the start of context.currentFragment). Note that the context offsets are the same as those given to the recognise method call which created recogniseInfo.

The given context starts at the same offset as when recognises was called. Modifications are made to the given node.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Class InlineParser

Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Class LinkInlineParser

Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method _searchMarkup

_searchMarkup( self, context )

Looks for the next markup inline in the current context. This also takes care of markups that are contained into an escaped text tag.

WARNING : this operation mutates the context offsets, so this should always be enclosed in offset store and restore. The context offset is set BEFORE the searched markup, so that the returned recognition info is relative to the context offset.

Returns the result of this parser `recognise' method, or null.

Method findEnd

findEnd( self, blockName, context, offsetIncr=0 )

Finds the end of the given markup end in the current block. Returns a couple (start, end) indicating the start and end offsets of the found end block, relative to the context offset. The given offsetIncr parameter tells the number of characters to skip before searching for the end markup. This has no impact on the result.

The context offsets are left unchanged.

Method isEndTag

isEndTag( self, match )
Undocumented

Method isStartTag

isStartTag( self, match )
Undocumented

Method parse

parse( self, context, node, recogniseInfo )

Parses the given tag, and returns the offset where the parsed tag ends. If the tag is an "inline block" tag, then its content is also parsed.

Method processText

processText( self, context, text )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Class MarkupInlineParser

Parses Kiwi generic markup elements.

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Class PreInlineParser

Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Class TargetInlineParser

Undocumented

Function Markup_attributes

Markup_attributes( match )

Returns the attribute string of this markup stat element.

Function Markup_isEndTag

Markup_isEndTag( match )
Undocumented

Function Markup_isStartTag

Markup_isStartTag( match )
Undocumented

Function _processText

_processText( context, text )

Common operation for expanding tabs and normalising text. Use by acronyms, citations and quotes.

Module kiwi.inlines

Undocumented

Function Upper

Upper( text )
Undocumented

Function escapeHTML

escapeHTML( text )
Undocumented

Module kiwi.formatting

Undocumented

Method __init__

__init__( self, module=None )
Undocumented

Method defaultProcessElement

defaultProcessElement( self, element, selector )

Default function for processing elements. This returns the text.

Method generate

generate( self, xmlDocument, bodyOnly=False, variables={} )
Undocumented

Method interpret

interpret( self, element, expression )

Interprets the given expression for the given element

Method process

process( self, element, text )
Undocumented

Method processElement

processElement( self, element, selector=None )

Processes the given element according to the EXPRESSION_TABLE, using the given selector to select an alternative function.

Method register

register( self, name2functions )

Fills the EXPRESSIONTABLE which maps element names to processing functions. This function is only useful when you implement your templates in the same way as the `kiwi2html` module, ie. with processing functions like `convertXXXVVV where XXX stands for the element name, and _VVV is the optional variant (selected by$(element:variant)`).

You may prefer to use the registerElementProcessor instead if you want to register a processor for an individual tag.

Method registerElementProcessor

registerElementProcessor( self, function, elementName, variant=None )

Registers the given function to process the given element name and the given optional variant.

Note that this will replace any previsously registered processor for the element and variant.

Method resolveSet

resolveSet( self, element, names )

Resolves the set of names in the given element. When "Paragraph"is given, then all child paragraph nodes of the current node will be returned, while "Section", "Paragraph"will return all paragraphs for all sections.

Class Processor

The processor is the core of the template engine. You give it a Python module with "convert*" functions, and it will process it.

SRE_Pattern

Compiled regular expression objects

Module kiwi.templates

The template module implements a simple way to convert an XML document to another format (HTML, text, whatever) by expanding very simple XPath-like expressions. Of course, it is a very-small subset of what you could do in XSLT, but it has a Python syntax and is very, very easy to use.

At first, your define convertXXX' functions where XXX is your case-sensitive tagName. All these functions should take an element as parameter and run the process' function with the element and template string as parameter.

Expressions like `$(XXX)' (XXX being the expression) in the template strings will be expanded by procesing the set of nodes indicated by the XXX expression.

  • $(*) will process all children
  • $(MyNode) will process only nodes with MyNode tagName
  • $(MyParent/MyNode) will process only the children of MyParent named MyNode
  • $(MyNode:alt) will use the function `convertMyNode_alt' instead of the default 'convertMyNode', if available. This allows to setup 'processing modes' for your document (like table of content, references, etc).
  • $(MyNode:alt?) will use the function convertMyNode_alt' if it is defined, or fallback to convertMyNode`.

tuple

(<class kiwi.templates.Processor at 0x822bf5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method defaultProcessElement

defaultProcessElement( self, element, selector )

We override this for elements with the html attribute.

Method generate

generate( self, xmlDocument, bodyOnly=False, variables={} )
Undocumented

Class Processor

Undocumented

Function convertBlock

convertBlock( element )
Undocumented

Function convertCaption

convertCaption( element )
Undocumented

Function convertCell

convertCell( element )
Undocumented

Function convertContent

convertContent( element )
Undocumented

Function convertContent_bodyonly

convertContent_bodyonly( element )
Undocumented

Function convertContent_table

convertContent_table( element )
Undocumented

Function convertDefinition

convertDefinition( element )
Undocumented

Function convertDefinitionItem

convertDefinitionItem( element )
Undocumented

Function convertDocument

convertDocument( element )
Undocumented

Function convertEntry

convertEntry( element )
Undocumented

Function convertHeader

convertHeader( element )
Undocumented

Function convertHeader_title

convertHeader_title( element )
Undocumented

Function convertHeading

convertHeading( element )
Undocumented

Function convertList

convertList( element )
Undocumented

Function convertListItem

convertListItem( element )
Undocumented

Function convertMeta

convertMeta( element )
Undocumented

Function convertParagraph

convertParagraph( element )
Undocumented

Function convertParagraph_cell

convertParagraph_cell( element )
Undocumented

Function convertReferences

convertReferences( element )
Undocumented

Function convertRow

convertRow( element )
Undocumented

Function convertSection

convertSection( element )
Undocumented

Function convertTable

convertTable( element )
Undocumented

Function convertarrow

convertarrow( element )
Undocumented

Function convertbreak

convertbreak( element )
Undocumented

Function convertcitation

convertcitation( element )
Undocumented

Function convertcode

convertcode( element )
Undocumented

Function convertdots

convertdots( element )
Undocumented

Function convertemail

convertemail( element )
Undocumented

Function convertemdash

convertemdash( element )
Undocumented

Function convertemphasis

convertemphasis( element )
Undocumented

Function convertendash

convertendash( element )
Undocumented

Function convertentity

convertentity( element )
Undocumented

Function convertlink

convertlink( element )
Undocumented

Function convertmeta

convertmeta( element )
Undocumented

Function convertnewline

convertnewline( element )
Undocumented

Function convertpre

convertpre( element )
Undocumented

Function convertquote

convertquote( element )
Undocumented

Function convertstrong

convertstrong( element )
Undocumented

Function convertsubtitle_header

convertsubtitle_header( element )
Undocumented

Function converttarget

converttarget( element )
Undocumented

Function convertterm

convertterm( element )
Undocumented

Function converttitle_header

converttitle_header( element )
Undocumented

Function converturl

converturl( element )
Undocumented

Function converturl_header

converturl_header( element )
Undocumented

Function element_number

element_number( element )

Utility function that returns the element number (part of the element offset attributes)

Function formatSectionNumber

formatSectionNumber( number )
Undocumented

Function getSectionNumberPrefix

getSectionNumberPrefix( element )
Undocumented

Function stringToTarget

stringToTarget( text )
Undocumented

Function wattrs

wattrs( element )

Returns the offset attributes of this element if it has any.

Function wdiv

wdiv( element, text )

Wraps the given text in a DIV extended with offsets attributes if the given element has offset attributes.

Function wspan

wspan( element, text )

Wraps the given text in a SPAN extended with offsets attributes if the given element has offset attributes.

dict

{'convertentity': <function convertentity at 0x823a95c>, 'convertsubtitle_header': <function convertsubtitle_header at 0x823a224>, 'convertDocument': <function convertDocument at 0x8230bc4>, 'convertcitation': <function convertcitation at 0x823a6f4>, 'convertCell': <function convertCell at 0x823a454>, 'converttarget': <function converttarget at 0x823a534>, 'converttitle_header': <function converttitle_header at 0x823a1ec>, 'convertemdash': <function convertemdash at 0x823a924>, 'convertHeading': <function convertHeading at 0x823a064>, 'convertBlock': <function convertBlock at 0x823a48c>, 'convertMeta': <function convertMeta at 0x823a56c>, 'convertstrong': <function convertstrong at 0x823a72c>, 'convertemail': <function convertemail at 0x823a5dc>, 'convertList': <function convertList at 0x823a2cc>, 'convertTable': <function convertTable at 0x823a33c>, 'convertendash': <function convertendash at 0x823a8ec>, 'convertbreak': <function convertbreak at 0x823a80c>, 'convertCaption': <function convertCaption at 0x823a3e4>, 'convertemphasis': <function convertemphasis at 0x823a7d4>, 'convertRow': <function convertRow at 0x823a41c>, 'convertarrow': <function convertarrow at 0x823a87c>, 'convertHeader_title': <function convertHeader_title at 0x823a1b4>, 'convertHeader': <function convertHeader at 0x823a02c>, 'convertContent_bodyonly': <function convertContent_bodyonly at 0x8230f7c>, 'convertParagraph_cell': <function convertParagraph_cell at 0x823a294>, 'convertContent_table': <function convertContent_table at 0x8230fb4>, 'convertContent': <function convertContent at 0x8230f44>, 'convertDefinition': <function convertDefinition at 0x823a374>, 'convertParagraph': <function convertParagraph at 0x823a25c>, 'convertlink': <function convertlink at 0x823a4fc>, 'convertpre': <function convertpre at 0x823a764>, 'convertEntry': <function convertEntry at 0x823a17c>, 'converturl_header': <function converturl_header at 0x823a64c>, 'converturl': <function converturl at 0x823a614>, 'convertquote': <function convertquote at 0x823a6bc>, 'convertnewline': <function convertnewline at 0x823a844>, 'convertListItem': <function convertListItem at 0x823a304>, 'convertSection': <function convertSection at 0x823a10c>, 'convertcode': <function convertcode at 0x823a79c>, 'convertdots': <function convertdots at 0x823a8b4>, 'convertterm': <function convertterm at 0x823a684>, 'convertDefinitionItem': <function convertDefinitionItem at 0x823a3ac>, 'convertmeta': <function convertmeta at 0x823a5a4>, 'convertReferences': <function convertReferences at 0x823a144>}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

instance

Undocumented

str

'converturl_header'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Module kiwi.kiwi2html

Undocumented

Function convertBlock

convertBlock( element )
Undocumented

Function convertCell

convertCell( element )
Undocumented

Function convertDefinition

convertDefinition( element )
Undocumented

Function convertDefinitionItem

convertDefinitionItem( element )
Undocumented

Function convertDocument

convertDocument( element )
Undocumented

Function convertHeader

convertHeader( element )
Undocumented

Function convertHeading

convertHeading( element )
Undocumented

Function convertList

convertList( element )
Undocumented

Function convertListItem

convertListItem( element )
Undocumented

Function convertParagraph

convertParagraph( element )
Undocumented

Function convertParagraph_cell

convertParagraph_cell( element )
Undocumented

Function convertReferences

convertReferences( element )
Undocumented

Function convertRow

convertRow( element )
Undocumented

Function convertSection

convertSection( element )
Undocumented

Function convertTable

convertTable( element )
Undocumented

Function convertarrow

convertarrow( element )
Undocumented

Function convertbreak

convertbreak( element )
Undocumented

Function convertcode

convertcode( element )
Undocumented

Function convertdots

convertdots( element )
Undocumented

Function convertemail

convertemail( element )
Undocumented

Function convertemdash

convertemdash( element )
Undocumented

Function convertemphasis

convertemphasis( element )
Undocumented

Function convertendash

convertendash( element )
Undocumented

Function convertentity

convertentity( element )
Undocumented

Function convertlink

convertlink( element )
Undocumented

Function convertnewline

convertnewline( element )
Undocumented

Function convertpre

convertpre( element )
Undocumented

Function convertquote

convertquote( element )
Undocumented

Function convertstrong

convertstrong( element )
Undocumented

Function converttarget

converttarget( element )
Undocumented

Function convertterm

convertterm( element )
Undocumented

Function converturl

converturl( element )
Undocumented

Function stringToTarget

stringToTarget( text )
Undocumented

dict

{'convertentity': <function convertentity at 0x8240d84>, 'convertCell': <function convertCell at 0x824095c>, 'converttarget': <function converttarget at 0x8240a3c>, 'convertHeading': <function convertHeading at 0x82406f4>, 'convertBlock': <function convertBlock at 0x8240994>, 'convertstrong': <function convertstrong at 0x8240b54>, 'convertemail': <function convertemail at 0x8240a74>, 'convertList': <function convertList at 0x824080c>, 'convertTable': <function convertTable at 0x824087c>, 'convertendash': <function convertendash at 0x8240d14>, 'convertbreak': <function convertbreak at 0x8240c34>, 'convertemphasis': <function convertemphasis at 0x8240bfc>, 'convertParagraph_cell': <function convertParagraph_cell at 0x82407d4>, 'convertarrow': <function convertarrow at 0x8240ca4>, 'convertHeader': <function convertHeader at 0x82406bc>, 'convertRow': <function convertRow at 0x8240924>, 'convertDocument': <function convertDocument at 0x8240684>, 'convertDefinitionItem': <function convertDefinitionItem at 0x82408ec>, 'convertDefinition': <function convertDefinition at 0x82408b4>, 'convertParagraph': <function convertParagraph at 0x824079c>, 'convertlink': <function convertlink at 0x8240a04>, 'convertpre': <function convertpre at 0x8240b8c>, 'converturl': <function converturl at 0x8240aac>, 'convertquote': <function convertquote at 0x8240b1c>, 'convertnewline': <function convertnewline at 0x8240c6c>, 'convertListItem': <function convertListItem at 0x8240844>, 'convertSection': <function convertSection at 0x824072c>, 'convertcode': <function convertcode at 0x8240bc4>, 'convertdots': <function convertdots at 0x8240cdc>, 'convertterm': <function convertterm at 0x8240ae4>, 'convertemdash': <function convertemdash at 0x8240d4c>, 'convertReferences': <function convertReferences at 0x8240764>}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

str

'converturl'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Module kiwi.kiwi2twiki

Undocumented

Function convertMeta

convertMeta( element )
Undocumented

Function convertRow

convertRow( element )
Undocumented

Method parse

parse( self, context, node, recogniseInfo )
Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method processText

processText( self, context, text )
Undocumented

Method __init__

__init__( self )
Undocumented

unicode

u'^(\\s*)(-|\\*\\)|[0-9A-z][\\)/]|\\[[ \\-\\~xX]\\])\\s*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Method _print

_print( self, message, context )
Undocumented

str

"Unrecognised markup specifier: 'start' or 'end' would be expected"

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

SRE_Pattern

Compiled regular expression objects

Class MetaBlockParser

Parses the content of a Meta block

Method processText

processText( self, context, text )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method __init__

__init__( self )
Undocumented

Function convertbreak

convertbreak( element )
Undocumented

Function convertemdash

convertemdash( element )
Undocumented

Function convertReferences

convertReferences( element )
Undocumented

tuple

(<class kiwi.templates.Processor at 0x822bf5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method _nodeEnsureOffsets

_nodeEnsureOffsets( self, node, start=None, end=None )
Undocumented

Method _findNextBlockSeparator

_findNextBlockSeparator( self, context )

Returns a match object that matches the next block separator, taking into account possible custom block objects.

Method _initialiseContextDocument

_initialiseContextDocument( self, context )

Creates the XML document that will be populated by Kiwi parsing.

Method setCurrentBlockEnd

setCurrentBlockEnd( self, endOffset )
Undocumented

Method setDocumentText

setDocumentText( self, text )

Sets the text of the current document. This should only be called at context initialisation.

Method saveOffsets

saveOffsets( self )

Returns a value that can be later used with the restoreOffsets method to restore the offsets as they were.

Method setCurrentBlock

setCurrentBlock( self, startOffset, endOffset )

Sets the start and end offset of the current block. The current offset is set to the current block start.

Method __init__

__init__( self, baseDirectory, inputEncoding='utf8', outputEncoding='utf8' )
Undocumented

Method _delimitXMLMarkupBlock

_delimitXMLMarkupBlock( self, context, markupMatch, blockMatch, localOffset )
Undocumented

Method setOffset

setOffset( self, offset )

Sets the current offset.

Class Parser

Undocumented

Method getOffset

getOffset( self )

Returns the current offset.

Method getParentSection

getParentSection( self, depth, indent )

Gets the section that would be the parent section for the given depth.

Method getBlockIndentation

getBlockIndentation( self )

Returns the indentation of the current block.

Method getDepthInSection

getDepthInSection( self, node )

Returns the number of parent sections of the given node.

Method parseAttributes

parseAttributes( self, text )

Parses attributes expressed in the given text. Attributes have the following form: ATTRIBUTE="VALUE" and are separated by spaces.

Method restoreOffsets

restoreOffsets( self, offsets )

Takes a value returned by saveOffsets and restores the offsets as they were.

Method increaseOffset

increaseOffset( self, increase )

Increases the current offset

Method offsetInBlock

offsetInBlock( self, offset )

Tells if the givne offset is in the current block.

SRE_Pattern

Compiled regular expression objects

str

'Empty list item.'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Method declareSection

declareSection( self, node, contentNode, depth )

Declares a section node with the given depth (which can be negative).

Method findNextInline

findNextInline( self, inlineParsers )

Finds the next inline in the given context, using the given list of inline parsers. This does not modifies the context.

Returns either None or a triple (offset, information, parser), where the offset is relative to the context offset and indicates the start offset where the parser recognised its tag and information is the information returned by the parser.

Method fragment

fragment( self, start, end )

Returns the text fragment that starts and ends at the given offsets.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method ensureParent

ensureParent( self, parentNames, predicate= at 0x822eca4> )

Ensures that the parent node name is one of the following name. This is useful for block parsers which want to ensure that their parent is a specific node

Method currentFragment

currentFragment( self )

Returns the current text fragment, from the current offset to the block end offset.

Method blockEndReached

blockEndReached( self )

Returns true when the current offset has exceeded the current block end offset

Method clone

clone( self )

Returns a clone of the current context, which can be changed safely without modifying the current context.

str

'utf-8'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Module kiwi.core

Undocumented

unicode

u'Kiwi v.0.8.4alpha,\n A flexible tool for converting plain text markup to XML and HTML.\n Kiwi can be used to easily generate documentation from plain files or to\n convert exiting Wiki markup to other formats.\n\n See <http://www.ivy.fr/kiwi>\n\nUsage: kiwi [options] source [destination]\n\n source:\n The text file to be parsed (usually an .stx file, "-" for stdin)\n destination:\n The optional destination file (otherwise result is dumped on stdout)\n\nOptions:\n\n -i --input-encoding Allows to specify the input encoding\n -o --output-encoding Allows to specify the output encoding\n -t --tab The value for tabs (tabs equal N sapces).\n Set to 4 by default.\n -f --offsets Add offsets information\n -p --pretty Pretty prints the output XML, this should only\n be used for viewing the output.\n -m --html Outputs an HTML file corresponding to the Kiwi\n document\n --no-style Does not include the default CSS in the HTML\n --body-only Only returns the content of the <body< element\n --level=n If n>0, n will transform HTML h1 to h2, etc...\n -O --output-format Specifies and alternate output FORMAT\n (see below)\n\t\t\t\t\t\t\t\t \n The available encodings are %s\n The available formats are %s\n \nMisc:\n -h, --help prints this help.\n -v, --version prints the version of Kiwi.\n'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

str

'utf-16'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Method __init__

__init__( self, documentText, markOffsets=False )
Undocumented

Method _getElementsByTagName

_getElementsByTagName( self, node, name )
Undocumented

Class Context

The context stores information on the currently processed document. It has the following attributes:

  • document: a reference to the current XML document.
  • rootNode: the current XML document root node.
  • header: the XML node corresponding to the header.
  • content: the XML node corresponding to the content.
  • references: the XML node corresponding to the references.
  • appendices: the XML node corresponding to the appendices.
  • currentNode: the XML node to which attributes/nodes are added during parsing.
  • blockStartOffset: the offset in the text where the currently parsed block starts.
  • blockEndOffset: the offset in the text where the currently parsed block ends.
  • parser: a reference to the Kiwi parser instance using the context.

tuple

()

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

str

'iso-8859-1'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

unicode

u'^\\s*#.*$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

dict

{'html': <module 'kiwi.kiwi2html' from '/home/sebastien/Projects/Local/lib/python/kiwi/kiwi2html.pyc'>, 'twiki': <module 'kiwi.kiwi2twiki' from '/home/sebastien/Projects/Local/lib/python/kiwi/kiwi2twiki.pyc'>}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

tuple

('iso-8859-1', 'iso-8859-2', 'utf-8', 'utf-16', 'macroman')

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

str

'iso-8859-2'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

str

'macroman'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Module kiwi.main

Kiwi is an advanced markup text processor, which can be used as an embedded processor in any application. It is fast, extensible and outputs an XML DOM.

Function run

run( arguments, input=None, noOutput=False )

Returns a couple (STATUS, VALUE), where status is 1 when OK, 0 when informative, and -1 when error, and value is a string.

The given arguments can be either a string or an array, the input can be None (it will be then taken from the arguments), or be a file-like object, and the noOutput flag will not output the result on stdout or whatever file is given on the command line.

Module kiwi

Undocumented

str

'us-ascii'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

dict

{'latin-2': 'iso-8859-2', 'iso88592': 'iso-8859-2', 'usascii': 'us-ascii', 'latin-1': 'iso-8859-1', 'ascii': 'us-ascii', 'mac-roman': 'macroman', 'iso-8859-2': 'iso-8859-2', 'iso-8859-1': 'iso-8859-1', 'utf-8': 'utf-8', 'text': 'us-ascii', 'iso88591': 'iso-8859-1', 'utf8': 'utf-8', 'iso-88592': 'iso-8859-2', 'iso-88591': 'iso-8859-1', 'iso8859': 'iso-8859-1', 'utf-16': 'utf-16', 'us-ascii': 'us-ascii', 'iso8859-2': 'iso-8859-2', 'iso8859-1': 'iso-8859-1', 'latin1': 'iso-8859-1', 'latin2': 'iso-8859-2', 'macroman': 'macroman', 'plain': 'us-ascii', 'utf16': 'utf-16'}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Function runAsCommand

runAsCommand( )
Undocumented

Function text2htmlbody

text2htmlbody( text, inputEncoding=None, outputEncoding=None )

Converts the given text to HTML, returning only the body.

Class MarkupBlockParser

Parses a custom markup block.

Method recognises

recognises( self, context )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method parse

parse( self, context, node, match )
Undocumented

unicode

u' -- ()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Method processText

processText( self, context, text )
Undocumented

Class InlineParser

Undocumented

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

Method processText

processText( self, context, text )
Undocumented

unicode

u'<-+>|-+->|<-+'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Function convertList

convertList( element )
Undocumented

Function wdiv

wdiv( element, text )

Wraps the given text in a DIV extended with offsets attributes if the given element has offset attributes.

Function convertquote

convertquote( element )
Undocumented

Function convertendash

convertendash( element )
Undocumented

Function Markup_isStartTag

Markup_isStartTag( match )
Undocumented

SRE_Pattern

Compiled regular expression objects

Method createInlineParsers

createInlineParsers( self )
Undocumented

Method endOf

endOf( self, recogniseInfo )
Undocumented

Method dataCell

dataCell( self, x, y )
Undocumented

Method p_author

p_author( self, context, content )
Undocumented

str

"Markup `%s' start found without following markup end"

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

unicode

u'\\*([^*]+)\\*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Method recognises

recognises( self, context )
Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method processText

processText( self, context, text )
Undocumented

Class PreBlockParser2

Parses the content of a preformatted block which is delimited with <<< and >>> characters.

Function convertContent

convertContent( element )
Undocumented

Function convertBlock

convertBlock( element )
Undocumented

unicode

u'\\<([A-z]+://[^\\>]+)\\>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Class ParagraphBlockParser

Parses a paragraph block. This parser always recognised the given block, so it should not appear in the block parsers.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

tuple

('Block', 'ListItem', 'Definition', 'Content', 'Chapter', 'Section', 'Appendix')

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

SRE_Pattern

Compiled regular expression objects

Method register

register( self, name2functions )

Fills the EXPRESSIONTABLE which maps element names to processing functions. This function is only useful when you implement your templates in the same way as the `kiwi2html` module, ie. with processing functions like `convertXXXVVV where XXX stands for the element name, and _VVV is the optional variant (selected by$(element:variant)`).

You may prefer to use the registerElementProcessor instead if you want to register a processor for an individual tag.

Function converturl_header

converturl_header( element )
Undocumented

Method createCustomParsers

createCustomParsers( self )
Undocumented

SRE_Pattern

Compiled regular expression objects

Method appendCellContent

appendCellContent( self, x, y, text )
Undocumented

Method __init__

__init__( self )
Undocumented

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

Method p_ack

p_ack( self, context, content )
Undocumented

Function convertpre

convertpre( element )
Undocumented

Function Markup_isEndTag

Markup_isEndTag( match )
Undocumented

Function convertemphasis

convertemphasis( element )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

SRE_Pattern

Compiled regular expression objects

unicode

u'<\\['

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function convertList

convertList( element )
Undocumented

Function convertHeader

convertHeader( element )
Undocumented
No attributes

Function convertCell

convertCell( element )
Undocumented

Function convertContent_bodyonly

convertContent_bodyonly( element )
Undocumented

Method decreaseOffset

decreaseOffset( self, decrease )

Decreases the offset.

Method documentEndReached

documentEndReached( self )

Returns true if the current offset is greater than the document length

Method __init__

__init__( self )
Undocumented

Function convertentity

convertentity( element )
Undocumented

Module kiwi.inlines

Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u"'([^']+)'"

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method ensureElement

ensureElement( self, node, elementName, index=0 )

Ensures that the given element exists in the given node at the given index.

Method recognises

recognises( self, context )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Function wattrs

wattrs( element )

Returns the offset attributes of this element if it has any.

Class DefinitionBlockParser

Parses a definition markup element.

Method p_organisation

p_organisation( self, context, content )
Undocumented

unicode

u'\\|([\\w\\s]+(:[^\\|]*)?)\\|'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method __init__

__init__( self )
Undocumented

Class TableBlockParser

Parses the content of a tables

SRE_Pattern

Compiled regular expression objects

Method parseBlock

parseBlock( self, context, node, textProcessor )

Parses the current block, looking for the inlines it may contain.

Function convertquote

convertquote( element )
Undocumented

Class Processor

The processor is the core of the template engine. You give it a Python module with "convert*" functions, and it will process it.

dict

{'convertentity': <function convertentity at 0x8240d84>, 'convertCell': <function convertCell at 0x824095c>, 'converttarget': <function converttarget at 0x8240a3c>, 'convertHeading': <function convertHeading at 0x82406f4>, 'convertBlock': <function convertBlock at 0x8240994>, 'convertstrong': <function convertstrong at 0x8240b54>, 'convertemail': <function convertemail at 0x8240a74>, 'convertList': <function convertList at 0x824080c>, 'convertTable': <function convertTable at 0x824087c>, 'convertendash': <function convertendash at 0x8240d14>, 'convertbreak': <function convertbreak at 0x8240c34>, 'convertemphasis': <function convertemphasis at 0x8240bfc>, 'convertParagraph_cell': <function convertParagraph_cell at 0x82407d4>, 'convertarrow': <function convertarrow at 0x8240ca4>, 'convertHeader': <function convertHeader at 0x82406bc>, 'convertRow': <function convertRow at 0x8240924>, 'convertDocument': <function convertDocument at 0x8240684>, 'convertDefinitionItem': <function convertDefinitionItem at 0x82408ec>, 'convertDefinition': <function convertDefinition at 0x82408b4>, 'convertParagraph': <function convertParagraph at 0x824079c>, 'convertlink': <function convertlink at 0x8240a04>, 'convertpre': <function convertpre at 0x8240b8c>, 'converturl': <function converturl at 0x8240aac>, 'convertquote': <function convertquote at 0x8240b1c>, 'convertnewline': <function convertnewline at 0x8240c6c>, 'convertListItem': <function convertListItem at 0x8240844>, 'convertSection': <function convertSection at 0x824072c>, 'convertcode': <function convertcode at 0x8240bc4>, 'convertdots': <function convertdots at 0x8240cdc>, 'convertterm': <function convertterm at 0x8240ae4>, 'convertemdash': <function convertemdash at 0x8240d4c>, 'convertReferences': <function convertReferences at 0x8240764>}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Method headerCell

headerCell( self, x, y )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

str

'^\\s*([\\-\\+]+|[\\=\\+]+)\\s*$'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Method p_language

p_language( self, context, content )
Undocumented

Method getIndentation

getIndentation( self, text )

Returns the indentation of a string.

Basically if a string has the first three lines at the same identation level, then it is indentation will be the number of spaces or tabs that lead the first three lines.

Tabs have the value given by the TAB_SIZE variable.

SRE_Pattern

Compiled regular expression objects

Function convertterm

convertterm( element )
Undocumented

Function Upper

Upper( text )
Undocumented

Function convertmeta

convertmeta( element )
Undocumented

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

SRE_Pattern

Compiled regular expression objects

Function convertEntry

convertEntry( element )
Undocumented

Function convertHeading

convertHeading( element )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )

Tells wether the given block is recognised or not. This returns this block recognition information, or False (or None) if the block was not recongised.

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method parse

parse( self, context, node, recogniseInfo )

Parses the given tag, and returns the offset where the parsed tag ends. If the tag is an "inline block" tag, then its content is also parsed.

unicode

u'\\"'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Class PreBlockParser

Parses the content of a preformatted block, where every line is prefixed by > .

Function convertReferences

convertReferences( element )
Undocumented

Function convertListItem

convertListItem( element )
Undocumented

Class TitleBlockParser

Parses a title object

SRE_Pattern

Compiled regular expression objects

unicode

u'(^\\s*[^:{().<]*:)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method process

process( self, context, itemMatch )
Undocumented

Class PreInlineParser

Undocumented

Method __init__

__init__( self )
Undocumented

unicode

u'\\s*(\\w+)\\s*(\\((\\w+)\\))?'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method _parseNextInline

_parseNextInline( self, context, node, textProcessor )

Parses the content of the current block, starting at the context offset, modifying the given node and updating the context offset. This returns the a triple (offset, information, parser) where information is the result of the parser `recognises' method.

Method __init__

__init__( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method processText

processText( self, context, text )
Undocumented

SRE_Pattern

Compiled regular expression objects

Function convertemail

convertemail( element )
Undocumented

Function convertarrow

convertarrow( element )
Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Method isEndTag

isEndTag( self, match )
Undocumented

Method _getParentDefinition

_getParentDefinition( self, node )
Undocumented

Method getCommonPrefix

getCommonPrefix( self, linea, lineb )
Undocumented

str

'Title too deeply nested'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

SRE_Pattern

Compiled regular expression objects

Function convertDefinitionItem

convertDefinitionItem( element )
Undocumented

Function convertDocument

convertDocument( element )
Undocumented

Method __init__

__init__( self, name, regexp, result= at 0x4033595c>, requiresLeadingSpace=False )

Creates a new InlineParser.

Name is the name of the parser, regexp is the string expression of the regular expression that will match the element that the InlineParser is looking for, or regexp can also be a precompiled regular expression object.

Result is a lambda expression that will return the content of the Inline generated by the parse method. The lambda takes two arguments : the match object and the string in which the match object has been found.

Class TaggedBlockParser

Parses a tagged block. Notes are the common example of tagged block.

Method recognises

recognises( self, context )

Tells wether the given block is recognised or not. This returns this block recognition information, or False (or None) if the block was not recongised.

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

SRE_Pattern

Compiled regular expression objects

unicode

u'(\\w+)\\s*=\\s*(\'[^\']*\'|"[^"]*")'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function converturl

converturl( element )
Undocumented

Method processElement

processElement( self, element, selector=None )

Processes the given element according to the EXPRESSION_TABLE, using the given selector to select an alternative function.

Module kiwi.templates

The template module implements a simple way to convert an XML document to another format (HTML, text, whatever) by expanding very simple XPath-like expressions. Of course, it is a very-small subset of what you could do in XSLT, but it has a Python syntax and is very, very easy to use.

At first, your define convertXXX' functions where XXX is your case-sensitive tagName. All these functions should take an element as parameter and run the process' function with the element and template string as parameter.

Expressions like `$(XXX)' (XXX being the expression) in the template strings will be expanded by procesing the set of nodes indicated by the XXX expression.

  • $(*) will process all children
  • $(MyNode) will process only nodes with MyNode tagName
  • $(MyParent/MyNode) will process only the children of MyParent named MyNode
  • $(MyNode:alt) will use the function `convertMyNode_alt' instead of the default 'convertMyNode', if available. This allows to setup 'processing modes' for your document (like table of content, references, etc).
  • $(MyNode:alt?) will use the function convertMyNode_alt' if it is defined, or fallback to convertMyNode`.

Function convertpre

convertpre( element )
Undocumented

Function stringToTarget

stringToTarget( text )
Undocumented

unicode

u'^\\s*(([^_]+\\s*)(\\:[^_]+)?)?(____+)\\s*$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method p_markup

p_markup( self, context, content )

Parses custom markup and registers the new parsers in the current Kiwi parser

Method setTitle

setTitle( self, title )

Sets the title for this table.

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method parse

parse( self, text, offsets=False )

Parses the given text, and returns an XML document. If offsets is set to True, then all nodes of the document are annotated with their position in the original text as well with a number. The document will also have an offsets attribute that will contain a list of (start, end) offset tuples for each element.

SRE_Pattern

Compiled regular expression objects

Method __init__

__init__( self )
Undocumented

Method processText

processText( self, text )
Undocumented

Method process

process( self, context, match )
Undocumented

Method recognises

recognises( self, context )
Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u'^([^:]+(:\\s*\n\\s*|::\\s*))|([^/\\\\]+[/\\\\]\\s*\n\\s*)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Method warning

warning( self, message, context )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Method recognises

recognises( self, context )
Undocumented

Function convertdots

convertdots( element )
Undocumented

unicode

u'\\[([^\\]]+)\\]\\s*((\\(([^ \\)]+)(\\s+"([^"]+)"\\s*)?\\))|\\[([\\w\\s]+)\\])?'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Method __init__

__init__( self )
Undocumented

Class ReferenceEntryBlockParser

Parses the content of a Reference entry

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Method _parseNextBlock

_parseNextBlock( self, context, end=None )

Parses the block identified in the given context, ending at the given end (if end is not None).

unicode

u'(^|\n)\\s*([\\w\\-]+)\\s*:\\s*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function convertcode

convertcode( element )
Undocumented

Method __init__

__init__( self )
Undocumented

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

SRE_Pattern

Compiled regular expression objects

Method recognises

recognises( self, context )
Undocumented

Function convertCaption

convertCaption( element )
Undocumented

str

'converturl_header'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Module kiwi.kiwi2twiki

Undocumented

Function convertCell

convertCell( element )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Class MarkupInlineParser

Parses Kiwi generic markup elements.

Method processText

processText( self, context, text )
Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u'\\<([\\w.\\-_]+@[\\w.\\-_]+)\\>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function convertcitation

convertcitation( element )
Undocumented

Module kiwi.kiwi2html

Undocumented

Function stringToTarget

stringToTarget( text )
Undocumented

Method process

process( self, element, text )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

unicode

u'``((`?[^`])+)``'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Function converttitle_header

converttitle_header( element )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Class LinkInlineParser

Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method processText

processText( self, context, text )
Undocumented

Function convertemphasis

convertemphasis( element )
Undocumented

Function convertParagraph_cell

convertParagraph_cell( element )
Undocumented

Function convertTable

convertTable( element )
Undocumented

Method tip

tip( self, message, context )
Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u'^\\s*(--)([^\\:]+):(.+)?$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method p_type

p_type( self, context, content )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method generate

generate( self, xmlDocument, bodyOnly=False, variables={} )
Undocumented

Function converttarget

converttarget( element )
Undocumented

instance

Undocumented

Function convertterm

convertterm( element )
Undocumented

Method interpret

interpret( self, element, expression )

Interprets the given expression for the given element

Function convertemdash

convertemdash( element )
Undocumented

Function Markup_attributes

Markup_attributes( match )

Returns the attribute string of this markup stat element.

Function convertnewline

convertnewline( element )
Undocumented

Method p_abstract

p_abstract( self, context, content )
Undocumented

unicode

u'^\\s*[\\*\\-\\=#][\\*\\-\\=#][\\*\\-\\=#]+\\s*$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method _ensureCell

_ensureCell( self, x, y )

Ensures that the cell at the given position exists and returns its pair value.

unicode

u'\\s+\\[([^\\]]+)]:'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method createBlockParsers

createBlockParsers( self )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method recognises

recognises( self, context )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Function convertendash

convertendash( element )
Undocumented

Function convertSection

convertSection( element )
Undocumented

unicode

u'\\.\\.\\.()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Class Table

The table class allows to easily create tables and then generate the XML objects from them.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

SRE_Pattern

Compiled regular expression objects

Method __init__

__init__( self )
Undocumented

Method _updateElementOffsets

_updateElementOffsets( self, context, node=None, counter=0, offsets=None )

This function ensures that every element has a start and end attribute indicating the bit of original data it comes from.

unicode

u'^((\\s*\\>(\t| ))(.*)\n?)+'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

unicode

u'(&(\\w+|#[0-9]+);)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method findBlockEnd

findBlockEnd( self, context, indent )
Undocumented

Method __init__

__init__( self )
Undocumented

Method findEnd

findEnd( self, blockName, context, offsetIncr=0 )

Finds the end of the given markup end in the current block. Returns a couple (start, end) indicating the start and end offsets of the found end block, relative to the context offset. The given offsetIncr parameter tells the number of characters to skip before searching for the end markup. This has no impact on the result.

The context offsets are left unchanged.

tuple

(<class kiwi.inlines.InlineParser at 0x40338f5c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Function convertDefinitionItem

convertDefinitionItem( element )
Undocumented

Function convertDefinition

convertDefinition( element )
Undocumented
Classes
Values
CODE
DOTS
LINK
PRE
TERM
URL

Method generate

generate( self, xmlDocument, bodyOnly=False, variables={} )
Undocumented

dict

{'convertentity': <function convertentity at 0x823a95c>, 'convertsubtitle_header': <function convertsubtitle_header at 0x823a224>, 'convertDocument': <function convertDocument at 0x8230bc4>, 'convertcitation': <function convertcitation at 0x823a6f4>, 'convertCell': <function convertCell at 0x823a454>, 'converttarget': <function converttarget at 0x823a534>, 'converttitle_header': <function converttitle_header at 0x823a1ec>, 'convertemdash': <function convertemdash at 0x823a924>, 'convertHeading': <function convertHeading at 0x823a064>, 'convertBlock': <function convertBlock at 0x823a48c>, 'convertMeta': <function convertMeta at 0x823a56c>, 'convertstrong': <function convertstrong at 0x823a72c>, 'convertemail': <function convertemail at 0x823a5dc>, 'convertList': <function convertList at 0x823a2cc>, 'convertTable': <function convertTable at 0x823a33c>, 'convertendash': <function convertendash at 0x823a8ec>, 'convertbreak': <function convertbreak at 0x823a80c>, 'convertCaption': <function convertCaption at 0x823a3e4>, 'convertemphasis': <function convertemphasis at 0x823a7d4>, 'convertRow': <function convertRow at 0x823a41c>, 'convertarrow': <function convertarrow at 0x823a87c>, 'convertHeader_title': <function convertHeader_title at 0x823a1b4>, 'convertHeader': <function convertHeader at 0x823a02c>, 'convertContent_bodyonly': <function convertContent_bodyonly at 0x8230f7c>, 'convertParagraph_cell': <function convertParagraph_cell at 0x823a294>, 'convertContent_table': <function convertContent_table at 0x8230fb4>, 'convertContent': <function convertContent at 0x8230f44>, 'convertDefinition': <function convertDefinition at 0x823a374>, 'convertParagraph': <function convertParagraph at 0x823a25c>, 'convertlink': <function convertlink at 0x823a4fc>, 'convertpre': <function convertpre at 0x823a764>, 'convertEntry': <function convertEntry at 0x823a17c>, 'converturl_header': <function converturl_header at 0x823a64c>, 'converturl': <function converturl at 0x823a614>, 'convertquote': <function convertquote at 0x823a6bc>, 'convertnewline': <function convertnewline at 0x823a844>, 'convertListItem': <function convertListItem at 0x823a304>, 'convertSection': <function convertSection at 0x823a10c>, 'convertcode': <function convertcode at 0x823a79c>, 'convertdots': <function convertdots at 0x823a8b4>, 'convertterm': <function convertterm at 0x823a684>, 'convertDefinitionItem': <function convertDefinitionItem at 0x823a3ac>, 'convertmeta': <function convertmeta at 0x823a5a4>, 'convertReferences': <function convertReferences at 0x823a144>}

dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Method __init__

__init__( self )
Undocumented

Method recognises

recognises( self, context )
Undocumented

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

unicode

u'^(\\s*(\\:[^\\:]|[^\\:])+)\\:\\:+\\s*(\n+\\s*|\\s*\\|\\s*\n)*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Class TargetInlineParser

Undocumented

Function convertTable

convertTable( element )
Undocumented

Function converturl

converturl( element )
Undocumented

Function convertnewline

convertnewline( element )
Undocumented

Function escapeHTML

escapeHTML( text )
Undocumented

Class EscapedStringInlineParser

Undocumented

Method isHeader

isHeader( self, x, y )
Undocumented

Method p_last_mod

p_last_mod( self, context, content )
Undocumented

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

SRE_Pattern

Compiled regular expression objects

Method normaliseText

normaliseText( self, text )

Treats tabs eols and multiples spaces as single space, plus removes leading and trailing spaces.

unicode

u'^(\\=+\\s*).+$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method _parseDateToNode

_parseDateToNode( self, context, content, node )
Undocumented

Method __repr__

__repr__( self )
Undocumented

Class EscapedInlineParser

Undocumented

Method countLeadingSpaces

countLeadingSpaces( self, text )

Returns the number of leading spaces in the given line. A tab will have the value given by the TAB_SIZE global.

unicode

u"''(('?[^'])+)''"

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Function convertemail

convertemail( element )
Undocumented

Function convertlink

convertlink( element )
Undocumented

Method processText

processText( self, context, text )
Undocumented

SRE_Pattern

Compiled regular expression objects

Method expandTabs

expandTabs( self, text, cut=0 )

Expands the tabs in the given text, cutting the n first characters of each line, where n is given by the cut argument. This tabs expansion algorithm works better than Python line expansion algorithms.

Method p_keywords

p_keywords( self, context, content )
Undocumented

unicode

u'\\s*\\|\\s*\n()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method recognises

recognises( self, context )
Undocumented

Method getNode

getNode( self, context, processText )

Renders the table as a Kiwi XML document node.

Function convertlink

convertlink( element )
Undocumented

Module kiwi.formatting

Undocumented

Function converttarget

converttarget( element )
Undocumented

Function convertBlock

convertBlock( element )
Undocumented

Class Processor

Undocumented

Function convertHeader

convertHeader( element )
Undocumented

Function convertDocument

convertDocument( element )
Undocumented

Method isStartTag

isStartTag( self, match )
Undocumented

Method parse

parse( self, context, node, match )
Undocumented

Method isEndLine

isEndLine( self, context, line, indent )
Undocumented

Method process

process( self, context, match )
Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u'\\]>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function convertContent_table

convertContent_table( element )
Undocumented

Function convertDefinition

convertDefinition( element )
Undocumented

str

"Markup `%s' end found without previous markup start"

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

SRE_Pattern

Compiled regular expression objects

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method __init__

__init__( self )
Undocumented

Class ArrowInlineParser

Undocumented

Method _searchMarkup

_searchMarkup( self, context )

Looks for the next markup inline in the current context. This also takes care of markups that are contained into an escaped text tag.

WARNING : this operation mutates the context offsets, so this should always be enclosed in offset store and restore. The context offset is set BEFORE the searched markup, so that the returned recognition info is relative to the context offset.

Returns the result of this parser `recognise' method, or null.

Method process

process( self, context, recogniseInfo )
Undocumented

Method __init__

__init__( self, name )
Undocumented

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Method process

process( self, context, recogniseInfo )
Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u'`([^\\`]+)`'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function getSectionNumberPrefix

getSectionNumberPrefix( element )
Undocumented

SRE_Pattern

Compiled regular expression objects

Function convertParagraph

convertParagraph( element )
Undocumented

Function _processText

_processText( context, text )

Common operation for expanding tabs and normalising text. Use by acronyms, citations and quotes.

Function convertentity

convertentity( element )
Undocumented

Function convertstrong

convertstrong( element )
Undocumented

Method error

error( self, message, context )
Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u'\\*\\*([^*]+)\\*\\*'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method p_creation

p_creation( self, context, content )
Undocumented

Method dimension

dimension( self )
Undocumented

Method parse

parse( self, context, node, recogniseInfo )
Undocumented

SRE_Pattern

Compiled regular expression objects

tuple

('EN', 'FR', 'DE', 'UK')

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Class CommentInlineParser

Undocumented

Method processText

processText( self, context, text )
Undocumented

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Function convertParagraph

convertParagraph( element )
Undocumented

Function convertHeading

convertHeading( element )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

SRE_Pattern

Compiled regular expression objects

Class EntityInlineParser

Undocumented

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

unicode

u'\\w+\\s*=\\s*(\'[^\']*\'|"[^"]*")'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method _nodeHasOffsets

_nodeHasOffsets( self, node )
Undocumented

Function convertSection

convertSection( element )
Undocumented

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Function convertcode

convertcode( element )
Undocumented

Function wspan

wspan( element, text )

Wraps the given text in a SPAN extended with offsets attributes if the given element has offset attributes.

Method defaultProcessElement

defaultProcessElement( self, element, selector )

We override this for elements with the html attribute.

SRE_Pattern

Compiled regular expression objects

unicode

u'\\s*-\\s*"([^"]+)"\\s*[=:]\\s*([\\w\\-_]+)(\\s*\\(\\s*(\\w+)\\s*\\))?'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Class CommentBlockParser

Parses a comment markup block.

Method parse

parse( self, context, node, match )
Undocumented

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

SRE_Pattern

Compiled regular expression objects

Method removeLeadingSpaces

removeLeadingSpaces( self, text, maximum=None )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method __init__

__init__( self )
Undocumented

Method p_revision

p_revision( self, context, content )
Undocumented

unicode

u'^\\s*(==)([^=].+)$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function convertsubtitle_header

convertsubtitle_header( element )
Undocumented

Method defaultProcessElement

defaultProcessElement( self, element, selector )

Default function for processing elements. This returns the text.

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Function convertRow

convertRow( element )
Undocumented

Function convertbreak

convertbreak( element )
Undocumented

SRE_Pattern

Compiled regular expression objects

Method __init__

__init__( self )
Undocumented

Class SectionBlockParser

Parses a section markup element.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Method _nodeGetOffsets

_nodeGetOffsets( self, node )
Undocumented

unicode

u'\\<(\\w+)(\\s*\\w+\\s*=\\s*(\'[^\']*\'|"[^"]*"))*\\s*/?>|\\</(\\w+)\\s*>'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Function convertParagraph_cell

convertParagraph_cell( element )
Undocumented

Function convertHeader_title

convertHeader_title( element )
Undocumented

Function convertListItem

convertListItem( element )
Undocumented

unicode

u'\\\\"([^"]+)"'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Class ListItemBlockParser

Parses a list item. A list item is an element within a list.

Method recognises

recognises( self, context )
Undocumented

Method isStartLine

isStartLine( self, context, line )
Undocumented

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method _processLine

_processLine( self, line )
Undocumented

Method process

process( self, context, recogniseInfo )
Undocumented

Method __init__

__init__( self )
Undocumented

SRE_Pattern

Compiled regular expression objects

int

int(x, base) -> integer

Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

unicode

u'\\s*\\\\n\\s*()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method _propagateElementOffsets

_propagateElementOffsets( self, element, start=None, end=None )

Used by the _updateElementOffsets to ensure start and end offsets in all children and descendants.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

SRE_Pattern

Compiled regular expression objects

Method _recognisesBefore

_recognisesBefore( self, context, match )

A function that is called to check if the text before the current offset is recognized by this parser. This is used by requiresLeadingSpace.

Method recognises

recognises( self, context )
Undocumented

Method resolveSet

resolveSet( self, element, names )

Resolves the set of names in the given element. When "Paragraph"is given, then all child paragraph nodes of the current node will be returned, while "Section", "Paragraph"will return all paragraphs for all sections.

Function formatSectionNumber

formatSectionNumber( number )
Undocumented

Class BlockParser

Undocumented

Method __init__

__init__( self )
Undocumented

Method _goToParent

_goToParent( self, thisblock, parent )
Undocumented

Method parse

parse( self, context, node, recogniseInfo )

Parses the given context within the current block range, returning the new offset (relative to the block start offset, ie. the start of context.currentFragment). Note that the context offsets are the same as those given to the recognise method call which created recogniseInfo.

The given context starts at the same offset as when recognises was called. Modifications are made to the given node.

unicode

u'\xab([^\xbb]+)\xbb'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

SRE_Pattern

Compiled regular expression objects

Function element_number

element_number( element )

Utility function that returns the element number (part of the element offset attributes)

Method registerElementProcessor

registerElementProcessor( self, function, elementName, variant=None )

Registers the given function to process the given element name and the given optional variant.

Note that this will replace any previsously registered processor for the element and variant.

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Module kiwi.blocks

Write module doc here

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

Method __init__

__init__( self )
Undocumented

SRE_Pattern

Compiled regular expression objects

unicode

u'\\s*\n\\s*\\|\\s*\n()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method __init__

__init__( self )
Undocumented

str

'converturl'

str(object) -> string

Return a nice string representation of the object. If the argument is a string, the return value is the same object.

Method __init__

__init__( self, module=None )
Undocumented

Function convertstrong

convertstrong( element )
Undocumented

Method parseContext

parseContext( self, context )
Undocumented

SRE_Pattern

Compiled regular expression objects

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method parse

parse( self, context, node, match )
Undocumented

unicode

u'\\_([^_]+)_'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method p_reference

p_reference( self, context, content )
Undocumented

Function convertarrow

convertarrow( element )
Undocumented

Method processText

processText( self, context, text )
Undocumented

tuple

(<class kiwi.blocks.BlockParser at 0x822b29c>,)

tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items

If the argument is a tuple, the return value is the same object.

Method recognises

recognises( self, context )
Undocumented

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.

SRE_Pattern

Compiled regular expression objects

unicode

u' --- ()'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method recognises

recognises( self, context )

Recognises this inlines in the given context, within the current context block. It returns (None, None) when the inline was not recognised, otherwise it returns the offset of the matching element in the current context, plus information that will be given as argument to the parse method. This means that the returned offset is RELATIVE TO THE CURRENT CONTEXT OFFSET.

Method __init__

__init__( self )
Undocumented

Method _flatify

_flatify( self, text )
Undocumented

unicode

u'^\\s*((([0-9]+|[A-z])\\.)+([0-9]+|[A-z])?\\.?)'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

unicode

u'^(\\s*\\>(\t| ))(.*)$'

unicode(string , encoding[, errors]) -> object

Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding. errors can be strict, replace or ignore and defaults to strict.

Method charactersToSpaces

charactersToSpaces( self, text )

Returns a string where all characters are converted to spaces. Newlines and tabs are preserved

SRE_Pattern

Compiled regular expression objects

Function convertdots

convertdots( element )
Undocumented

Method endOf

endOf( self, recogniseInfo )

Returns the end of this inline using the given recogniseInfo.