Example #1
0
        public void Test_Create_AddsParagraphTag_BeforeOthers()
        {
            var text = "coursive text bold";
            var markers = new List<Marker>
            {
                new Marker(0, 8, MarkerType.Coursive),
                new Marker(14, 18, MarkerType.Bold),
                new Marker(0, 18, MarkerType.Paragraph),
            };
            var expected = "<p><em>coursive</em> text <strong>bold</strong></p>";

            var htmlCreator = new HtmlCreator(text, markers);

            Assert.AreEqual(expected, htmlCreator.GetHtml());
        }
Example #2
0
        public void Test_Create_AddsTags_ForIntersectingManyMarkers()
        {
            var text = "coursive both bold";
            var markers = new List<Marker>
            {
                new Marker(0, 13, MarkerType.Coursive),
                new Marker(8, 18, MarkerType.Paragraph),
                new Marker(9, 18, MarkerType.Bold),
            };
            var expected = "<em>coursive<p> <strong>both</strong></p></em><p><strong> bold</strong></p>";

            var htmlCreator = new HtmlCreator(text, markers);

            Assert.AreEqual(expected, htmlCreator.GetHtml());
        }
Example #3
0
        public void Test_Create_AddsTags_ForAllMarkers()
        {
            var text = "just text: bold, coursive, code end";
            var markers = new List<Marker>
            {
                new Marker(0, 35, MarkerType.Paragraph),
                new Marker(11, 15, MarkerType.Bold),
                new Marker(17, 25, MarkerType.Coursive),
                new Marker(27, 31, MarkerType.Code),
            };
            var expected = "<p>just text: <strong>bold</strong>, <em>coursive</em>, <code>code</code> end</p>";

            var htmlCreator = new HtmlCreator(text, markers);

            Assert.AreEqual(expected, htmlCreator.GetHtml());
        }
Example #4
0
        public void Test_Create_RetunsSameText_IfMarkersListIsEmpty()
        {
            var text = "Hello, html!";
            var markers = new List<Marker>();
            var expected = text;

            var htmlCreator = new HtmlCreator(text, markers);

            Assert.AreEqual(expected, htmlCreator.GetHtml());
        }
Example #5
0
        public void Test_Create_EscapesTagsInText()
        {
            var text = "text and <tag>";
            var markers = new List<Marker>();
            var expected = "text and &lt;tag&gt;";

            var htmlCreator = new HtmlCreator(text, markers);

            Assert.AreEqual(expected, htmlCreator.GetHtml());
        }
Example #6
0
        public void Test_Create_AddsTags_ForMarkersWithSameStartAndEnd()
        {
            var text = "both bold coursive both";
            var markers = new List<Marker>
            {
                new Marker(0, 9, MarkerType.Bold),
                new Marker(0, 4, MarkerType.Coursive),
                new Marker(10, 23, MarkerType.Coursive),
                new Marker(19, 23, MarkerType.Bold),
            };
            var expected = "<strong><em>both</em> bold</strong> <em>coursive <strong>both</strong></em>";

            var htmlCreator = new HtmlCreator(text, markers);

            Assert.AreEqual(expected, htmlCreator.GetHtml());
        }
 public string ConvertMarkdownToHtml(string markdown)
 {
     var parser = new Parser(markdown);
     var htmlCreator = new HtmlCreator(parser.GetResultText(), parser.GetResultMarkers());
     return htmlCreator.GetHtml();
 }