Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent recursion into returned object #72

Open
garethstockwell opened this issue Oct 23, 2018 · 1 comment
Open

Prevent recursion into returned object #72

garethstockwell opened this issue Oct 23, 2018 · 1 comment

Comments

@garethstockwell
Copy link

Is there any way to prevent recursion into the object returned by a filter?

For example:

from pandocfilters import Link, Str

def my_filter(key, value, format, meta):
    if key == 'Str':
        if 'something' in value:
            return Link(attr, [Str(value)], 'my_target')

The above will result in infinite recursion into the string. One possible solution would be to introduce pseudo-types NoFilterInline and NoFilterBlock, which cause pandocfilters.walk to abort recursion down a path of the AST:

from pandocfilters import NoFilterInline, Link, Str

def my_filter(key, value, format, meta):
    if key == 'Str':
        if 'something' in value:
            return Link(attr, [NoFilterInline([Str(value)])], 'my_target')

Is there a better solution?

@jgm
Copy link
Owner

jgm commented Oct 23, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants