Exemple #1
0
        public EditorControl()
        {
            InitializeComponent();
            // http://stackoverflow.com/questions/4823468/comments-in-markdown
            // (empty line)
            // [comment]: # (This actually is the most platform independent comment)

            // https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
            // I didn't implement the Youtube video option
            operations.Add("H1", "# ");
            operations.Add("H2", "## ");
            operations.Add("H3", "### ");
            operations.Add("H4", "#### ");
            operations.Add("H5", "##### ");
            operations.Add("H6", "###### ");
            operations.Add("Alt-H1", string.Empty, t => { return("\r\n" + new string('=', t.Length)); });
            operations.Add("Alt-H2", string.Empty, t => { return("\r\n" + new string('-', t.Length)); });
            operations.Add("Italic", "_", "_");
            operations.Add("Bold", "**", "**");
            operations.Add("Strike", "~~", "~~");
            operations.Add("HR", "\r\n----");
            operations.Add("Link", t => { return(LinkForm.CreateLinkText()); }, string.Empty);
            operations.Add("Ordered List", "1. ");
            operations.Add("Unordered List", "+ ");
            operations.Add("Image", t => { return(ImageForm.CreateImageText(Path.GetDirectoryName(fileName))); }, string.Empty);
            operations.Add("Code", t => { return(CodeForm.CreateLanguageText()); }, "\n```");
            operations.Add("Quote", t => { StringBuilder sb = new StringBuilder("\n" + t); sb.Replace("\n", "\n> "); return(sb.ToString().TrimStart().TrimEnd(new char[] { '\n', '>', ' ' })); }, string.Empty);
            operations["Quote"].KeepOriginal = false;
            operations.Add("Dictionary", "<dl>\n", "</dl>");
            operations.Add("Definition", t => { return(DefinitionForm.CreateDefinitionText()); }, string.Empty);
            operations.Add("Header", t => { return(TableForm.CreateTableText()); }, string.Empty);
            operations.Add("Row", string.Empty, t =>
            {
                int cols = t.Occurrences('|') + 1; if (t.StartsWith("|"))
                {
                    cols--;
                }
                if (t.TrimEnd().EndsWith("|"))
                {
                    cols--;
                }
                StringBuilder sb = new StringBuilder("\n|"); for (int i = 0; i < cols; i++)
                {
                    sb.Append("value|");
                }
                return(sb.ToString());
            });
            operations.Add("Task", "- [ ]", string.Empty);

            autoSaveTimer          = new Timer();
            autoSaveTimer.Tick    += AutoSaveTimer_Tick;
            autoSaveTimer.Interval = 3000;
            autoSaveTimer.Enabled  = false;
        }
Exemple #2
0
        public static string CreateDefinitionText()
        {
            string rtnVal = string.Empty;

            DefinitionForm form = new DefinitionForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                rtnVal = string.Format("<dt>{0}</dt>\n<dd>{1}</dd>\n", form.Term, form.Meaning);
            }
            return(rtnVal);
        }