Markup Parsers
inyoka.markup.parsers
Parsers can process contents inside parser blocks. Unlike macros the possibilities of parsers regarding tree processing are very limited. They can only return subtrees (which are inserted at the parser block position) or render data dynamically on page rendering.
This means that they are also unable to both render data dynamically and emit metadata. This functionallity is reserverd for macros.
Beside that all features of macros also affect parsers just that they are passed the wrapper data which they can process.
- copyright:
2007-2024 by the Inyoka Team, see AUTHORS for more details.
- license:
BSD, see LICENSE for more details.
- inyoka.markup.parsers.ALL_PARSERS = {'code': <class 'inyoka.markup.parsers.PygmentsParser'>, 'csv': <class 'inyoka.markup.parsers.CSVParser'>, 'vorlage': <class 'inyoka.markup.parsers.TemplateParser'>}
list of all parsers this wiki can handle
- class inyoka.markup.parsers.CSVParser(*args, **orig_kw)
Parse csv files and format it as table.
- build_node(context=None, format=None)
If this is a static parser this method has to return a node. If it’s a runtime parser a context and format parameter is passed.
- is_static = True
if a parser is static this has to be true.
- class inyoka.markup.parsers.Parser(*args, **orig_kw)
baseclass for parsers. Concrete parsers should either subclass this or implement the same attributes and methods.
- arguments = ()
the arguments this parser accepts
- build_node(context=None, format=None)
If this is a static parser this method has to return a node. If it’s a runtime parser a context and format parameter is passed.
- is_block_tag = True
True if this parser returns a block level element on dynamic rendering. This does not affect static rendering.
- is_static = False
if a parser is static this has to be true.
- render(context, format)
Dispatch to the correct render method.
- class inyoka.markup.parsers.PygmentsParser(*args, **orig_kw)
Enable sourcecode highlighting.
- arguments = (('syntax', <class 'str'>, 'text'),)
the arguments this parser accepts
- build_node(context=None, format=None)
If this is a static parser this method has to return a node. If it’s a runtime parser a context and format parameter is passed.
- is_static = True
if a parser is static this has to be true.
- class inyoka.markup.parsers.TemplateParser(data, args, kwargs)
Works exactly like the template macro just with the difference that the body of the parser is passed as first argument.
As such the following two pieces of code do the very same:
[[Vorlage(Foo, " Hello World ")]] {{{ #!Vorlage Foo Hello World }}}
- build_node(context=None, format=None)
If this is a static parser this method has to return a node. If it’s a runtime parser a context and format parameter is passed.
- has_argument_parser = True
- is_static = True
if a parser is static this has to be true.
- inyoka.markup.parsers.get_parser(name, args, kwargs, data)
Instantiate a new parser or return None if it doesn’t exist.