Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove $this->in_anchor #125

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

Remove $this->in_anchor #125

yuanzhou opened this issue Aug 19, 2013 · 5 comments

Comments

@yuanzhou
Copy link

$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
Copy link
Owner

michelf commented Aug 19, 2013

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

@yuanzhou
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
Owner

michelf commented Aug 19, 2013

You're welcome.

@michelf michelf closed this as completed Aug 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants