# Path: weasyprint/logger.py
# LOGGER = logging.getLogger('weasyprint')


import copy
from ..logger import LOGGER
        elif anchor_token[0] == 'url' and anchor_token[1][0] == 'internal':
            return anchor_token[1][1]

    def collect_anchor(self, anchor_name):
        """Create a TargetLookupItem for the given `anchor_name``."""
        if anchor_name and isinstance(anchor_name, str):
            if self.target_lookup_items.get(anchor_name) is not None:
                LOGGER.warning('Anchor defined twice: %r', anchor_name)
            else:
                self.target_lookup_items.setdefault(
                    anchor_name, TargetLookupItem())

    def lookup_target(self, anchor_token, source_box, css_token, parse_again):
        """Get a TargetLookupItem corresponding to ``anchor_token``.

        If it is already filled by a previous anchor-element, the status is
        'up-to-date'. Otherwise, it is 'pending', we must parse the whole
        tree again.

        """
        anchor_name = self.anchor_name_from_token(anchor_token)
        item = self.target_lookup_items.get(
            anchor_name, TargetLookupItem('undefined'))

        if item.state == 'pending':
            self.had_pending_targets = True
            item.parse_again_functions.setdefault(
                (source_box, css_token), parse_again)

        if item.state == 'undefined':

# Path: weasyprint/logger.py
# LOGGER = logging.getLogger('weasyprint')


# Path: weasyprint/css/targets.py
import copy
from ..logger import LOGGER

        elif anchor_token[0] == 'url' and anchor_token[1][0] == 'internal':
            return anchor_token[1][1]

    def collect_anchor(self, anchor_name):
        """Create a TargetLookupItem for the given `anchor_name``."""
        if anchor_name and isinstance(anchor_name, str):
            if self.target_lookup_items.get(anchor_name) is not None:
                LOGGER.warning('Anchor defined twice: %r', anchor_name)
            else:
                self.target_lookup_items.setdefault(
                    anchor_name, TargetLookupItem())

    def lookup_target(self, anchor_token, source_box, css_token, parse_again):
        """Get a TargetLookupItem corresponding to ``anchor_token``.

        If it is already filled by a previous anchor-element, the status is
        'up-to-date'. Otherwise, it is 'pending', we must parse the whole
        tree again.

        """
        anchor_name = self.anchor_name_from_token(anchor_token)
        item = self.target_lookup_items.get(
            anchor_name, TargetLookupItem('undefined'))

        if item.state == 'pending':
            self.had_pending_targets = True
            item.parse_again_functions.setdefault(
                (source_box, css_token), parse_again)

        if item.state == 'undefined':

            LOGGER.error(