Skip to content

Plugin output is not being rendered #702

Description

@jessicah

Describe the bug

context
I've written a port of markdown-it-abbr to python, but when used with MyST-Parser, the replacement tokens are missing, due to an error of WARNING: No render method for: abbr [myst.render].

expectation
In the rendered HTML, I expected the <abbr> HTML tag and content to be output.

E.g. the following markdown:

*[HTML]: HyperText Markup Language
*[W3C]: World Wide Web Consortium

The HTML specification is maintained by the W3C.

should generate:

<p>The <abbr title="HyperText Markup Language'>HTML</abbr> specification is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.</p>

bug
Instead, it generates:

<p>The specification is maintained by the .</p>

I added print(nodes) at https://github.com/jessicah/mdit-py-abbr/blob/main/mdit_py_abbr/index.py#L157, and it showed up fine in console:

[Token(type='text', tag='', nesting=0, attrs={}, map=None, level=0, children=None, content='The ', markup='', info='', meta={}, block=False, hidden=False), Token(type='abbr_open', tag='abbr', nesting=1, attrs={'title': 'HyperText Markup Language'}, map=None, level=0, children=None, content='', markup='', info='', meta={}, block=False, hidden=False), Token(type='text', tag='', nesting=0, attrs={}, map=None, level=0, children=None, content='HTML', markup='', info='', meta={}, block=False, hidden=False), Token(type='abbr_close', tag='abbr', nesting=-1, attrs={}, map=None, level=0, children=None, content='', markup='', info='', meta={}, block=False, hidden=False), Token(type='text', tag='', nesting=0, attrs={}, map=None, level=0, children=None, content=' specification is maintained by the ', markup='', info='', meta={}, block=False, hidden=False), Token(type='abbr_open', tag='abbr', nesting=1, attrs={'title': 'World Wide Web Consortium'}, map=None, level=0, children=None, content='', markup='', info='', meta={}, block=False, hidden=False), Token(type='text', tag='', nesting=0, attrs={}, map=None, level=0, children=None, content='W3C', markup='', info='', meta={}, block=False, hidden=False), Token(type='abbr_close', tag='abbr', nesting=-1, attrs={}, map=None, level=0, children=None, content='', markup='', info='', meta={}, block=False, hidden=False), Token(type='text', tag='', nesting=0, attrs={}, map=None, level=0, children=None, content='.', markup='', info='', meta={}, block=False, hidden=False)]

So the token stream itself seems correct. Also, using markdown-it-py directly works correctly.

I did try adding a render method, but it had no effect. E.g.:

md.add_render_rule("abbr", abbr_render)

and

def abbr_render(self, tokens, idx, options, env):
    return f'<abbr title="{tokens[idx].attrGet("title")}">{tokens[idx].content}</abbr>'

Reproduce the bug

I've created an example repo: https://github.com/jessicah/myst-demo

make [all] runs sphinx-build, and make test runs the test file.

List your environment

myst_parser: 0.18.1
sphinx: 5.3.0
docutils: 0.17.1
markdown_it: 1.1.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions