<commit_before># -*- coding: utf-8 -*-
"""
Created on Fri Oct 23 18:52:28 2015

@author: jessime
"""

import sys
import markdown

from flask import Flask, Markup, render_template, redirect, request


from pick_file import pick
from state import Tutorial, Data
from level_markdown import split

from webbrowser import open_new_tab

def markup_str(string):
    """Prepares a markdown formatted string for insertion into jinja template."""
    markup = Markup(markdown.markdown(string))
    return markup

app = Flask(__name__)

@app.route("/")
def index():
    return render_template('index.html')

@app.route('/about')
def about():
    return render_template('about.html')

@app.route('/elements')
def elements():
    return render_template('elements.html')

@app.route('/launch', methods=['GET','POST'])
def launch():
    if request.method == 'POST':
        pass
    infile = 'static/story/level1.md'
    no_markup = {'title', 'subtitle', 'img'}
    sections = split(infile)
    sections = {k:markup_str(v) if (k not in no_markup) else v for k,v in sections.items()}
    sections['hint_solved1'] = True
    sections['hint_solved2'] = True
    sections['hint_solved3'] = True

    return render_template('level_content.html', **sections)
<commit_msg>New function name for level_markdown<commit_after># -*- coding: utf-8 -*-
"""
Created on Fri Oct 23 18:52:28 2015

@author: jessime
"""

import sys
import markdown

from flask import Flask, Markup, render_template, redirect, request


from pick_file import pick
from state import Tutorial, Data
from level_markdown import parse

from webbrowser import open_new_tab

def markup_str(string):
    """Prepares a markdown formatted string for insertion into jinja template."""
    markup = Markup(markdown.markdown(string))
    return markup

app = Flask(__name__)

@app.route("/")
def index():
    return render_template('index.html')

@app.route('/about')
def about():
    return render_template('about.html')

@app.route('/elements')
def elements():
    return render_template('elements.html')

@app.route('/launch', methods=['GET','POST'])
def launch():
    if request.method == 'POST':
        pass
    infile = 'static/story/level1.md'
    no_markup = {'title', 'subtitle', 'img'}
    sections = parse(infile)
    sections = {k:markup_str(v) if (k not in no_markup) else v for k,v in sections.items()}
    sections['hint_solved1'] = True
    sections['hint_solved2'] = True
    sections['hint_solved3'] = True

    return render_template('level_content.html', **sections)

{'fraction_non_alphanumeric': 0.13555291319857313, 'fraction_numerical': 0.013476020610384463, 'mean_word_length': 4.404710920770878, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6467380', 'n_tokens_mistral': 830, 'n_tokens_neox': 780, 'n_words': 228}