public virtual StringBuffer Render(DfmEngine engine, DfmFencesBlockToken token, MarkdownBlockContext context) { var lang = string.IsNullOrEmpty(token.Lang) ? null : $" class=\"language-{token.Lang}\""; var name = string.IsNullOrEmpty(token.Name) ? null : $" name=\"{StringHelper.HtmlEncode(token.Name)}\""; var title = string.IsNullOrEmpty(token.Title) ? null : $" title=\"{StringHelper.HtmlEncode(token.Title)}\""; if (!PathUtility.IsRelativePath(token.Path)) { string errorMessage = $"Code absolute path: {token.Path} is not supported in file {engine.Parents.Peek()}"; Logger.LogError(errorMessage); return $"<!-- {StringHelper.HtmlEncode(errorMessage)} -->"; } try { // TODO: Valid REST and REST-i script. var fencesPath = ((RelativePath)token.Path).BasedOn((RelativePath)engine.Parents.Peek()); var fencesCode = File.ReadAllText(fencesPath); return $"<pre><code{lang}{name}{title}>{StringHelper.HtmlEncode(fencesCode)}\n</code></pre>"; } catch(FileNotFoundException) { string errorMessage = $"Can not find reference {token.Path}"; Logger.LogError(errorMessage); return $"<!-- {StringHelper.HtmlEncode(errorMessage)} -->"; } }
public virtual StringBuffer Render(DfmEngine engine, DfmIncludeBlockToken token, MarkdownBlockContext context) { var href = token.Src == null ? null : $"src=\"{StringHelper.HtmlEncode(token.Src)}\""; var name = token.Name == null ? null : StringHelper.HtmlEncode(token.Name); var title = token.Title == null ? null : $"title=\"{StringHelper.HtmlEncode(token.Title)}\""; var resolved = _blockInclusionHelper.Load(token.Src, token.Raw, engine.Parents, engine.InternalMarkup); return resolved; }
public string InternalMarkup(string src, IMarkdownContext context) { DfmEngine engine = new DfmEngine(context, Rewriter, Renderer, Options); return Mark(Normalize(src), context).ToString(); }
public string InternalMarkup(string src, ImmutableStack<string> parents) { DfmEngine engine = new DfmEngine(Context, Rewriter, Renderer, Options); return Mark(Normalize(src), Context.SetFilePathStack(parents)).ToString(); }
public string InternalMarkup(string src, Stack<string> parents) { DfmEngine engine = new DfmEngine(Context, Rewriter, Renderer, Options); engine.Parents = parents; return engine.Markup(src); }
public virtual StringBuffer Render(DfmEngine engine, DfmIncludeInlineToken token, MarkdownInlineContext context) { var resolved = _inlineInclusionHelper.Load(token.Src, token.Raw, engine.Parents, engine.InternalMarkup); return resolved; }