示例#1
0
        public void TextWithUnparidTag_OriginalText()
        {
            var data = "Hello _my__ world";
            var markdown = new MarkdownFile(data);

            var actual = markdown.ToString();

            Assert.AreEqual(data, actual);
        }
示例#2
0
        public void TextWithTagInTag_OriginalText()
        {
            var data = "_Hello __my__ `very big` world_";
            var markdown = new MarkdownFile(data);

            var actual = markdown.ToString();

            Assert.AreEqual(data, actual);
        }
示例#3
0
        public void TextWithTagsList_OriginalText()
        {
            var data = "_Hello_ __my__ ___big___ world";
            var markdown = new MarkdownFile(data);

            var actual = markdown.ToString();

            Assert.AreEqual(data, actual);
        }
示例#4
0
        public static HtmlFile HtmlToMarkdown(MarkdownFile file)
        {
            string str = null;
            if (file.Text != null)
            {
                str = Regex.Replace(file.Text, @"\\<(.+?)\\>", "&lt;$1&gt;");
                str = Regex.Replace(str, @"\\([_`])", "$1");
            }
            var head = new HtmlFile(str, file.TypeTags);
            foreach (var e in file.СhildrenFiles)
                head.Add(HtmlToMarkdown(e));

            return head;
        }
示例#5
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Не передан параметр. Введите имя файла при запуске.");
                return;
            }
            var fileName = args[0];

            if (!File.Exists(fileName))
            {
                Console.WriteLine("Файл " + fileName + " не найден.");
                return;
            }
            var parseText = File.ReadAllText(fileName);

            var fileMarkdown = new MarkdownFile(parseText);

            var fileNameResult = fileName.Replace(".md", "") + ".html";

            var parseResult = Converter.HtmlToMarkdown(fileMarkdown).ToString();

            File.WriteAllText(fileNameResult, parseResult);
        }