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


C# MarkdownSharp.Markdown类代码示例

本文整理汇总了C#中MarkdownSharp.Markdown的典型用法代码示例。如果您正苦于以下问题:C# Markdown类的具体用法?C# Markdown怎么用?C# Markdown使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Markdown类属于MarkdownSharp命名空间,在下文中一共展示了Markdown类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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