Skip to content

2.2.0

Compare
Choose a tag to compare
@sergiocorreia sergiocorreia released this 14 Jul 04:11
· 37 commits to master since this release

The run_filters() function, as well as .walk() method now support as optional argument a stop_if function. If this argument is used and not none, then .walk() will not walk through an element's children if stop_if(element) is True.

This has two uses:

  1. We can speed up filters by avoiding going too deep into the document's tree. For instance:
def stop_if(elem):
    return isinstance(elem, pf.Inline)

Will stop walking the tree once it reaches an inline element

  1. Some filters become easier to write, because we can just act on a main element such as Table and then by hand call .walk() to each table component

This also simplifies possible stringify() improvements, as discussed in #218 and illustrated in c8b4365 for DefinitionList elements

Other minor changes:

  • Simplified element.walk() code and added .walk() methods to ListContainer and DictContainer
  • Minor code cleanup to reduce pycodestyle warnings