public MarkupRenderer(MarkupRendererContext context) { _context = context; _formatters = new List<IMarkupFormatter> { // Block-level new SummaryFormatter(), new ListingFormatter(), new QuoteFormatter(), new TitleFormatter(), new ParentFormatter(), new ImageFormatter(), new TableFormatter(), // Paragraph new ListFormatter(), // Paragraph level new BoldFormatter(), new HorizontalRuleFormatter(), new BackSlashFormatter(), new HeadingFormatter(), new InternalLinkFormatter(), new ParagraphFormatter(), new IncludeFormatter() }; }
public void Apply(Content content, MarkupRendererContext context) { content.Html = _standardLink.Replace(content.Html, match => BuildLink(context, match.Groups["Foo"].Value, match.Groups["Foo"].Value, null)); content.Html = _anchoredLink.Replace(content.Html, match => BuildLink(context, match.Groups["Foo"].Value, match.Groups["Foo"].Value, match.Groups["Bar"].Value)); content.Html = _namedLink.Replace(content.Html, match => BuildLink(context, match.Groups["Foo"].Value, match.Groups["Foobar"].Value, null)); content.Html = _namedAnchoredLink.Replace(content.Html, match => BuildLink(context, match.Groups["Foo"].Value, match.Groups["Foobar"].Value, match.Groups["Bar"].Value)); }
public override void Apply(Content content, MarkupRendererContext context) { var match = Expression.Match(content.Html); if (match.Success) { content.Parent = match.Groups["parent"].Value; content.Html = Expression.Replace(content.Html, ""); } }
public void Apply(Content content, MarkupRendererContext context) { var lines = content.Html.Split('\n'); var writer = new HtmlParagraphWriter(); foreach (var line in lines) { writer.WriteLine(line); } content.Html = writer.ToString(); }
public override void Apply(Content content, MarkupRendererContext context) { var match = Expression.Match(content.Html); while (match != null && match.Success) { var tagname = "h" + (match.Groups[1].Value.Length + 1); content.Html = content.Html.Replace(match.Groups[0].Value, string.Format("<{0}>{1}</{0}>\r\n\r\n", tagname, match.Groups[2].Value)); match = Expression.Match(content.Html); } }
public override void Apply(Content content, MarkupRendererContext context) { content.Html = Expression.Replace(content.Html, delegate (Match match) { var childContent = context.LoadSiblingContent(match.Groups["path"].Value); if (childContent == null) return ""; content.SourceFiles.AddRange(childContent.SourceFiles); return childContent.Html; } ); }
public override void Apply(Content content, MarkupRendererContext context) { content.Html = Expression.Replace(content.Html, delegate (Match match) { var image = context.ResolveContentAttachmentPath(match.Groups["image"].Value); var builder = new StringBuilder(); builder.AppendLine("<div class='image'>"); builder.AppendFormat("<img src='{0}' alt='Image {1}: {2}' />", image, match.Groups["index"].Value, match.Groups["caption"]).AppendLine(); builder.AppendFormat("<div>Image {0}: {1}</div>", match.Groups["index"].Value, match.Groups["caption"]); builder.AppendLine("</div>"); return builder.ToString(); } ); }
private static string BuildLink(MarkupRendererContext context, string content, string url, string anchor) { var builder = new StringBuilder(); builder.Append("<a href='"); if (url != null) builder.Append(context.ResolveInterContentLink(url)); else builder.Append(context.ResolveInterContentLink(content)); if (anchor != null) builder.Append("#" + anchor); builder.Append("'>"); builder.Append(HttpUtility.HtmlEncode(content)); builder.Append("</a>"); return builder.ToString(); }
public override void Apply(Content content, MarkupRendererContext context) { content.Html = Expression.Replace(content.Html, "$1<strong>$2</strong>"); }
public override void Apply(Content content, MarkupRendererContext context) { content.Html = Expression.Replace(content.Html, "<hr />"); }
public void Apply(Content content, MarkupRendererContext context) { content.Html = _listMatcher.Replace(content.Html, MatchFormatter); }
public void Apply(Content content, MarkupRendererContext context) { content.Html = content.Html.Replace("\\", ""); }
public abstract void Apply(Content content, MarkupRendererContext context);
public override void Apply(Content content, MarkupRendererContext context) { content.Html = Expression.Replace(content.Html, "<blockquote><p>${Quote}</p><p><span class='author'>${Author}</span></p></blockquote>"); }