# Path: handroll/signals.py

# 
# Path: handroll/exceptions.py
# class AbortError(Exception):
#     """Any fatal errors that would prevent handroll from proceeding should
#     signal with the ``AbortError`` exception."""
# 
# Path: handroll/i18n.py



from html import escape
from yaml.scanner import ScannerError
from handroll import signals
from handroll.exceptions import AbortError
from handroll.i18n import _
import io
import os
import yaml
                # This is a plain file so pull title from the first line.
                data['title'] = escape(first)
            else:
                f.seek(0)
                source = f.read()

        return data, source

    def _has_frontmatter(self, first_line):
        """Check if the document has any front matter. handroll only supports
        front matter from YAML documents."""
        return first_line.startswith(('%YAML', '---'))

    def _split_content_with_frontmatter(self, first, source, source_file):
        """Separate frontmatter from source material."""
        max_splits = 1
        # With a directive present, there must be two document markers.
        if first.startswith('%YAML'):
            max_splits = 2
        content = source.split(self.document_marker, max_splits)

        try:
            data = yaml.load(content[max_splits - 1])
        except ScannerError as ex:
            raise AbortError(_(
                'There is invalid YAML in the frontmatter: {details}').format(
                    details=str(ex)))
        try:
            source = content[max_splits]
        except IndexError:

# Path: handroll/signals.py

# 
# Path: handroll/exceptions.py
# class AbortError(Exception):
#     """Any fatal errors that would prevent handroll from proceeding should
#     signal with the ``AbortError`` exception."""
# 
# Path: handroll/i18n.py



# Path: handroll/composers/mixins.py
from html import escape
from yaml.scanner import ScannerError
from handroll import signals
from handroll.exceptions import AbortError
from handroll.i18n import _
import io
import os
import yaml

                # This is a plain file so pull title from the first line.
                data['title'] = escape(first)
            else:
                f.seek(0)
                source = f.read()

        return data, source

    def _has_frontmatter(self, first_line):
        """Check if the document has any front matter. handroll only supports
        front matter from YAML documents."""
        return first_line.startswith(('%YAML', '---'))

    def _split_content_with_frontmatter(self, first, source, source_file):
        """Separate frontmatter from source material."""
        max_splits = 1
        # With a directive present, there must be two document markers.
        if first.startswith('%YAML'):
            max_splits = 2
        content = source.split(self.document_marker, max_splits)

        try:
            data = yaml.load(content[max_splits - 1])
        except ScannerError as ex:
            raise AbortError(_(
                'There is invalid YAML in the frontmatter: {details}').format(
                    details=str(ex)))
        try:
            source = content[max_splits]
        except IndexError:

            raise AbortError(_('A YAML marker was missing in {source}').format(