<commit_before>"use strict";

var m          = require("mithril"),
    editor     = require("codemirror"),
    Remarkable = require("remarkable"),

    hide  = require("./lib/hide"),
    label = require("./lib/label"),
    
    css = require("./markdown.css"),

    md = new Remarkable();

require("codemirror/mode/markdown/markdown");

module.exports = {
    controller : function(options) {
        var ctrl = this;

        ctrl.markdown = options.data || "";
        ctrl.previewing = false;
        ctrl.previewHTML = null;

        ctrl.togglePreview = function(e) {
            e.preventDefault();

            ctrl.previewHTML = md.render(ctrl.markdown);
            ctrl.previewing = !ctrl.previewing;
        };

        ctrl.editorChanged = function() {
            ctrl.markdown = ctrl.editor.doc.getValue();

            options.update(options.path, ctrl.markdown);
        };

        ctrl.editorSetup = function(el, init) {
            if(init) {
                return;
            }

            ctrl.editor = editor.fromTextArea(el, {
                mode : "text/x-markdown",

                indentUnit   : 4,
                lineWrapping : true
            });

            ctrl.editor.on("changes", ctrl.editorChanged);
        };
    },

    view : function(ctrl, options) {
        var hidden  = hide(options);

        if(hidden) {
            return hidden;
        }

        return m("div",
            label(ctrl, options),
            m("div", { class : ctrl.previewing ? css.inputHidden : css.input },
                m("textarea", { config : ctrl.editorSetup },
                    ctrl.markdown
                )
            ),
            m("div", { class : ctrl.previewing ? css.input : css.inputHidden },
                m.trust(ctrl.previewHTML)
            ),
            m("button.pure-button", {
                    onclick : ctrl.togglePreview,
                    class   : css.button
                },
                ctrl.previewing ? "Edit" : "Preview"
            )
        );
    }
};
<commit_msg>Generate id for markdown type<commit_after>"use strict";

var m          = require("mithril"),
    editor     = require("codemirror"),
    Remarkable = require("remarkable"),
    
    id    = require("./lib/id"),
    hide  = require("./lib/hide"),
    label = require("./lib/label"),
    
    css = require("./markdown.css"),

    md = new Remarkable();

require("codemirror/mode/markdown/markdown");

module.exports = {
    controller : function(options) {
        var ctrl = this;
        
        ctrl.id       = id(options);
        ctrl.markdown = options.data || "";
        ctrl.previewing = false;
        ctrl.previewHTML = null;

        ctrl.togglePreview = function(e) {
            e.preventDefault();

            ctrl.previewHTML = md.render(ctrl.markdown);
            ctrl.previewing = !ctrl.previewing;
        };

        ctrl.editorChanged = function() {
            ctrl.markdown = ctrl.editor.doc.getValue();

            options.update(options.path, ctrl.markdown);
        };

        ctrl.editorSetup = function(el, init) {
            if(init) {
                return;
            }

            ctrl.editor = editor.fromTextArea(el, {
                mode : "text/x-markdown",

                indentUnit   : 4,
                lineWrapping : true
            });

            ctrl.editor.on("changes", ctrl.editorChanged);
        };
    },

    view : function(ctrl, options) {
        var hidden  = hide(options);

        if(hidden) {
            return hidden;
        }

        return m("div",
            label(ctrl, options),
            m("div", { class : ctrl.previewing ? css.inputHidden : css.input },
                m("textarea", { config : ctrl.editorSetup },
                    ctrl.markdown
                )
            ),
            m("div", { class : ctrl.previewing ? css.input : css.inputHidden },
                m.trust(ctrl.previewHTML)
            ),
            m("button.pure-button", {
                    onclick : ctrl.togglePreview,
                    class   : css.button
                },
                ctrl.previewing ? "Edit" : "Preview"
            )
        );
    }
};

{'fraction_non_alphanumeric': 0.1308500477554919, 'fraction_numerical': 0.0004775549188156638, 'mean_word_length': 1.4241898148148149, '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': '1963775', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1102, 'n_words': 198}