本文整理汇总了C#中MarkdownSharp.Markdown类的典型用法代码示例。如果您正苦于以下问题:C# Markdown类的具体用法?C# Markdown怎么用?C# Markdown使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Markdown类属于MarkdownSharp命名空间,在下文中一共展示了Markdown类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Execute
public string Execute(string source, IDictionary<string, object> arguments)
{
var markdown = new Markdown();
string output = markdown.Transform(source);
return output;
}
开发者ID:wilsonmar,项目名称:mulder,代码行数:7,代码来源:MarkdownFilter.cs
示例2: Process
public void Process(RenderFieldArgs args)
{
Assert.ArgumentNotNull(args, "args");
if (!string.IsNullOrEmpty(args.FieldValue))
{
args.Result.FirstPart = args.FieldValue;
}
else
{
args.Result.FirstPart = args.Item[args.FieldName];
}
if (args.FieldTypeKey == "rich text")
{
WordFieldValue wordFieldValue = WordFieldValue.Parse(args.Result.FirstPart);
if (wordFieldValue.BlobId != ID.Null)
{
args.Result.FirstPart = wordFieldValue.GetHtmlWithStyles();
}
}
if (args.FieldTypeKey == "markdownfield")
{
var markdown = new Markdown();
args.Result.FirstPart = markdown.Transform(args.FieldValue);
}
}
开发者ID:abhaydhar,项目名称:Sitecore-MarkdownField,代码行数:29,代码来源:MarkdownFieldRender.cs
示例3: 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 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", "");
}
开发者ID:RadifMasud,项目名称:Nancy,代码行数:34,代码来源:MarkdownViewengineRender.cs
示例4: GetTests
private static IEnumerable<TestCaseData> GetTests()
{
Markdown m = new Markdown();
Assembly assembly = Assembly.GetAssembly(typeof(BaseTest));
string namespacePrefix = String.Concat(assembly.GetName().Name, '.', folder);
string[] resourceNames = assembly.GetManifestResourceNames();
Func<string, string> getResourceFileContent = filename =>
{
using (Stream stream = assembly.GetManifestResourceStream(filename))
{
if (stream == null)
return null;
using (StreamReader streamReader = new StreamReader(stream))
return streamReader.ReadToEnd();
}
};
return from name in resourceNames
// Skip resource names that aren't within the namespace (folder) we want
// and doesn't have the extension '.html'.
where name.StartsWith(namespacePrefix) && name.EndsWith(".html")
let actualName = Path.ChangeExtension(name, "text")
let actualContent = getResourceFileContent(actualName)
let actual = Program.RemoveWhitespace(m.Transform(actualContent))
let expectedContent = getResourceFileContent(name)
let expected = Program.RemoveWhitespace(expectedContent)
select new TestCaseData(actualName, name, actual, expected);
}
开发者ID:sassembla,项目名称:markdownsharp,代码行数:30,代码来源:MDTestTests.cs
示例5: MarkdownReplace
private static string MarkdownReplace(string text) {
if (string.IsNullOrEmpty(text))
return string.Empty;
var markdown = new MarkdownSharp.Markdown(new MarkdownOptions { AutoNewLines = false });
return markdown.Transform(text);
}
开发者ID:bigfont,项目名称:CertifiedOverheadCrane,代码行数:7,代码来源:MarkdownFilter.cs
示例6: transform
private string transform(string text)
{
if (string.IsNullOrEmpty(text))
return string.Empty;
var parser = new Markdown();
parser.ExtendWith(new StatefulCheckboxPattern());
var t = parser.Transform(text);
//prevent html from being replaced by wikiwords
var htmlTags = new Queue<string>();
t = _htmlTagsRegex.Replace(t, m =>
{
htmlTags.Enqueue(m.Groups[0].Value);
return _emaPlaceholder;
});
//don't extend markdown with this pattern because it will destroy links
t = new WikiWordsPattern().Transform(t);
return _htmlTagsRegex.Replace(t, m =>
{
if (m.Groups[0].Value == _emaPlaceholder)
{
return htmlTags.Dequeue();
}
else
{
//new wikiword link
return m.Groups[0].Value;
}
});
}
开发者ID:KhalidElSayed,项目名称:Ema-Personal-Wiki,代码行数:34,代码来源:PagesDal.cs
示例7: ProcessContent
static HtmlString ProcessContent(string fileContent)
{
var content = new Markdown().Transform(fileContent);
content = CodeHighlightRegex.Replace(content, match =>
{
var highlightOptions = match.Groups["highlightOptions"].Value;
var linesToHighlight = highlightOptions.Split(',').Select(int.Parse);
var codeLines = match.Groups["code"].Value.Split('\n');
foreach (var lineNumber in linesToHighlight)
{
var lineIndex = lineNumber - 1;
if (lineIndex < 0) throw new ArgumentException(string.Format("Tried to highlight a line with index less than 0. The full code block was:\r\n\r\n{0}", match.Value));
if (lineIndex > codeLines.Count() - 1) throw new ArgumentException(string.Format("Tried to highlight a line with index {0}, which doesn't exist. The full code block was:\r\n\r\n{1}", codeLines.Count(), match.Value));
codeLines[lineIndex] = string.Format("<strong>{0}</strong>", codeLines[lineIndex]);
}
return string.Join(Environment.NewLine, codeLines);
});
var contentIncludesASequenceDiagram = false;
content = SequenceDiagramRegex.Replace(content, match =>
{
contentIncludesASequenceDiagram = true;
var sequenceContent = match.Groups["sequenceContent"].Value;
return string.Format("<div class=\"wsd\">{0}</div>", sequenceContent);
});
if (contentIncludesASequenceDiagram)
content += "\r\n<script type=\"text/javascript\" src=\"http://www.websequencediagrams.com/service.js\" async></script>";
return new HtmlString(content);
}
开发者ID:tathamoddie,项目名称:nfwd,代码行数:31,代码来源:ContentController.cs
示例8: ProcessRequest
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/html";
var markdown = context.Request.QueryString["markdown"];
var processor = new Markdown();
context.Response.Write(processor.Transform(markdown));
}
开发者ID:cmarfia,项目名称:KalikoCMS.Core,代码行数:7,代码来源:MarkdownHandler.ashx.cs
示例9: Main
public static void Main(string[] args)
{
Markdown md = new Markdown ();
var markup = File.ReadAllText (args[0]);
var html = md.Transform (markup);
Console.WriteLine (html);
}
开发者ID:Dynalon,项目名称:MarkdownSharp,代码行数:7,代码来源:Main.cs
示例10: IndexReturnsCorrectViewResult
public void IndexReturnsCorrectViewResult(
HttpContextBase httpContext,
ControllerContext controllerContext,
HomeController sut)
{
// Arrange
controllerContext.HttpContext = httpContext;
sut.ControllerContext = controllerContext;
const string readmeFilePath = "README.md";
Mock.Get(httpContext).Setup(x => x.Server.MapPath("~/bin/README.md")).Returns(readmeFilePath);
string markdown;
using (var reader = new StreamReader(readmeFilePath))
{
markdown = reader.ReadToEnd();
}
var html = new Markdown().Transform(markdown);
// Act
var actual = sut.Index();
// Assert
var viewResult = Assert.IsAssignableFrom<ViewResult>(actual);
Assert.Empty(viewResult.ViewName);
Assert.Equal(html, viewResult.Model);
}
开发者ID:jwChung,项目名称:TfsBuilder,代码行数:28,代码来源:HomeControllerTest.cs
示例11: MarkDownService
public MarkDownService(Manager man)
: base(man)
{
Markdown = new Markdown();
Markdown.AutoHyperlink = true;
Markdown.AutoNewLines = true;
}
开发者ID:sutoentertainment,项目名称:BaoViet,代码行数:7,代码来源:MarkDownService.cs
示例12: DocumentParser
public DocumentParser(ITemplate template)
{
Ensure.ArgumentNotNull(template, "template");
_template = template;
_markdown = new Markdown();
}
开发者ID:ryanwentzel,项目名称:Proverb,代码行数:7,代码来源:DocumentParser.cs
示例13: MarkDownTextBox_Load
private void MarkDownTextBox_Load(object sender, EventArgs e)
{
if(this.DesignModeAtAll())
return;
var markdownTransformer = new Markdown();
_htmlLabel.HTML = markdownTransformer.Transform(_markdown);
}
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:7,代码来源:MarkDownTextBox.cs
示例14: GetContent
private string GetContent()
{
var md = new Markdown(new MarkdownOptions { AutoHyperlink = true });
// Code is converted to <pre><code>, I just want the code tag:
var html = md.Transform(_content).Replace("<pre><code>", "<code>").Replace("</code></pre>", "</code>");
return html;
}
开发者ID:flq,项目名称:Rf.Sites,代码行数:7,代码来源:MarkdownTransformer.cs
示例15: Process
public string Process(string input)
{
var options = new MarkdownOptions();
var markdown = new Markdown();
var output = markdown.Transform(input);
return output;
}
开发者ID:typeset,项目名称:typeset,代码行数:7,代码来源:MarkdownProcessor.cs
示例16: RenderView
public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext)
{
var response = new HtmlResponse();
var html = renderContext.ViewCache.GetOrAdd(viewLocationResult, result =>
{
string markDown =
viewLocationResult.Contents()
.ReadToEnd();
var parser = new Markdown();
return parser.Transform(markDown);
});
var serverHtml = ParagraphSubstitution.Replace(html, "$1");
var renderHtml = this.engineWrapper.Render(serverHtml, model, new MarkdownViewEngineHost(new NancyViewEngineHost(renderContext), renderContext));
response.Contents = stream =>
{
var writer = new StreamWriter(stream);
writer.Write(renderHtml);
writer.Flush();
};
return response;
}
开发者ID:jchannon,项目名称:Nancy.ViewEngines.Markdown,代码行数:29,代码来源:MarkDownEngine.cs
示例17: Configure
public static void Configure()
{
var options = new MarkdownOptions { AutoHyperlink = true };
var converter = new Markdown(options);
Mapper.CreateMap<Entry, EntryViewModel>()
// convert content from markdown to html
.ForMember(entry => entry.Content,
expression => expression.ResolveUsing(source => converter.Transform(source.Content)))
// convert summary from markdown to html
.ForMember(entry => entry.Summary,
expression => expression.ResolveUsing(source => converter.Transform(source.Summary)));
// convert the closed type of the derived generic list
Mapper.CreateMap<PagedList<Entry>, PagedList<EntryViewModel>>()
.AfterMap((entity, model) => Mapper.Map<List<Entry>, List<EntryViewModel>>(entity, model));
Mapper.CreateMap<EntryInput, Entry>()
.ForMember(entry => entry.Slug, expression => expression.MapFrom(
entry => SlugConverter.Convert(entry.Header)))
.ForMember(entry => entry.Tags, expression => expression.MapFrom(
entry => TagsResolver.ResolveTags(entry.Tags)));
Mapper.CreateMap<Entry, EntryInput>()
.ForMember(entry => entry.Tags, opt => opt.MapFrom(
entry => TagsResolver.ResolveTags(entry.Tags)));
Mapper.CreateMap<Entry, EntryInput>();
}
开发者ID:niekert,项目名称:GoBlog,代码行数:29,代码来源:AutoMapperConfiguration.cs
示例18: ToHtml
public string ToHtml(MarkdownDocument doc, UrlHelper urlHelper)
{
var html = new Markdown(new MarkdownOptions()).Transform(doc.Markdown);
const string internalLinkPattern = @"\[\[(.+?)\]\]"; // match: [[ any chars ]]
Func<string, string> nameToDocPath = name => name.Replace(" ", "-").ToLower();
const string internalLinkTemplate = @"<a class='internal' href='{0}'>{1}</a>";
Func<Match, string> interalLinkResolver = match =>
{
// match.Value = [[text|doc_name]] or [[doc_name]]
var value = match.Value.Substring(2, match.Value.Length - 4);
var text = (value.Contains("|"))
? value.Substring(0, value.IndexOf("|", StringComparison.Ordinal))
: value;
var name = (value.Contains("|"))
? value.Substring(value.IndexOf("|", StringComparison.Ordinal) + 1)
: value;
var docPath = nameToDocPath(name);
var root = doc.Root;
var href = urlHelper.Action("View", "Documents", new { root.Product, root.Language, root.Version, url = docPath });
return string.Format(internalLinkTemplate, href, text);
};
return Regex.Replace(html, internalLinkPattern, match => interalLinkResolver(match));
}
开发者ID:vidoardes,项目名称:mvc-docs,代码行数:31,代码来源:DefaultDocumentFormatter.cs
示例19: ShowReadme
private void ShowReadme()
{
var source = File.ReadAllText(_readmePath);
var mark = new Markdown(_options);
var headerHtml = @"<!DOCTYPE html>
<head>
<meta charset='utf-8'>
<link rel='stylesheet' type='text/css' href='
"
+
_stylePath
+
@"' />
</head>
<body>
";
const string footerHtml = @"</body>";
var htmlString = headerHtml + mark.Transform(source) + footerHtml;
WbReadme.NavigateToString(htmlString);
}
开发者ID:Reddds,项目名称:ProjectExplorer,代码行数:25,代码来源:ReadmeWindow.xaml.cs
示例20: MDView
public MDView(IStatusbarService statusbar)
{
_md = new Markdown();
this._statusbar = statusbar;
InitializeComponent();
textEditor.TextArea.Caret.PositionChanged += Caret_PositionChanged;
}
开发者ID:ruisebastiao,项目名称:Wide,代码行数:7,代码来源:MDView.xaml.cs
注:本文中的MarkdownSharp.Markdown类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论