コード例 #1
0
 public MarkdownContextBuilder WithContext(MarkdownContext context)
 {
     _filePath     = context.FilePath;
     _basePath     = context.BasePath;
     _mvb          = context.Mvb;
     _content      = context.Content;
     _isInline     = context.IsInline;
     _inclusionSet = context.InclusionSet;
     return(this);
 }
コード例 #2
0
        private static void UpdateLinks(MarkdownObject markdownObject, MarkdownContext context)
        {
            if (markdownObject == null || context == null || string.IsNullOrEmpty(context.FilePath))
            {
                return;
            }

            if (markdownObject is ContainerBlock containerBlock)
            {
                foreach (var subBlock in containerBlock)
                {
                    UpdateLinks(subBlock, context);
                }
            }
            else if (markdownObject is LeafBlock leafBlock)
            {
                if (leafBlock.Inline != null)
                {
                    foreach (var subInline in leafBlock.Inline)
                    {
                        UpdateLinks(subInline, context);
                    }
                }
            }
            else if (markdownObject is ContainerInline containerInline)
            {
                foreach (var subInline in containerInline)
                {
                    UpdateLinks(subInline, context);
                }

                if (markdownObject is LinkInline linkInline)
                {
                    var originalUrl = linkInline.Url;
                    if (RelativePath.IsRelativePath(originalUrl) && PathUtility.IsRelativePath(originalUrl) && !RelativePath.IsPathFromWorkingFolder(originalUrl) && !originalUrl.StartsWith("#"))
                    {
                        linkInline.GetDynamicUrl = () =>
                        {
                            return(((RelativePath)context.FilePath + (RelativePath)originalUrl).GetPathFromWorkingFolder());
                        };
                    }
                }
            }
        }
コード例 #3
0
 public static ProcessDocumentDelegate GetProcessDocumentDelegate(MarkdownContext context)
 {
     return(document => UpdateLinks(document, context));
 }
コード例 #4
0
 public InclusionExtension(IMarkdigCompositor compositor, MarkdownContext context, MarkdownServiceParameters parameters)
 {
     _compositor = compositor;
     _context    = context;
     _parameters = parameters;
 }
コード例 #5
0
 public HtmlInclusionInlineRenderer(IMarkdigCompositor compositor, MarkdownContext context, MarkdownServiceParameters parameters)
 {
     _compositor = compositor;
     _context    = context;
     _parameters = parameters;
 }
コード例 #6
0
 public CodeSnippetExtension(IMarkdigCompositor compositor, MarkdownContext context)
 {
     _compositor = compositor;
     _context    = context;
 }
コード例 #7
0
 public HtmlCodeSnippetRenderer(IMarkdigCompositor compositor, MarkdownContext context)
 {
     _compositor = compositor;
     _context    = context;
 }