private static string GetText(IInline inline) { switch (inline) { case LiteralInline literal: return(GetTextFromLiteral(literal)); case LinkInline link: return(GetTextFromLink(link)); case AutolinkInline autoLink: return(autoLink.Url); case CodeInline code: return(code.Content); case EmphasisInline emphasis: return(GetTextFromInlineContainer(emphasis)); case HtmlInline html: return(html.Tag); case HtmlEntityInline htmlEntity: return(htmlEntity.Transcoded.Text); case LineBreakInline lineBreak: return(Environment.NewLine); default: return(string.Empty); } }
public IInlineElement Execute(IInline inline) { var textRun = (LiteralInline)inline; return(new Text { Content = Markdig.Markdown.ToPlainText(textRun.Content.Text) }); }
private static void WriteInline(IInline inline) { switch (inline) { case LiteralInline literal: SysConsole.Write(GetTextFromLiteral(literal)); return; case LinkInline link: MarkdownConsole.WriteLink(GetUrlFromLink(link), link.Title); return; case AutolinkInline autoLink: MarkdownConsole.WriteLink(autoLink.Url); return; case CodeInline code: MarkdownConsole.WriteCode(code.Content); return; case EmphasisInline emphasis: string text = GetTextFromInlineContainer(emphasis); if (emphasis.IsDouble) { MarkdownConsole.WriteBold(text); } else { MarkdownConsole.WriteItalic(text); } return; case HtmlInline html: MarkdownConsole.WriteHtml(html.Tag); return; case HtmlEntityInline htmlEntity: MarkdownConsole.WriteHtml(htmlEntity.Transcoded.Text); return; case LineBreakInline lineBreak: SysConsole.WriteLine(); return; } }
public void Add(IInline element) { if (pLines.Count == 0) { ParagraphLine pLine = new ParagraphLine(); pLine.Add(element); pLines.Add(pLine); } else { ParagraphLine pLine = pLines.Last(); if (pLine.Width + element.GetXCoordinateDelta() > width) { pLine = new ParagraphLine(); pLine.Add(element); pLines.Add(pLine); } else { pLine.Add(element); } } }
public Span AddChild(IInline childToAdd) { return(new Span(children.Add(childToAdd))); }
public Span(IInline content) { children = ImmutableList <IInline> .Empty.Add(content); }
public Strong(IInline content) { Content = content; }
public ListItem(ushort level, IInline content) { Content = content; Level = Math.Max(level, (ushort)1); }
public Highlight(IInline content, Color highlightColor) { Content = content; Color = highlightColor; }
public Header(ushort level, IInline content) : this(content) { Level = Math.Max(level, (ushort)1); }
public Link(IInline content, string address) { Content = content; Address = address; }
public CodeBlock(IInline content) : this(string.Empty, content) { // no operation }
public CodeBlock(string language, IInline content) { Content = content; Language = language; }
public OrderedListItem(IInline content) : base(1, content) { // no operation }
public OrderedListItem(ushort number, ushort level, IInline content) : base(level, content) { Number = number; }
public OrderedListItem(ushort number, IInline content) : base(1, content) { Number = number; }
public void Add(IInline element) { elements.Add(element); }
public Span InsertAt(int index, IInline childToAdd) { return(new Span(children.Insert(index, childToAdd))); }
public Paragraph(IInline content) { Content = content; }
public ListItem(IInline content) : this(1, content) { // no operation }
public Header(IInline content) { Content = content; }
public Strikethrough(IInline content) { Content = content; }
public Heading(int level, IInline inline) { Level = level; Inlines = new[] { inline }; }
public CodeInline(IInline content) { Content = content; }
public Inserted(IInline content) { Content = content; }
public Italic(IInline content) { Content = content; }
public IInlineElement Execute(IInline inline) { throw new NotImplementedException(); }
public Marked(IInline content) { Content = content; }