• Members 17 posts
    Sept. 19, 2018, 10:20 a.m.

    Hi,
    I want add markdown.extensions.footnotes extensions to misago,Is there any way to do that.

  • Sept. 20, 2018, 6:51 p.m.

    Extending markup is documented here.

    Your function will have to look like this:

    from markdown.extensions.footnotes import FootnoteExtension
    
    footnote_extension = FootnoteExtension()
    
    
    def extend_markdown(md):
        footnote_extension.extendMarkdown(md)
    
  • Members 17 posts
    Sept. 21, 2018, 5:37 a.m.

    Hi, I did exactly the same as you, but I was given an error.

    django_1    |   File "/app/misago/markup/api.py", line 23,in parse_markup
    django_1    | force_shva=True,
    django_1    |   File "/app/misago/markup/flavours.py", line 20, in common
    django_1    |     force_shva=force_shva,
    django_1    |   File "/app/misago/markup/parser.py", line 51, in parse
    django_1    |     allow_blocks=allow_blocks,
    django_1    |   File "/app/misago/markup/parser.py", line 151, in md_factory
    django_1    |     return pipeline.extend_markdown(md)
    django_1    |   File "/app/misago/markup/pipeline.py", line 18, in extend_markdown
    django_1    |     hook.extend_markdown(md)
    django_1    | AttributeError: 'function' object has no attribute 'extend_markdown'
    
  • Sept. 21, 2018, 11:16 a.m.

    The error is telling you that you have included function name at the end of python path to your markup extension, eg: my.python.path.extend_markdown. It should be just my.python.path.

  • Members 17 posts
    Sept. 22, 2018, 11:59 a.m.

    May be this is a bug.And I don't includ function name.

  • Members 17 posts
    Sept. 22, 2018, 4:10 p.m.

    Hi, @rafalp

    class MarkupPipeline(object):
        """small framework for extending parser"""
    
        def extend_markdown(self, md):
            for extension in settings.MISAGO_MARKUP_EXTENSIONS:
                module = import_module(extension)
                if hasattr(module, 'extend_markdown'):
                    hook = getattr(module, 'extend_markdown')
                    hook.extend_markdown(md)
            return md
        ......
    

    in extend_markdown function, I think hook is a function, so hook.extend_markdown(md) is wrong, it should be hook(md).

    By the way, markdown has upgrade to 3.0, Maybe we should follow up.

  • Sept. 22, 2018, 10:54 p.m.

    Yup, that looks like a bug, PR welcome, we may release it as 0.19.3 ;)

    As for updating dep to latest version, thats doable but seeing how its breaking change we would have to pull it under 0.20 release.

  • Members 17 posts
    Sept. 25, 2018, 11:05 a.m.

    Hi,
    I tried to fix it, but footnotes, or other extensions, have an extra parameter md_globals, so even if I fix this small problem, still can't add the markdown extensions. And I tried to upgrade markdown to 3.0, the result will be a small bug in rest_framework,

    check this:#6203

    so maybe we should wait for the associated plugin to upgrade to fix this problem.

  • Sept. 26, 2018, 11 a.m.

    so maybe we should wait for the associated plugin to upgrade to fix this problem.

    I would still open PR fixing the call to user-defined extend_markdown function, so we give this hatch for users wanting to run custom code against Markdown instance used by Misago to parse messages.

    My dev machine is currently in repair, so I can't look at what's happening here myself - but I would like to revisit this issue myself eventually and see whats happening in Markdown extensions currently.

    Misago also uses extensions mechanics for adding custom items to message parser (eg. our BBCode support), so there is a way to extend the md.