Remove $this->in_anchor #125

Closed
yuanzhou opened this Issue Aug 19, 2013 · 5 comments

Comments

Projects
None yet
2 participants
@yuanzhou

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

@michelf

This comment has been minimized.

Show comment
Hide comment
@michelf

michelf Aug 19, 2013

Owner

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

Owner

michelf commented Aug 19, 2013

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

@yuanzhou

This comment has been minimized.

Show comment
Hide comment
@yuanzhou

yuanzhou Aug 19, 2013

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.

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.

@michelf

This comment has been minimized.

Show comment
Hide comment
@michelf

michelf Aug 19, 2013

Owner

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.

Owner

michelf commented Aug 19, 2013

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.

@yuanzhou

This comment has been minimized.

Show comment
Hide comment
@yuanzhou

yuanzhou Aug 19, 2013

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.

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.

@michelf

This comment has been minimized.

Show comment
Hide comment
@michelf

michelf Aug 19, 2013

Owner

You're welcome.

Owner

michelf commented Aug 19, 2013

You're welcome.

@michelf michelf closed this Aug 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment