예제 #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;
 }