Skip to content

Prevent recursion into returned object #72

Open
@garethstockwell

Description

@garethstockwell

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions