# `RenderChain`

class mnemosyne.libmnemosyne.render_chain.RenderChain(component_manager)

  A RenderChain details the operations needed to get from the raw data in a card to a representation of its question and answer, in a form either suitable for displaying in a browser, or exporting to a text file, … .

  First the raw data is sent through Filters, which perform operations which can be useful for many card types, like expanding relative paths.

  Sometimes Mnemosyne will try to assemble the answer together with the question on a single page, e.g. if config()[“QA_split”] == “single_window”. For some Renderers where this does not make sense, e.g. the card browser, set ‘never_join_q_to_a = True’.

  Then this data is assembled in the right order in a Renderer, which can be card type specific.

  ‘filters’: list of Filter classes ‘renderers’: list or Renderer classes

  Plugins can add Filters or Renderers for a new card type to a chain at run time. In case the rendering of a card type does not fit comfortably in the scheme below, an alternative is to override ‘render_question’ and ‘render_answer’ in CardType directly.

  Each client should have a render chain with id=”default” on startup.

  component_type = 'render_chain'
  filter(filter_class)
  filters = []
  id = 'default'
  never_join_q_to_a = False
  register_filter(filter_class, in_front=False)

    ‘filter_class’ should be a class, not an instance.

  register_filter_at_back(filter_class, before=[])

    Register a filter at the back of the render chain, but before a list of other filters already in the chain. The list should contain class names. (Using strings instead of classes means a plugin writer does not need to import the filters he wants to use in this list.)

    ‘filter_class’ should be a class, not an instance.

  register_filter_at_front(filter_class, after=[])

    Register a filter at the very front of the render chain, but after a list of other filters already in the chain. The list should contain class names. (Using strings instead of classes means a plugin writer does not need to import the filters he wants to use in this list.)

    ‘filter_class’ should be a class, not an instance.

  register_renderer(renderer_class)

    ‘renderer_class’ should be a class, not an instance.

  render_answer(card, **render_args)
  render_question(card, **render_args)
  renderer_for_card_type(card_type)
  renderers = []
  unregister_filter(filter_class)

    ‘filter_class’ should be a class, not an instance.

  unregister_renderer(renderer_class)

    ‘renderer_class’ should be a class, not an instance.