# 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

            if self._has_frontmatter(first):
                data, source = self._split_content_with_frontmatter(
                    first, source, source_file)
                signals.frontmatter_loaded.send(source_file, frontmatter=data)
            elif self.guess_title:
                # 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:

# 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


            if self._has_frontmatter(first):
                data, source = self._split_content_with_frontmatter(
                    first, source, source_file)
                signals.frontmatter_loaded.send(source_file, frontmatter=data)
            elif self.guess_title:
                # 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(_(