Skip to content

Walker enters infinite loop. #660

Answered by colinodell
fiddlerwoaroof asked this question in Q&A
Discussion options

You must be logged in to vote

The walker emits two events for the Emphasis object: once when it enters, and again when it leaves. Your code is adding a new Text element both times and continuously resetting the walker's position just prior to it exiting the Emphasis object. Two iterations later it's exiting the Emphasis again, and your code adds the Text and resets the position again. This cycle repeats indefinitely.

Try modifying your debug code to something like this:

  $direction = $event->isEntering() ? "Entering" : "Leaving";
  $nodeClass = get_class($node);
  printf("%s the %s element\n", $direction, $nodeClass);

And you'll see the following output:

Entering the League\CommonMark\Block\Element\Document element
E…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by colinodell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question General questions about the project or usage
2 participants
Converted from issue

This discussion was converted from issue #231 on June 12, 2021 14:09.