public StringBuffer Render(IMarkdownRenderer render, DfmFencesBlockToken token, MarkdownBlockContext context)
        {
            var markdown   = token.SourceInfo.Markdown;
            var originPath = token.Path;
            var path       = originPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

            if (!string.Equals(path, originPath))
            {
                return(markdown.Replace(originPath, path));
            }

            return(base.Render(render, token, context));
        }
Esempio n. 2
0
        public void TestDfmFencesRenderFromCodeContent(string queryStringAndFragment, string expectedContent)
        {
            // arrange
            var content = @"namespace ConsoleApplication1
{
    // <namespace>
    using System;
    using System.Collections.Generic;
    using System.IO;
    // </namespace>

    // <snippetprogram>
    class Program
    {
        static void Main(string[] args)
        {
            string s = ""\ntest"";
            int i = 100;
        }
    }
    // </snippetprogram>

    #region Helper
    internal static class Helper
    {
        #region Foo
        public static void Foo()
        {
        }
        #endregion Foo
    }
    #endregion
}";

            // act
            var renderer = new DfmCodeRenderer();
            var token    = new DfmFencesBlockToken(null, null, null, "test.cs", new SourceInfo(), "csharp", null, queryStringAndFragment);
            var marked   = renderer.RenderFencesFromCodeContent(content, token);

            Assert.Equal(expectedContent.Replace("\r\n", "\n"), marked);
        }
        public StringBuffer Render(IMarkdownRenderer render, DfmFencesBlockToken token, MarkdownInlineContext context)
        {
            var markdown   = token.SourceInfo.Markdown;
            var originPath = token.Path;
            var path       = originPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
            var result     = StringBuffer.Empty;

            if (!string.Equals(path, originPath))
            {
                result = markdown.Replace(originPath, path);
            }
            else
            {
                result = base.Render(render, token, context);
            }

            if (token.Rule.Name == "DfmFencesInline")
            {
                return(NewLine + result + NewLine);
            }

            return(result);
        }