4using System.Threading.Tasks;
41 this.
Output.AppendLine(
new string(
'-', 80));
51 if (this.
Document?.TryGetFootnoteNumber(Key, out
int Nr) ??
false)
52 this.
Output.Append(Nr.ToString());
58 await Note.Render(
this);
82 return Task.CompletedTask;
93 return Task.CompletedTask;
125 return Task.CompletedTask;
144 Footnote.Referenced =
true;
148 if ((this.
Document?.TryGetFootnoteNumber(Element.
Key, out
int Nr) ??
false))
149 this.
Output.Append(Nr.ToString());
155 return Task.CompletedTask;
166 return Task.CompletedTask;
175 string s = Html.HtmlEntity.EntityToCharacter(Element.
Entity);
176 if (!
string.IsNullOrEmpty(s))
179 return Task.CompletedTask;
190 return Task.CompletedTask;
201 return Task.CompletedTask;
210 return Task.CompletedTask;
231 return Task.CompletedTask;
233 this.
Output.Append(Result.ToString());
235 if (AloneInParagraph)
241 return Task.CompletedTask;
252 return Task.CompletedTask;
272 return Task.CompletedTask;
299 bool FirstOnRow =
true;
301 if (Element.
TryGetMetaData(out KeyValuePair<string, bool>[] Values))
303 foreach (KeyValuePair<string, bool> P
in Values)
310 this.
Output.Append(P.Key);
319 return Task.CompletedTask;
326 public override Task
Render(Model.SpanElements.Multimedia Element)
330 return this.DefaultRenderingMultimedia(Element.Children, Element.AloneInParagraph);
332 return Renderer.RenderText(
this, Element.Items, Element.Children, Element.AloneInParagraph, Element.Document);
341 bool AloneInParagraph)
343 await this.
Render(ChildNodes);
345 if (AloneInParagraph)
404 i = nrmScriptLetters.IndexOf(ch);
408 this.
Output.Append(subScriptLetters[i]);
413 private const string nrmScriptLetters =
"0123456789+-=()aeoxhklmnpstijruv";
414 private const string subScriptLetters =
"₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎ₐₑₒₓₕₖₗₘₙₚₛₜᵢⱼᵣᵤᵥ";
423 StringBuilder sb =
new StringBuilder();
426 foreach (
char ch
in s)
428 i = nrmScriptLetters.IndexOf(ch);
432 sb.Append(subScriptLetters[i]);
435 return sb.ToString();
452 i = normlScriptLetters.IndexOf(ch);
456 this.
Output.Append(superScriptLetters[i]);
461 private const string normlScriptLetters =
"abcdefghijklmnoprstuvwxyzABDEGHIJKLMNOPRTUW0123456789+-=()";
462 private const string superScriptLetters =
"ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖʳˢᵗᵘᵛʷˣʸᶻᴬᴮᴰᴱᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾᴿᵀᵁᵂ⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾";
471 StringBuilder sb =
new StringBuilder();
474 foreach (
char ch
in s)
476 i = normlScriptLetters.IndexOf(ch);
480 sb.Append(superScriptLetters[i]);
483 return sb.ToString();
497 #region Block elements
510 s = s.Replace(
"\r\n",
"\n").Replace(
"\r",
"\n");
512 foreach (
string Row
in s.Split(
'\n'))
515 this.
Output.AppendLine(Row);
531 string s2 = Environment.NewLine + Environment.NewLine;
532 bool LastIsParagraph =
false;
534 s = this.
Output.ToString();
535 if (!s.EndsWith(Environment.NewLine) && !
string.IsNullOrEmpty(s))
541 while (!(Loop is
null))
543 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
551 LastIsParagraph = s.EndsWith(s2);
557 if (!LastIsParagraph)
590 if (ex is AggregateException ex2)
592 foreach (Exception ex3
in ex2.InnerExceptions)
593 this.
Output.AppendLine(ex3.Message);
596 this.
Output.AppendLine(ex.Message);
603 for (i = Element.
Start; i <= Element.
End; i++)
619 return Task.CompletedTask;
631 while (!(Loop is
null))
633 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
635 this.
Output.Append(
":\t");
636 await Loop[i].Render(
this);
653 string s2 = Environment.NewLine + Environment.NewLine;
654 bool LastIsParagraph =
false;
655 bool FirstTerm =
true;
657 s = this.
Output.ToString();
658 if (!s.EndsWith(Environment.NewLine) && !
string.IsNullOrEmpty(s))
665 while (!(Loop is
null))
667 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
684 LastIsParagraph = s.EndsWith(s2);
689 if (!LastIsParagraph)
706 while (!(Loop is
null))
708 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
715 if (!s.EndsWith(Environment.NewLine))
735 s = s.Replace(
"\r\n",
"\n").Replace(
"\r",
"\n");
737 foreach (
string Row
in s.Split(
'\n'))
739 this.
Output.Append(
"-> ");
740 this.
Output.AppendLine(Row);
762 if (Element.
Level <= 2)
764 int Len = this.
Output.Length;
768 Len = this.Output.Length - Len + 3;
770 this.
Output.AppendLine(
new string(Element.
Level == 1 ?
'=' :
'-', Len));
775 this.
Output.Append(
new string(
'#', Element.
Level));
791 this.
Output.AppendLine(
new string(
'-', 80));
794 return Task.CompletedTask;
810 while (!(Loop is
null))
812 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
818 if (!
string.IsNullOrEmpty(s))
827 if (s.EndsWith(
"\n"))
851 s = s.Replace(
"\r\n",
"\n").Replace(
"\r",
"\n");
853 foreach (
string Row
in s.Split(
'\n'))
855 this.
Output.Append(
"+> ");
856 this.
Output.AppendLine(Row);
869 return Task.CompletedTask;
916 if (!s.EndsWith(
"\n"))
930 string s2 = Environment.NewLine + Environment.NewLine;
931 bool LastIsParagraph =
false;
933 s = this.
Output.ToString();
934 if (!s.EndsWith(Environment.NewLine) && !
string.IsNullOrEmpty(s))
940 while (!(Loop is
null))
942 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
949 LastIsParagraph = s.EndsWith(s2);
955 if (!LastIsParagraph)
996 this.
Output.AppendLine(
new string(
'=', 80));
999 return Task.CompletedTask;
1022 this.
Output.Append(
'\t');
1024 await
E.Render(
this);
1027 this.
Output.AppendLine();
1042 this.
Output.Append(
'\t');
1044 await
E.Render(
this);
1047 this.
Output.AppendLine();
1050 this.
Output.AppendLine();
1060 this.
Output.Append(
"[X] ");
1062 this.
Output.Append(
"[ ] ");
1072 if (!s.EndsWith(
"\n"))
1073 this.
Output.AppendLine();
1086 string s2 = Environment.NewLine + Environment.NewLine;
1087 bool LastIsParagraph =
false;
1089 s = this.
Output.ToString();
1090 if (!s.EndsWith(Environment.NewLine) && !
string.IsNullOrEmpty(s))
1091 this.
Output.AppendLine();
1096 while (!(Loop is
null))
1098 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
1105 LastIsParagraph = s.EndsWith(s2);
1111 if (!LastIsParagraph)
1112 this.
Output.AppendLine();
1133 if (!s.EndsWith(
"\n"))
1134 this.
Output.AppendLine();
IEnumerable< string > FootnoteOrder
Order of footnotes.
MarkdownDocument Detail
Detail document of a master document.
Multimedia GetReference(string Label)
Gets the multimedia information referenced by a label.
Represents a block quote in a markdown document.
Represents a bullet list in a markdown document.
Represents a center-aligned set of blocks in a markdown document.
Represents a code block in a markdown document.
string IndentString
String used for indentation.
int Indent
Code block indentation.
string[] Rows
Rows in code block
Represents a definition list in a markdown document.
Represents inserted blocks in a markdown document.
Represents a block of HTML in a markdown document.
Represents inserted blocks in a markdown document.
Represents a left-aligned set of blocks in a markdown document.
Represents a margin-aligned set of blocks in a markdown document.
Represents a nested block with no special formatting rules in a markdown document.
Represents a numbered item in an ordered list.
int Number
Number associated with item.
Represents a numbered list in a markdown document.
Represents a paragraph in a markdown document.
Represents a right-aligned set of blocks in a markdown document.
Represents a sequence of sections.
Represents a table in a markdown document.
Represents a task item in a task list.
bool IsChecked
If the item is checked or not.
Represents a task list in a markdown document.
Represents an unnumbered item in an ordered list.
string Prefix
Prefix, in plain text mode.
override ChunkedList< MarkdownElement > Children
Any children of the element.
Abstract base class for all markdown elements.
abstract Task Render(IRenderer Output)
Renders the element.
MarkdownDocument Document
Markdown document.
MarkdownElement Child
Child element.
EmojiInfo Emoji
Emoji information.
Represents an HTML entity.
Represents an HTML entity in Unicode format.
int Code
Unicode character
bool AloneInParagraph
If the element is alone in a paragraph.
async Task< object > EvaluateExpression()
Evaluates the script expression.
string Value
Unformatted text.
bool TryGetMetaData(out KeyValuePair< string, bool >[] Values)
Tries to get meta-data from the document.
MultimediaItem[] Items
Multimedia items.
bool AloneInParagraph
If the element is alone in a paragraph.
Abstract base class for Markdown renderers.
readonly StringBuilder Output
Renderer output.
Task RenderChild(MarkdownElementSingleChild Element)
Renders the child of Element .
void Clear()
Clears the underlying StringBuilder.
virtual async Task RenderDocument(MarkdownDocument Document, bool Inclusion)
Renders a document.
Task RenderChildren(MarkdownElementChildren Element)
Renders the children of Element .
override string ToString()
Returns the renderer output.
MarkdownDocument Document
Reference to Markdown document being processed.
Renders plain text from a Markdown document.
override Task Render(Strong Element)
Renders Element .
override async Task Render(DefinitionTerms Element)
Renders Element .
override Task Render(InvisibleBreak Element)
Renders Element .
override Task Render(HtmlEntityUnicode Element)
Renders Element .
override Task Render(HorizontalRule Element)
Renders Element .
override async Task Render(TaskItem Element)
Renders Element .
Task RenderObject(object Result, bool AloneInParagraph)
Generates plain text from Script output.
override Task Render(InlineText Element)
Renders Element .
override Task Render(MultimediaReference Element)
Renders Element .
override Task Render(MetaReference Element)
Renders Element .
override Task Render(Model.SpanElements.Multimedia Element)
Renders Element .
override async Task RenderFootnotes()
Renders footnotes.
override Task Render(FootnoteReference Element)
Renders Element .
override Task Render(AutomaticLinkUrl Element)
Renders Element .
override async Task Render(TaskList Element)
Renders Element .
override Task Render(SectionSeparator Element)
Renders Element .
override async Task Render(DefinitionDescriptions Element)
Renders Element .
override async Task Render(DeleteBlocks Element)
Renders Element .
override Task Render(HashTag Element)
Renders Element .
override Task Render(HtmlEntity Element)
Renders Element .
static string ToSubscript(string s)
Converts a string to subscript (as far as it goes).
override async Task Render(Table Element)
Renders Element .
override Task Render(MarginAligned Element)
Renders Element .
override async Task Render(Header Element)
Renders Element .
override Task Render(RightAligned Element)
Renders Element .
override Task Render(Delete Element)
Renders Element .
override async Task Render(BlockQuote Element)
Renders Element .
override Task Render(EmojiReference Element)
Renders Element .
override Task Render(Sections Element)
Renders Element .
override Task Render(Abbreviation Element)
Renders Element .
override async Task Render(NumberedItem Element)
Renders Element .
override async Task Render(DefinitionList Element)
Renders Element .
override Task Render(CommentBlock Element)
Renders Element .
override Task Render(Insert Element)
Renders Element .
static string ToSuperscript(string s)
Converts a string to superscript (as far as it goes).
override async Task Render(HtmlBlock Element)
Renders Element .
override async Task Render(NumberedList Element)
Renders Element .
override Task Render(Footnote Element)
Renders Element .
override Task Render(InlineCode Element)
Renders Element .
override async Task Render(CodeBlock Element)
Renders Element .
override async Task Render(SuperScript Element)
Renders Element .
override Task Render(InlineHTML Element)
Renders Element .
override async Task Render(InsertBlocks Element)
Renders Element .
override async Task Render(SubScript Element)
Renders Element .
override Task Render(StrikeThrough Element)
Renders Element .
TextRenderer(StringBuilder Output)
Renders plain text from a Markdown document.
override Task Render(Underline Element)
Renders Element .
override async Task Render(Paragraph Element)
Renders Element .
TextRenderer()
Renders plain text from a Markdown document.
override async Task Render(BulletList Element)
Renders Element .
override Task Render(AutomaticLinkMail Element)
Renders Element .
override Task Render(LinkReference Element)
Renders Element .
override Task Render(LeftAligned Element)
Renders Element .
override Task Render(Emphasize Element)
Renders Element .
override async Task Render(UnnumberedItem Element)
Renders Element .
override Task Render(NestedBlock Element)
Renders Element .
override Task Render(DetailsReference Element)
Renders Element .
override async Task Render(InlineScript Element)
Renders Element .
override Task Render(Link Element)
Renders Element .
override Task Render(LineBreak Element)
Renders Element .
override Task Render(CenterAligned Element)
Renders Element .
Static class managing the application event log. Applications and services log events on this static ...
static Exception UnnestException(Exception Exception)
Unnests an exception, to extract the relevant inner exception.
Node referencing a chunk in a ChunkedList<T>
ChunkNode< T > Next
Next chunk
int Pos
Index after the last element in chunk.
int Start
Index of first element in chunk.
A chunked list is a linked list of chunks of objects of type T .
ChunkNode< T > FirstChunk
First chunk
Interface for code content plain text renderers.
Interface for multimedia content plain text renderers.