Skip to content

Improve runtime for parent element context checking #190

Closed

Description

@chrispy-snps

There are various places where conversion functions must know about their parent/ancestor context, such as:

  • Performing inline (single-line) text conversion in <h1>-<h6> and <th>/<td> tags
  • Suppressing formatting inside <pre>, <code>, <kbd>, and <samp> tags
  • Avoiding newline collapsing in <pre> tags

The current code uses Beautiful Soup's find_parent() method to check the parent/ancestor context. However, this imposes runtime overhead, particularly for content with nontrivial content (such as nested <div>, <section>, and <article> hierarchy).

This enhancement issue requests that context be propagated downward instead of checked upward. Because only a single level is added for each downward traversal, instead of checking all ancestors upward, complexity would be reduced from O(n!) to O(n).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions