    def get_string_or_element_for(self, store, page, name, keyword):
        """Resolve value of string or element function.

        We'll have something like this that represents all assignments on a
        given page:

        {1: ['First Header'], 3: ['Second Header'],
         4: ['Third Header', '3.5th Header']}

        Value depends on current page.
        https://drafts.csswg.org/css-gcpm/#funcdef-string

        :param dict store:
            Dictionary where the resolved value is stored.
        :param page:
            Current page.
        :param str name:
            Name of the named string or running element.
        :param str keyword:
            Indicates which value of the named string or running element to
            use. Default is the first assignment on the current page else the
            most recent assignment.
        :returns:
            Text for string set, box for running element.

        """
        if self.current_page in store[name]:
            # A value was assigned on this page
            first_string = store[name][self.current_page][0]
            last_string = store[name][self.current_page][-1]
            if keyword == 'first':
                return first_string
            elif keyword == 'start':
                element = page
                while element:
                    if element.style['string_set'] != 'none':
                        for (string_name, _) in element.style['string_set']:
                            if string_name == name:
                                return first_string
                    if element.children:
                        element = element.children[0]
                        continue
                    break
            elif keyword == 'last':
                return last_string
            elif keyword == 'first-except':
                return
        # Search backwards through previous pages
        for previous_page in range(self.current_page - 1, 0, -1):
            if previous_page in store[name]:
                return store[name][previous_page][-1]
Resolve value of string or element function.

We'll have something like this that represents all assignments on a
given page:

{1: ['First Header'], 3: ['Second Header'],
4: ['Third Header', '3.5th Header']}

Value depends on current page.
https://drafts.csswg.org/css-gcpm/#funcdef-string

:param dict store:
Dictionary where the resolved value is stored.
:param page:
Current page.
:param str name:
Name of the named string or running element.
:param str keyword:
Indicates which value of the named string or running element to
use. Default is the first assignment on the current page else the
most recent assignment.
:returns:
Text for string set, box for running element.
weasyprint/layout/__init__.py