public void TextWithUnparidTag_OriginalText() { var data = "Hello _my__ world"; var markdown = new MarkdownFile(data); var actual = markdown.ToString(); Assert.AreEqual(data, actual); }
public void TextWithTagInTag_OriginalText() { var data = "_Hello __my__ `very big` world_"; var markdown = new MarkdownFile(data); var actual = markdown.ToString(); Assert.AreEqual(data, actual); }
public void TextWithTagsList_OriginalText() { var data = "_Hello_ __my__ ___big___ world"; var markdown = new MarkdownFile(data); var actual = markdown.ToString(); Assert.AreEqual(data, actual); }
public static HtmlFile HtmlToMarkdown(MarkdownFile file) { string str = null; if (file.Text != null) { str = Regex.Replace(file.Text, @"\\<(.+?)\\>", "<$1>"); str = Regex.Replace(str, @"\\([_`])", "$1"); } var head = new HtmlFile(str, file.TypeTags); foreach (var e in file.СhildrenFiles) head.Add(HtmlToMarkdown(e)); return head; }
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); }