本文整理汇总了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));
}
示例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));
}
示例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=\"/Attachments/folder/myfile.jpg\">Some link text</a> <a href=\"/Attachments/folder2/myfile.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);
}
示例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://www.google.com/?blah=xyz#myanchor\" class=\"external-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);
}
示例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));
}
示例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.");
}
示例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=\"/wiki/Special: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);
}
示例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=\"/wiki/1/foo-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);
}
示例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=\"#myanchortag\">hello world</a>\n</p>";
// Act
string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]]");
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml));
}
示例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://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.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);
}
示例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://www.blah.com\" class=\"external-link\">link1</a> <a rel=\"nofollow\" href=\"www.blah.com\" class=\"external-link\">link2</a> <a rel=\"nofollow\" href=\"mailto:spam@gmail.com\" class=\"external-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));
}
示例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=\"/Attachments/my/folder/image1.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);
}
示例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://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx\" class=\"external-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);
}
示例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=\"#myanchortag\">hello world</a> <a href=\"https://www.google.com/some-page-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));
}
示例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=\"#myanchortag\">hello world</a>\n</p>";
// Act
string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]]");
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml));
}