Skip to content

Inline filters #406

@cmahnke

Description

@cmahnke

Currently passing filters works by passing a list, this feels a bit clunky / sub optimal integrated...
Considering there is a package as pandocfilters, it should be possible to so something like this:

import pypandoc
from pathlib import Path
from pandocfilters import toJSONFilter, Str

def caps(key, value, format, meta):
  if key == 'Str':
    return Str(value.upper())

input = Path('somefile.md')
output = input.with_suffix('.docx')
pypandoc.convert_file(input, 'docx', outputfile=output, filters=[toJSONFilter(caps)])

(Pseudo code to illustrate how it might work. Copy and pasted from provided examples)

Or in short: It should be possible to pass a function or maybe a object as filter, while passing a string would work as it currently is

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