# Path: engine/conf.py
# PATH_TO_IMG = PATH + '/notes/'
# 
# PATH_TO_MD = PATH + '/notes/'
# 
# PATH_TO_ORIG = PATH + "/engine/data/orig/"


from engine.conf import PATH_TO_IMG, PATH_TO_MD, PATH_TO_ORIG
                from Bio.Seq import Seq
                from Bio.Alphabet import generic_dna, generic_protein
import re
import os
import codecs
import glob
import logging
                        next(f)  # skip first line? hack to get rid of # Title of the note
                    txt = f.read()
                    # remove table of content for this included note
                    txt = txt.replace('{{TOC}}', '')
                    txt = txt.replace('[tableofcontent]', '')
                    nmd += '<p><div class="alert alert-info">Imported <a href="http://127.0.0.1:5000/view/' + mdname + '">' + mdname + '</a></div></p>'
                    nmd += '\n' + txt + '\n'
            else:
                nmd = '@error The file can not be found: ' + l + '\n' + nmd  # at this info at the beginning of the file


        else:
            nmd += l + '\n'
    if imported_files_list:
        nmd = '```\n' + imported_files_list + '```\n' + nmd # add list pre
    return nmd


def include_file(text):
    """This is to import any file. If you want to import a note form your Geekbook use

    include_md_files()
    """
    ntext = ''

    for l in text.split('\n'):
        if l.strip().startswith('[if:'):
            file_fn = l.replace('[if:', '').replace(']', '').strip()
            ntext += '<kbd> Imported file: %s </kbd>\n' % file_fn
            try:

# Path: engine/conf.py
# PATH_TO_IMG = PATH + '/notes/'
# 
# PATH_TO_MD = PATH + '/notes/'
# 
# PATH_TO_ORIG = PATH + "/engine/data/orig/"


# Path: engine/preprocessing.py
from engine.conf import PATH_TO_IMG, PATH_TO_MD, PATH_TO_ORIG
                from Bio.Seq import Seq
                from Bio.Alphabet import generic_dna, generic_protein
import re
import os
import codecs
import glob
import logging

                        next(f)  # skip first line? hack to get rid of # Title of the note
                    txt = f.read()
                    # remove table of content for this included note
                    txt = txt.replace('{{TOC}}', '')
                    txt = txt.replace('[tableofcontent]', '')
                    nmd += '<p><div class="alert alert-info">Imported <a href="http://127.0.0.1:5000/view/' + mdname + '">' + mdname + '</a></div></p>'
                    nmd += '\n' + txt + '\n'
            else:
                nmd = '@error The file can not be found: ' + l + '\n' + nmd  # at this info at the beginning of the file


        else:
            nmd += l + '\n'
    if imported_files_list:
        nmd = '```\n' + imported_files_list + '```\n' + nmd # add list pre
    return nmd


def include_file(text):
    """This is to import any file. If you want to import a note form your Geekbook use

    include_md_files()
    """
    ntext = ''

    for l in text.split('\n'):
        if l.strip().startswith('[if:'):
            file_fn = l.replace('[if:', '').replace(']', '').strip()
            ntext += '<kbd> Imported file: %s </kbd>\n' % file_fn
            try:

                with codecs.open(PATH_TO_MD + os.sep + file_fn, "r", "utf-8") as f: