Esempio n. 1
0
        public void Handle_HandleTheScreening()
        {
            var h = new EmHandler();

            h.Handle(@"fr \_ddd\_ _dd_")
            .ShouldBeEquivalentTo("fr _ddd_ <em>dd</em>");
        }
Esempio n. 2
0
        public void SplitLineOnIndexes_ShouldSplitCorrect()
        {
            var h = new EmHandler();

            h.SplitLineOnIndexes("123 _6789_ ", new [] { 3, 7 })
            .ShouldBeEquivalentTo(new [] { "123", " _67", "89_ " });
        }
Esempio n. 3
0
        public void Split_IsCorrect()
        {
            var h  = new Handler();
            var em = new EmHandler();

            h.GetIndexesForSplit(@"ab \_dd\_ ff", em.IsCorrectStart, em.IsCorrectFinish)
            .ShouldBeEquivalentTo(new int[0]);
        }
Esempio n. 4
0
        public void Handle_ReplaceSimpleTag()
        {
            var handler  = new EmHandler();
            var markdown = "_abs_";
            var html     = "<em>abs</em>";

            handler.Handle(markdown)
            .ShouldBeEquivalentTo(html);
        }
Esempio n. 5
0
        public void Split_ShouldSplit_OnUnderscore2()
        {
            var handler  = new EmHandler();
            var markdown = "ab _abs __fr__ e_ de";
            var result   = new[] { "ab ", "_abs __fr__ e_", " de" };

            handler.Split(markdown)
            .ShouldBeEquivalentTo(result);
        }
Esempio n. 6
0
        public string RenderToHtml(string markdown)
        {
            var emHandler     = new EmHandler();
            var strongHandler = new StrongHandler();

            var splitedLine = emHandler.Split(markdown);
            var html        = splitedLine.Select(line =>
            {
                if (line.StartsWith("_") && line.EndsWith("_"))
                {
                    var emHtml = "<em>" + line.Trim('_') + "</em>";
                    return(emHandler.RemoveScreening(emHtml));
                }
                return(strongHandler.Handle(line));
            }).ToArray();

            return(String.Join("", html));
        }