# Path: peanut/meta_yaml.py
# class MetaYamlExtension (Extension):
#     """Extension for parsing YAML-Metadata with Python-Markdown."""
# 
#     def extendMarkdown(self, md, md_globals):
#         """Add MetaYamlPreprocessor to Markdown instance."""
#         md.preprocessors.add("meta_yaml", MetaYamlPreprocessor(md), "_begin")


import os
import six
import re
import markdown
import datetime
import logging
from six import with_metaclass
from peanut.meta_yaml import MetaYamlExtension
class MarkdownReader(with_metaclass(Singleton, Reader)):
    """Markdown reader
    """

    regex = re.compile(r'([^/]+)\.(MD|md|[mM]arkdown)')

    # Meta data parser
    _meta_parser = {
        'tags': parser_list,
        'category': parser_single,
        'date': parser_date,
        'publish': parser_bool,
        'top': parser_bool,
        'image': parser_single,
    }

    def __init__(self):
        self.md_parser = MarkdownReader.__create_md_reader()

    @classmethod
    def __create_md_reader(cls):
        """Create markdown parser
        """

        extensions = [
            'markdown.extensions.fenced_code',  # Fenced Code Blocks
            'markdown.extensions.codehilite',   # CodeHilite
            'markdown.extensions.footnotes',    # Footnotes
            'markdown.extensions.tables',       # Tables
            'markdown.extensions.toc',          # Table of Contents

# Path: peanut/meta_yaml.py
# class MetaYamlExtension (Extension):
#     """Extension for parsing YAML-Metadata with Python-Markdown."""
# 
#     def extendMarkdown(self, md, md_globals):
#         """Add MetaYamlPreprocessor to Markdown instance."""
#         md.preprocessors.add("meta_yaml", MetaYamlPreprocessor(md), "_begin")


# Path: peanut/reader.py
import os
import six
import re
import markdown
import datetime
import logging
from six import with_metaclass
from peanut.meta_yaml import MetaYamlExtension

class MarkdownReader(with_metaclass(Singleton, Reader)):
    """Markdown reader
    """

    regex = re.compile(r'([^/]+)\.(MD|md|[mM]arkdown)')

    # Meta data parser
    _meta_parser = {
        'tags': parser_list,
        'category': parser_single,
        'date': parser_date,
        'publish': parser_bool,
        'top': parser_bool,
        'image': parser_single,
    }

    def __init__(self):
        self.md_parser = MarkdownReader.__create_md_reader()

    @classmethod
    def __create_md_reader(cls):
        """Create markdown parser
        """

        extensions = [
            'markdown.extensions.fenced_code',  # Fenced Code Blocks
            'markdown.extensions.codehilite',   # CodeHilite
            'markdown.extensions.footnotes',    # Footnotes
            'markdown.extensions.tables',       # Tables
            'markdown.extensions.toc',          # Table of Contents

            MetaYamlExtension(),                # Meta-YAML