# 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
# Copyright (c) 2017, Matt Layman





class FrontmatterComposerMixin(object):
    """Mixin the ability to extract frontmatter from a source file."""
    document_marker = '---' + os.linesep
    guess_title = True

    def get_data(self, source_file):
        """Get data and source from the source file."""
        data = {}
        with io.open(source_file, 'r', encoding='utf-8') as f:
            # The first line determines whether to look for front matter.
            first = f.readline().strip()
            source = f.read()

            if self._has_frontmatter(first):
                data, source = self._split_content_with_frontmatter(
                    first, source, source_file)

# 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

# Copyright (c) 2017, Matt Layman





class FrontmatterComposerMixin(object):
    """Mixin the ability to extract frontmatter from a source file."""
    document_marker = '---' + os.linesep
    guess_title = True

    def get_data(self, source_file):
        """Get data and source from the source file."""
        data = {}
        with io.open(source_file, 'r', encoding='utf-8') as f:
            # The first line determines whether to look for front matter.
            first = f.readline().strip()
            source = f.read()

            if self._has_frontmatter(first):
                data, source = self._split_content_with_frontmatter(
                    first, source, source_file)

                signals.frontmatter_loaded.send(source_file, frontmatter=data)