本文整理汇总了C#中MarkdownSharp.Markdown.Transform方法的典型用法代码示例。如果您正苦于以下问题:C# MarkdownSharp.Markdown.Transform方法的具体用法?C# MarkdownSharp.Markdown.Transform怎么用?C# MarkdownSharp.Markdown.Transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarkdownSharp.Markdown
的用法示例。
在下文中一共展示了MarkdownSharp.Markdown.Transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AboutVoodoo
public AboutVoodoo()
{
InitializeComponent();
try
{
Assembly assembly = Assembly.GetExecutingAssembly();
Stream textStream = assembly.GetManifestResourceStream("VoodooUI.Resources.about.md");
StreamReader textStreamReader = new StreamReader(textStream);
String text = new StreamReader(textStream).ReadToEnd();
MarkdownSharp.MarkdownOptions mdopt = new MarkdownSharp.MarkdownOptions();
mdopt.AutoHyperlink = true; mdopt.LinkEmails = true;
MarkdownSharp.Markdown parser = new MarkdownSharp.Markdown(mdopt);
text = parser.Transform(text);
webBrowser1.DocumentText = text;
textStreamReader.Close();
}
catch (Exception exc)
{
webBrowser1.DocumentText = "Voodoo Shader Framework<br>\nCopyright (c) 2010-2013 by Sean Sube, All Rights Reserved.<br>\n<br>\nError loading info:<br>\n\t" + exc.Message;
}
m_NoNav = true;
}
示例2: GenerateCode
/// <summary>
/// Function that builds the contents of the generated file based on the contents of the input file
/// </summary>
/// <param name="inputFileContent">Content of the input file</param>
/// <returns>Generated file as a byte array</returns>
protected override byte[] GenerateCode(string inputFileContent)
{
//if (InputFilePath.EndsWith("_md"))
var mdRegex = new System.Text.RegularExpressions.Regex(@"\w+\.\w+_md");
if (mdRegex.IsMatch(Path.GetFileName(InputFilePath)))
{
try
{
var input = File.ReadAllText(InputFilePath);
var md = new MarkdownSharp.Markdown();
var output = md.Transform(input);
return ConvertToBytes(output);
}
catch (Exception exception)
{
GeneratorError(0, exception.Message, 0, 0);
}
}
else
{
GeneratorError(0, "The Markdown tool is only for Markdown files with the following filename format: filename.[required_extension]_md", 0, 0);
}
return null;
}
示例3: Show
public ActionResult Show([Bind(Prefix = "id")] string slug)
{
if (string.IsNullOrWhiteSpace(slug))
throw new ArgumentNullException("slug");
Entry entry;
try
{
entry = Services.Entry.GetBySlug(slug);
}
catch (Exception ex)
{
throw new HttpException(404, "Entry not found", ex);
}
var markdown = new MarkdownSharp.Markdown();
var html = markdown.Transform(entry.Markdown);
var model = new ShowModel
{
Date = entry.DateCreated.ToString("dddd, dd MMMM yyyy"),
Slug = entry.Slug,
Title = entry.Title,
Html = html,
IsCodePrettified = entry.IsCodePrettified ?? true
};
return View(model);
}
示例4: GenerateCode
/// <summary>
/// Function that builds the contents of the generated file based on the contents of the input file
/// </summary>
/// <param name="inputFileContent">Content of the input file</param>
/// <returns>Generated file as a byte array</returns>
protected override byte[] GenerateCode(string inputFileContent)
{
try
{
//If the input file doesn't contain an inline output extension then use the file namespace,
if (new Regex(@"(\.\w+)\" + Path.GetExtension(InputFilePath))
.Match(Path.GetFileName(InputFilePath)).Groups.Count == 1)
{
DefaultExtension = "." + this.FileNameSpace;
}
else //leave the default extension blank to use the inline extension
{
DefaultExtension = string.Empty;
}
var input = File.ReadAllText(InputFilePath);
var md = new MarkdownSharp.Markdown();
var output = md.Transform(input);
return ConvertToBytes(output);
}
catch (Exception exception)
{
GeneratorError(0, exception.Message, 0, 0);
}
return null;
}
示例5: Transform
public string Transform(string input)
{
var md = new MarkdownSharp.Markdown();
var outputContent = md.Transform(input);
return outputContent;
}
示例6: GenerateCode
/// <summary>
/// Function that builds the contents of the generated file based on the contents of the input file
/// </summary>
/// <param name="inputFileContent">Content of the input file</param>
/// <returns>Generated file as a byte array</returns>
protected override byte[] GenerateCode(string inputFileContent)
{
var mdRegex = new System.Text.RegularExpressions.Regex(@"(\.\w+)\.(?:md|markdown)$");
var matches = mdRegex.Match(Path.GetFileName(InputFilePath));
if (matches.Groups.Count > 1)
{
try
{
var input = File.ReadAllText(InputFilePath);
var md = new MarkdownSharp.Markdown();
var output = md.Transform(input);
return ConvertToBytes(output);
}
catch (Exception exception)
{
GeneratorError(0, exception.Message, 0, 0);
}
}
else
{
GeneratorError(0, "The Markdown tool is only for Markdown files with the following filename format: filename.[required_extension].md or filename.[required_extension].markdown", 0, 0);
}
return null;
}
示例7: MarkdownReplace
private static string MarkdownReplace(string text) {
if (string.IsNullOrEmpty(text))
return string.Empty;
var markdown = new MarkdownSharp.Markdown();
return markdown.Transform(text);
}
示例8: RenderMasterPage
/// <summary>
/// Renders stand alone / master page
/// </summary>
/// <param name="templateContent">Template content</param>
/// <returns>HTML converted to markdown</returns>
public static string RenderMasterPage(string templateContent)
{
var second =
templateContent.Substring(
templateContent.IndexOf("<!DOCTYPE html>", StringComparison.OrdinalIgnoreCase),
templateContent.IndexOf("<body", StringComparison.OrdinalIgnoreCase));
var third = templateContent.Substring(second.Length);
var forth = templateContent.Substring(second.Length, third.IndexOf(">", StringComparison.Ordinal) + 1);
var header = second + forth;
var toConvert = templateContent.Substring(header.Length,
(templateContent.IndexOf("</body>", StringComparison.Ordinal) -
(templateContent.IndexOf(forth, StringComparison.Ordinal) + forth.Length)));
var footer =
templateContent.Substring(templateContent.IndexOf("</body>", StringComparison.OrdinalIgnoreCase));
var parser = new MarkdownSharp.Markdown();
var html = parser.Transform(toConvert.Trim());
var serverHtml = ParagraphSubstitution.Replace(html, "$1");
//TODO: The "Replace" is simply for unit testing HTML/MD strings. Probably needs improving
return string.Concat(header, serverHtml, footer).Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
}
示例9: Write
public static void Write(HttpContext context, string file)
{
var md = new MarkdownSharp.Markdown();
context.Response.ContentType = "text/html";
// < html xmlns = ""http://www.w3.org/1999/xhtml"">
context.Response.Output.Write(@"<!DOCTYPE html>
<html>
<head>
<meta http-equiv=""X-UA-Compatible"" content=""IE=edge,chrome=1"" />
<meta charset=""utf-8"">
<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />
<title>");
context.Response.Output.Write(System.IO.Path.GetFileNameWithoutExtension(file));
context.Response.Output.Write(@"</title>
<meta http-equiv=""cache-control"" content=""max-age=0"" />
<meta http-equiv=""cache-control"" content=""no-cache"" />
<meta http-equiv=""expires"" content=""0"" />
<meta http-equiv=""expires"" content=""Tue, 01 Jan 1980 1:00:00 GMT"" />
<meta http-equiv=""pragma"" content=""no-cache"" />
<base href =""/ajax/Resource.ashx/");
context.Response.Output.Write(System.Web.HttpUtility.UrlPathEncode(
Base64Encode(System.IO.Path.GetDirectoryName(file))
));
context.Response.Output.Write(@"/"" />
<link rel=""canonical"" href=""");
string str = new System.Uri(file).AbsoluteUri;
context.Response.Output.Write(str);
context.Response.Output.Write(@""" />");
context.Response.Output.Write("<style type=\"text/css\">");
// http://stackoverflow.com/questions/6784799/what-is-this-char-65279
// It's a zero-width no-break space. It's more commonly used as a byte-order mark (BOM).
// context.Response.WriteFile(System.Web.Hosting.HostingEnvironment.MapPath("~/style.css"));
// http://www.fileformat.info/info/unicode/char/feff/index.htm
// \32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\64\102\111\110\116\45\102\97\99\101\32\123
// \32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\65279\64\102\111\110\116\45\102\97\99\101\32\123
context.Response.Output.Write(
System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/style.css"), System.Text.Encoding.UTF8)
);
context.Response.Output.Write("</style>");
context.Response.Output.Write(@"
<link type=""text/css"" rel=""stylesheet"" href=""Content/style.css"" />
<script type=""text/javascript"" src=""./Scripts/libs/jquery.js""></script>
</head>
<body>
");
context.Response.Output.Write(md.Transform(System.IO.File.ReadAllText(file)));
context.Response.Output.Write(@"</body></html>");
}
示例10: ConvertToHtml
private string ConvertToHtml(string source)
{
var md = new MarkdownSharp.Markdown();
md.AddExtension(new GitHubCodeBlockExtension());
var html = md.Transform(source);
html = CleanHtml(html);
return html;
}
示例11: Transform
public string Transform(string input)
{
var md = new MarkdownSharp.Markdown();
return md.Transform(input);
//var md = new anrControls.Markdown();
//return md.Transform(input);
}
示例12: TranslateWithStyle
public static string TranslateWithStyle(string markdownText)
{
var lMarkdown = new MarkdownSharp.Markdown();
var lStyleSheet = Properties.Resources.PreviewStyleSheet;
var lHeader = Properties.Settings.Default.MarkdownStyleHeader + lStyleSheet + Properties.Settings.Default.MarkdownBodyHeader;
var lBody = lMarkdown.Transform(markdownText);
var lFooter = Properties.Settings.Default.MarkdownBodyFooter;
return lHeader + lBody + lFooter;
}
示例13: Transform
public static string Transform(string input)
{
//MarkdownSharp.MarkdownOptions mdo = new MarkdownSharp.MarkdownOptions();
//mdo.AutoHyperlink = true;
//mdo.AutoNewlines = true;
MarkdownSharp.Markdown md = new MarkdownSharp.Markdown(); //mdo);
md.AutoHyperlink = true;
return md.Transform(input);
}
示例14: Transform
public string Transform(string markdownText, string baseUrl)
{
// TODO Valutare se usare un'altra libreria per performance migliori
// e perchè credo che questa non supporta il multithreading e bisogna ricreare ogni volta l'istanza. Da verificare.
var markdown = new MarkdownSharp.Markdown();
markdown.BaseUrl = baseUrl;
return markdown.Transform(markdownText);
}
示例15: Get
/// <summary>
/// Gets the block with the given internal id.
/// </summary>
/// <param name="internalId">The internal id</param>
/// <returns>The block content as html</returns>
public static IHtmlString Get(string internalId) {
using (var rep = new Goldfish.Blocks.Api()) {
var block = rep.GetByInternalId(internalId);
if (block != null) {
var converter = new MarkdownSharp.Markdown();
return new HtmlString(converter.Transform(block.Body));
}
return new HtmlString("");
}
}