:py:mod:`oioioi.portals.widgets` ================================ .. py:module:: oioioi.portals.widgets Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.portals.widgets.PortalInlineGrammar oioioi.portals.widgets.PortalRenderer oioioi.portals.widgets.PortalInlineLexer oioioi.portals.widgets.PortalBlockLexer oioioi.portals.widgets.PortalMarkdown oioioi.portals.widgets.YouTubeWidget oioioi.portals.widgets.ProblemTableWidget oioioi.portals.widgets.RedirectWidget Functions ~~~~~~~~~ .. autoapisummary:: oioioi.portals.widgets.render_panel oioioi.portals.widgets.register_widget Attributes ~~~~~~~~~~ .. autoapisummary:: oioioi.portals.widgets.REGISTERED_WIDGETS oioioi.portals.widgets._block_spoiler_leading_pattern .. py:data:: REGISTERED_WIDGETS :annotation: = [] .. py:data:: _block_spoiler_leading_pattern .. py:class:: PortalInlineGrammar Bases: :py:obj:`mistune.InlineGrammar` Grammars for inline level tokens. .. py:class:: PortalRenderer(**kwargs) Bases: :py:obj:`mistune.Renderer` The default HTML renderer for rendering Markdown. .. py:method:: block_center(text) .. py:method:: block_spoiler(summary, body) .. py:method:: table(header, body) Rendering table element. Wrap header and body in it. :param header: header part of the table. :param body: body part of the table. .. py:class:: PortalInlineLexer(request, renderer, rules=None, **kwargs) Bases: :py:obj:`mistune.InlineLexer` Inline level lexer for inline grammars. .. py:attribute:: default_rules .. py:class:: PortalBlockLexer(*args, **kwargs) Bases: :py:obj:`mistune.BlockLexer` Block level lexer for block grammars. .. py:attribute:: default_rules .. py:method:: parse_block_center(m) .. py:method:: parse_block_spoiler(m) .. py:class:: PortalMarkdown(request) Bases: :py:obj:`mistune.Markdown` The Markdown parser. :param renderer: An instance of ``Renderer``. :param inline: An inline lexer class or instance. :param block: A block lexer class or instance. .. py:method:: output_block_center() .. py:method:: output_block_spoiler() .. py:function:: render_panel(request, panel) .. py:function:: register_widget(widget) Register markdown tag for a portal widget. See ``mistune`` docs for more info. :type widget: object containing the following: * :attr:`widget.name` - name of the widget * :attr:`widget.compiled_tag_regex` - compiled regular expression pattern used for identifying markdown tag * :meth:`widget.render` - method (or just function) accepting corresponding :class:`re.MatchObject` instance as the only parameter (named 'm'). Should return a string (rendered widget). .. py:class:: YouTubeWidget Bases: :py:obj:`object` .. py:attribute:: name :annotation: = youtube .. py:attribute:: compiled_tag_regex .. py:method:: render(request, m) .. py:class:: ProblemTableWidget Bases: :py:obj:`object` .. py:attribute:: name :annotation: = problem_table .. py:attribute:: compiled_tag_regex .. py:method:: site_key_from_link(link) :staticmethod: .. py:method:: parse_problems(m) :staticmethod: .. py:method:: get_problem_ids(m) .. py:method:: render(request, m) .. py:class:: RedirectWidget Bases: :py:obj:`object` .. py:attribute:: name :annotation: = redirect .. py:attribute:: compiled_tag_regex .. py:method:: render(request, match) :staticmethod: