当前位置: 首页>>代码示例>>C#>>正文


C# MarkupConverter.ToHtml方法代码示例

本文整理汇总了C#中Roadkill.Core.Converters.MarkupConverter.ToHtml方法的典型用法代码示例。如果您正苦于以下问题:C# MarkupConverter.ToHtml方法的具体用法?C# MarkupConverter.ToHtml怎么用?C# MarkupConverter.ToHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Roadkill.Core.Converters.MarkupConverter的用法示例。


在下文中一共展示了MarkupConverter.ToHtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Internal_Links_Should_Resolve_With_Id

		public void Internal_Links_Should_Resolve_With_Id()
		{
			// Bug #87

			// Arrange
			Page page = new Page() { Id = 1, Title = "My first page" };

			RepositoryMock repositoryStub = new RepositoryMock();
			repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
			repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

			ApplicationSettings settings = new ApplicationSettings();
			settings.Installed = true;
			settings.UpgradeRequired = false;

			UrlResolverMock resolver = new UrlResolverMock();
			resolver.InternalUrl = "blah";
			MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);
			converter.UrlResolver = resolver;

			string markdownText = "[Link](My-first-page)";
			string invalidMarkdownText = "[Link](My first page)";

			// Act
			string expectedHtml = "<p><a href=\"blah\">Link</a></p>\n";
			string expectedInvalidLinkHtml = "<p>[Link](My first page)</p>\n";

			string actualHtml = converter.ToHtml(markdownText);
			string actualHtmlInvalidLink = converter.ToHtml(invalidMarkdownText);

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
			Assert.That(actualHtmlInvalidLink, Is.EqualTo(expectedInvalidLinkHtml));
		}
开发者ID:35e8,项目名称:roadkill,代码行数:34,代码来源:MarkdownTests.cs

示例2: Code_Blocks_Should_Allow_Quotes

        public void Code_Blocks_Should_Allow_Quotes()
        {
            // Issue #82
            // Arrange
            Page page = new Page() { Id = 1, Title = "My first page" };

            RepositoryMock repositoryStub = new RepositoryMock();
            repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
            repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

            ApplicationSettings settings = new ApplicationSettings();
            settings.Installed = true;
            settings.UpgradeRequired = false;

            MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);

            string markdownText = "Here is some `// code with a 'quote' in it and another \"quote\"`\n\n" +
                "    var x = \"some tabbed code\";\n\n"; // 2 line breaks followed by 4 spaces (tab stop) at the start indicates a code block

            string expectedHtml = "<p>Here is some <code>// code with a 'quote' in it and another \"quote\"</code></p>\n\n" +
                                "<pre><code>var x = \"some tabbed code\";\n" +
                                "</code></pre>\n";

            // Act
            string actualHtml = converter.ToHtml(markdownText);

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:29,代码来源:MarkdownTests.cs

示例3: Attachment_Link_Should_Not_Have_NoFollow_Attribute

        public void Attachment_Link_Should_Not_Have_NoFollow_Attribute()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"&#x2F;Attachments&#x2F;folder&#x2F;myfile&#x2E;jpg\">Some link text</a> <a href=\"&#x2F;Attachments&#x2F;folder2&#x2F;myfile&#x2E;jpg\">Some link text</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[~/folder/myfile.jpg|Some link text]] [[attachment:/folder2/myfile.jpg|Some link text]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
开发者ID:baskint,项目名称:roadkill,代码行数:14,代码来源:MarkupConverterTests.cs

示例4: External_Links_With_Anchor_Tag_Should_Retain_The_Anchor

        public void External_Links_With_Anchor_Tag_Should_Retain_The_Anchor()
        {
            // Issue #172
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _repository.AddNewPage(new Page() { Id = 1, Title = "foo" }, "foo", "admin", DateTime.Today);
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a rel=\"nofollow\" href=\"http&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;&#x3F;blah&#x3D;xyz&#x23;myanchor\" class=\"external&#x2D;link\">Some link text</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[http://www.google.com/?blah=xyz#myanchor|Some link text]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
开发者ID:baskint,项目名称:roadkill,代码行数:16,代码来源:MarkupConverterTests.cs

示例5: Html_Should_Not_Be_Sanitized_If_UseHtmlWhiteList_Setting_Is_False

        public void Html_Should_Not_Be_Sanitized_If_UseHtmlWhiteList_Setting_Is_False()
        {
            // Arrange
            _applicationSettings.UseHtmlWhiteList = false;
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string htmlFragment = "<div onclick=\"javascript:alert('ouch');\">test</div>";
            MarkupConverter converter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            // Act
            string actualHtml = converter.ToHtml(htmlFragment);

            // Assert
            string expectedHtml = "<p>" + htmlFragment + "\n</p>";
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
开发者ID:baskint,项目名称:roadkill,代码行数:17,代码来源:MarkupConverterTests.cs

示例6: imageparsed_should_convert_to_absolute_path

		public void imageparsed_should_convert_to_absolute_path()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Markdown";
			UrlResolverMock resolver = new UrlResolverMock();
			resolver.AbsolutePathSuffix = "123";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);
			_markupConverter.UrlResolver = resolver;

			// Act
			bool wasCalled = false;
			_markupConverter.Parser.ImageParsed += (object sender, ImageEventArgs e) =>
			{
				wasCalled = (e.Src == "/Attachments/DSC001.jpg123");
			};

			_markupConverter.ToHtml("![Image title](/DSC001.jpg)");

			// Assert
			Assert.True(wasCalled, "ImageParsed.ImageEventArgs.Src did not match.");
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:21,代码来源:MarkupConverterTests.cs

示例7: specialurl_link_should_not_have_nofollow_attribute

		public void specialurl_link_should_not_have_nofollow_attribute()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;Special&#x3A;Random\">Some link text</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[Special:Random|Some link text]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:14,代码来源:MarkupConverterTests.cs

示例8: internal_wiki_page_link_should_not_have_nofollow_attribute

		public void internal_wiki_page_link_should_not_have_nofollow_attribute()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_pageRepository.AddNewPage(new Page() { Id = 1, Title = "foo-page" }, "foo", "admin", DateTime.Today);
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;1&#x2F;foo&#x2D;page\">Some link text</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[foo-page|Some link text]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:15,代码来源:MarkupConverterTests.cs

示例9: links_to_named_anchors_should_not_have_external_css_class

		public void links_to_named_anchors_should_not_have_external_css_class()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"&#x23;myanchortag\">hello world</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:14,代码来源:MarkupConverterTests.cs

示例10: Links_With_The_Word_Script_In_Url_Should_Not_Be_Cleaned

        public void Links_With_The_Word_Script_In_Url_Should_Not_Be_Cleaned()
        {
            // Issue #159
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"http&#x3A;&#x2F;&#x2F;msdn&#x2E;microsoft&#x2E;com&#x2F;en&#x2D;us&#x2F;library&#x2F;system&#x2E;componentmodel&#x2E;descriptionattribute&#x2E;aspx\">ComponentModel.Description</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx|ComponentModel.Description]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
开发者ID:Kiresorg,项目名称:roadkill,代码行数:15,代码来源:MarkupConverterTests.cs

示例11: links_starting_with_http_www_mailto_tag_are_no_rewritten_as_internal

		public void links_starting_with_http_www_mailto_tag_are_no_rewritten_as_internal()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"http&#x3A;&#x2F;&#x2F;www&#x2E;blah&#x2E;com\" class=\"external&#x2D;link\">link1</a> <a rel=\"nofollow\" href=\"www&#x2E;blah&#x2E;com\" class=\"external&#x2D;link\">link2</a> <a rel=\"nofollow\" href=\"mailto&#x3A;spam&#x40;gmail&#x2E;com\" class=\"external&#x2D;link\">spam</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[http://www.blah.com|link1]] [[www.blah.com|link2]] [[mailto:[email protected]|spam]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:14,代码来源:MarkupConverterTests.cs

示例12: links_starting_with_attachmentcolon_should_resolve_as_attachment_paths

		public void links_starting_with_attachmentcolon_should_resolve_as_attachment_paths()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;Attachments&#x2F;my&#x2F;folder&#x2F;image1&#x2E;jpg\">hello world</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[attachment:/my/folder/image1.jpg|hello world]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:14,代码来源:MarkupConverterTests.cs

示例13: links_with_the_word_script_in_url_should_not_be_cleaned

		public void links_with_the_word_script_in_url_should_not_be_cleaned()
		{
			// Issue #159
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"http&#x3A;&#x2F;&#x2F;msdn&#x2E;microsoft&#x2E;com&#x2F;en&#x2D;us&#x2F;library&#x2F;system&#x2E;componentmodel&#x2E;descriptionattribute&#x2E;aspx\" class=\"external&#x2D;link\">ComponentModel.Description</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx|ComponentModel.Description]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:15,代码来源:MarkupConverterTests.cs

示例14: Links_With_Dashes_Or_23_Are_Rewritten_And_Not_Parsed_As_Encoded_Hashes

        public void Links_With_Dashes_Or_23_Are_Rewritten_And_Not_Parsed_As_Encoded_Hashes()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"&#x23;myanchortag\">hello world</a> <a href=\"https&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;some&#x2D;page&#x2D;23\">google</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]] [[https://www.google.com/some-page-23|google]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
开发者ID:Kiresorg,项目名称:roadkill,代码行数:14,代码来源:MarkupConverterTests.cs

示例15: Links_To_Named_Anchors_Should_Not_Have_External_CSS_Class

        public void Links_To_Named_Anchors_Should_Not_Have_External_CSS_Class()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a rel=\"nofollow\" href=\"&#x23;myanchortag\">hello world</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
开发者ID:baskint,项目名称:roadkill,代码行数:14,代码来源:MarkupConverterTests.cs


注:本文中的Roadkill.Core.Converters.MarkupConverter.ToHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。