Markup Transformers
inyoka.markup.transformers
This module holds ast transformers we use. Transformers can assume that they always operate on complete trees, thus the outermost node is always a container node.
Transformers are not necessarily the last thing that processes a tree. For example macros that are marked as tree processors and have have their stage attribute set to ‘final’ are expanded after all the transformers finished their job.
- copyright:
2007-2024 by the Inyoka Team, see AUTHORS for more details.
- license:
BSD, see LICENSE for more details.
- class inyoka.markup.transformers.AutomaticParagraphs
This transformer is enabled per default and wraps elements in paragraphs. All macros and parsers depend on this parser so it’s a terrible idea to disable this one.
- joined_text_iter(node)
This function joins multiple text nodes that follow each other into one.
- transform(parent)
Insert real paragraphs into the node and return it.
- class inyoka.markup.transformers.AutomaticStructure
This transformer adds additional structure information. Each headline adds either a new section or subsection depending on its level.
- transform(tree)
This is passed a tree that should be processed. A class can modify a tree in place, the return value has to be the tree then. Otherwise, it’s safe to return a new tree.
- class inyoka.markup.transformers.FootnoteSupport
Looks for footnote nodes, gives them a unique id and moves the text to the bottom into a list. Without this translator footnotes are just <small>ed and don’t have an id.
- transform(tree)
This is passed a tree that should be processed. A class can modify a tree in place, the return value has to be the tree then. Otherwise, it’s safe to return a new tree.
- class inyoka.markup.transformers.HeadlineProcessor
This transformer looks at all headlines and makes sure that every ID is unique. If one id clashes with another headline ID a numeric suffix is added. What this transformer does not do is resolving clashes with footnotes or other references. At least not by now because such clashes are very unlikely.
- transform(tree)
This is passed a tree that should be processed. A class can modify a tree in place, the return value has to be the tree then. Otherwise, it’s safe to return a new tree.
- class inyoka.markup.transformers.KeyHandler
Removes unused paragraphs around key templates.
- transform(tree, nested=False)
This is passed a tree that should be processed. A class can modify a tree in place, the return value has to be the tree then. Otherwise, it’s safe to return a new tree.
- class inyoka.markup.transformers.SmileyInjector
Adds smilies from the configuration.
- _convert_to_regional_indicator(country_code)
A two char ASCII string (country_code) will be converted to two regional indicator symbols. Most browsers will display these regional indicators as flags. See https://en.wikipedia.org/wiki/Regional_Indicator_Symbol
- _new_smiley_node(match)
- smiley_re
As DEFAULT_TRANSFORMERS instances this class and it’s passed around, this property will be cached until the python process dies.
- smilies = {'# 8)': '😎', '# <8-} ': 'css-class:icon-frog-xmas', '--': '–', '->': '→', '8-)': '😎', '8-o': '😲', '8-}': '🐸', ':!:': '❗', ':(': '☹', ':)': '☺', ':-$': '😳', ':-(': '☹', ':-)': '☺', ':->': '😊', ':-?': '😕', ':-D': '😀', ':-O': '😮', ':-P': '😛', ':-[]': '😬', ':-o': '😮', ':-x': '😠', ':-|': '😐', ':?': '😕', ':?:': '❓', ':???:': '⁇', ':D': '😀', ':P': '😛', ':[]': '😬', ':arrow:': '▶', ':backarrow:': '◀', ':cool:': '😎', ':cry:': '😢', ':eek:': '😮', ':ente:': '🦆', ':grin:': '😀', ':idea:': '💡', ':lol:': '🤣', ':mad:': '😠', ':mrgreen:': '😀', ':neutral:': '😐', ':o': '😮', ':oops:': '😳', ':razz:': '😛', ':roll:': '🙄', ':sad:': '☹', ':shock:': '😲', ':smile:': '☺', ':thumbsup:': '👍', ':tux:': 'css-class:icon-tux', ':wink:': '😉', ':x': '😠', ':|': '😐', ';)': '😉', ';-(': '😢', ';-)': '😉', '<-': '←', '<3': '♥', '<=': '⇐', '=>': '⇒', 'O:-)': '😇', ']:-(': '👿', ']:-)': '😈', '{*}': 'css-class:icon-ubuntu', '{dl}': '⮷', '{g}': 'css-class:icon-ubuntugnome', '{k}': 'css-class:icon-kubuntu', '{l}': 'css-class:icon-lubuntu', '{ma}': 'css-class:icon-ubuntumate', '{m}': 'css-class:icon-mythbuntu', '{ut}': 'css-class:icon-ubuntutouch', '{x}': 'css-class:icon-xubuntu', '{Übersicht}': 'css-class:icon-overview', '§)': '🤓'}
- transform(tree)
This is passed a tree that should be processed. A class can modify a tree in place, the return value has to be the tree then. Otherwise, it’s safe to return a new tree.