def process_flagged_blocks(self, content: str) -> str:
        '''Replace flagged blocks either with their contents or nothing, depending on the value
        of ``FOLIANT_FLAGS`` environment variable and ``flags`` config value.

        :param content: Markdown content

        :returns: Markdown content without flagged blocks
        '''

        def _sub(flagged_block):
            options = self.get_options(flagged_block.group('options'))

            required_flags = {
                flag.lower()
                for flag in re.split(self._flag_delimiters, options.get('flags', ''))
                if flag
            } | {
                f'target:{target.lower()}'
                for target in re.split(self._flag_delimiters, options.get('targets', ''))
                if target
            } | {
                f'backend:{backend.lower()}'
                for backend in re.split(self._flag_delimiters, options.get('backends', ''))
                if backend
            }

            env_flags = {
                flag.lower()
                for flag in re.split(self._flag_delimiters, getenv(self._flags_envvar, ''))
                if flag
            }

            config_flags = {flag.lower() for flag in self.options['flags']}

            set_flags = env_flags \
                | config_flags \
                | {f'target:{self.context["target"]}', f'backend:{self.context["backend"]}'}

            kind = options.get('kind', 'all')

            if (kind == 'all' and required_flags <= set_flags) \
                or (kind == 'any' and required_flags & set_flags) \
                or (kind == 'none' and not required_flags & set_flags):
                return flagged_block.group('body').strip()

            else:
                return ''

        return self.pattern.sub(_sub, content)
Replace flagged blocks either with their contents or nothing, depending on the value
        of ``FOLIANT_FLAGS`` environment variable and ``flags`` config value.

        :param content: Markdown content

        :returns: Markdown content without flagged blocks