Hi,
I want add markdown.extensions.footnotes
extensions to misago,Is there any way to do that.
Hi,
I want add markdown.extensions.footnotes
extensions to misago,Is there any way to do that.
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)
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'
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
.
May be this is a bug.And I don't includ function name.
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.
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.
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.
Rest Framework has dependency on Python Markdown?
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
.