Skip to content


Remove $this->in_anchor #125

yuanzhou opened this Issue · 5 comments

2 participants


$this->in_anchor is used as a status flag to avoid invalid nesting in doAnchors(). The problem I see is this variable does nothing.


What do you mean by "this variable does nothing", you've just explained what it does.


Here is my understanding:

protected function doAnchors($text) {
    if ($this->in_anchor) return $text;
    $this->in_anchor = true;

    // code

    $this->in_anchor = false;
    return $text;

By default, $this->in_anchor is defined as protected and it's set to false, so this function will never change the value of $this->in_anchor.


But note that this function is called recursively when processing the textual content of the link. See the call to $this->runSpanGamut($link_text) in the two callbacks below it, which, in turn, will call doAnchor again.


Got it. Thanks a lot for the explanation. I had this question when I thought to change $in_anchor to a local variable. Now I'll put it back as a class property.


You're welcome.

@michelf michelf closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.