<commit_before>"""Insert the demo into the codemirror site."""
from __future__ import print_function

import os
import fileinput
import shutil

proselint_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

code_mirror_path = os.path.join(
    proselint_path,
    "plugins",
    "webeditor")

code_mirror_demo_path = os.path.join(code_mirror_path, "index.html")

live_write_path = os.path.join(proselint_path, "site", "write")

shutil.copytree(code_mirror_path, live_write_path)

demo_path = os.path.join(proselint_path, "proselint", "demo.md")

with open(demo_path, "r") as f:
    demo = f.read()

for line in fileinput.input(
        os.path.join(live_write_path, "index.html"), inplace=True):

    if "##DEMO_PLACEHOLDER##" in line:
        print(demo, end=' ')
    else:
        print(line, end=' ')<commit_msg>Delete live writing demo before loading new one<commit_after>"""Insert the demo into the codemirror site."""
from __future__ import print_function

import os
import fileinput
import shutil

proselint_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

code_mirror_path = os.path.join(
    proselint_path,
    "plugins",
    "webeditor")

code_mirror_demo_path = os.path.join(code_mirror_path, "index.html")

live_write_path = os.path.join(proselint_path, "site", "write")

if os.path.exists(live_write_path):
    shutil.rmtree(live_write_path)
shutil.copytree(code_mirror_path, live_write_path)

demo_path = os.path.join(proselint_path, "proselint", "demo.md")

with open(demo_path, "r") as f:
    demo = f.read()

for line in fileinput.input(
        os.path.join(live_write_path, "index.html"), inplace=True):

    if "##DEMO_PLACEHOLDER##" in line:
        print(demo, end=' ')
    else:
        print(line, end=' ')
{'fraction_non_alphanumeric': 0.13355970571590267, 'fraction_numerical': 0.0, 'mean_word_length': 4.630573248407643, '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': '4855670', 'n_tokens_mistral': 652, 'n_tokens_neox': 651, 'n_words': 130}