2using System.Globalization;
88 this.XmlOutput = XmlWriter.Create(this.
Output, XmlSettings);
99 this.XmlOutput = XmlWriter.Create(this.Output, XmlSettings);
106 GC.SuppressFinalize(
this);
109 private bool isDisposed;
114 protected virtual void Dispose(
bool disposing)
122 this.XmlOutput.Dispose();
125 this.isDisposed =
true;
138 this.StrikeThrough =
false;
139 this.Underline =
false;
140 this.Superscript =
false;
141 this.Subscript =
false;
143 this.InLabel =
false;
144 this.Hyperlink =
null;
146 return base.RenderDocument(
Document, Inclusion);
154 this.XmlOutput.WriteStartElement(
"VerticalStackLayout",
"http://schemas.microsoft.com/dotnet/2021/maui");
155 this.XmlOutput.WriteAttributeString(
"xmlns",
"x",
null,
"http://schemas.microsoft.com/winfx/2009/xaml");
159 this.XmlOutput.WriteAttributeString(
"xmlns",
"ui",
null, $
"clr-namespace:NeuroAccessMaui.UI;assembly={UiAssembly}");
161 this.XmlOutput.WriteAttributeString(
"Spacing",
"0");
163 return Task.CompletedTask;
175 this.XmlOutput.WriteStartElement(
"BoxView");
176 this.XmlOutput.WriteAttributeString(
"HeightRequest",
"1");
177 this.XmlOutput.WriteAttributeString(
"BackgroundColor",
"{DynamicResource InputFieldsContentSecondary}");
178 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"Fill");
179 this.XmlOutput.WriteAttributeString(
"Margin", SmallMargins(
false,
false,
true,
true));
180 this.XmlOutput.WriteEndElement();
182 this.XmlOutput.WriteStartElement(
"Grid");
183 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
184 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
186 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
188 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
189 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
190 this.XmlOutput.WriteEndElement();
192 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
193 this.XmlOutput.WriteAttributeString(
"Width",
"*");
194 this.XmlOutput.WriteEndElement();
196 this.XmlOutput.WriteEndElement();
197 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
201 if ((this.
Document?.TryGetFootnoteNumber(Key, out Nr) ??
false) &&
205 this.XmlOutput.WriteStartElement(
"RowDefinition");
206 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
207 this.XmlOutput.WriteEndElement();
211 this.XmlOutput.WriteEndElement();
217 if ((this.
Document?.TryGetFootnoteNumber(Key, out Nr) ??
false) &&
221 this.XmlOutput.WriteStartElement(
"ContentView");
222 this.XmlOutput.WriteAttributeString(
"Margin",
"{DynamicResource SmallMargins}");
223 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
224 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
225 this.XmlOutput.WriteAttributeString(
"Scale",
"0.75");
226 this.XmlOutput.WriteAttributeString(
"TranslationY",
"-5");
228 this.XmlOutput.WriteStartElement(
"Label");
229 this.XmlOutput.WriteAttributeString(
"Text", Nr.ToString(CultureInfo.InvariantCulture));
230 this.XmlOutput.WriteEndElement();
231 this.XmlOutput.WriteEndElement();
233 this.XmlOutput.WriteStartElement(
"ContentView");
234 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
235 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
237 this.XmlOutput.WriteEndElement();
244 this.XmlOutput.WriteEndElement();
252 this.XmlOutput.WriteEndElement();
253 this.XmlOutput.Flush();
255 return Task.CompletedTask;
258 #region Span Elements
276 this.Hyperlink =
"mailto:" + Element.
EMail;
277 this.RenderSpan(this.Hyperlink);
278 this.Hyperlink = Bak;
280 return Task.CompletedTask;
290 this.Hyperlink = Element.
URL;
291 this.RenderSpan(Element.
URL);
292 this.Hyperlink = Bak;
294 return Task.CompletedTask;
304 this.StrikeThrough =
true;
308 this.StrikeThrough = Bak;
335 if (EmojiSource is
null)
342 await
Multimedia.ImageContent.OutputMauiXaml(this.XmlOutput, Source);
371 await this.
Render(Footnote);
372 else if (this.
Document?.TryGetFootnoteNumber(Element.
Key, out
int Nr) ??
false)
375 this.Superscript =
true;
377 this.RenderSpan(Nr.ToString(CultureInfo.InvariantCulture));
379 this.Superscript = Bak;
382 Footnote.Referenced =
true;
392 this.RenderSpan(Element.
Tag);
393 return Task.CompletedTask;
403 if (!
string.IsNullOrEmpty(s))
406 return Task.CompletedTask;
415 this.RenderSpan(
new string((
char)Element.
Code, 1));
416 return Task.CompletedTask;
425 bool Bak = this.
Code;
428 this.RenderSpan(Element.
Code);
432 return Task.CompletedTask;
441 this.XmlOutput.WriteComment(Element.
HTML);
442 return Task.CompletedTask;
468 if (Result is XmlDocument Xml)
475 s = Result?.ToString();
476 if (!
string.IsNullOrEmpty(s))
477 this.RenderSpan(Result?.
ToString() ??
string.Empty);
482 if (Result is
Graph G)
487 s =
"data:image/png;base64," + Convert.ToBase64String(Bin, 0, Bin.Length);
492 Width = Pixels.Width,
493 Height = Pixels.Height
496 else if (Result is SKImage Img)
498 using SKData Data = Img.Encode(SKEncodedImageFormat.Png, 100);
499 byte[] Bin = Data.ToArray();
501 s =
"data:image/png;base64," + Convert.ToBase64String(Bin, 0, Bin.Length);
513 Doc.ProcessAsyncTasks();
519 Doc.ProcessAsyncTasks();
521 else if (Result is Exception ex)
525 if (ex is AggregateException ex2)
527 foreach (Exception ex3
in ex2.InnerExceptions)
529 this.RenderContentView();
530 this.XmlOutput.WriteStartElement(
"Label");
531 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
532 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
533 this.XmlOutput.WriteValue(ex3.Message);
534 this.XmlOutput.WriteEndElement();
535 this.XmlOutput.WriteEndElement();
540 if (AloneInParagraph)
541 this.RenderContentView();
543 this.XmlOutput.WriteStartElement(
"Label");
544 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
545 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
546 this.XmlOutput.WriteValue(ex.Message);
547 this.XmlOutput.WriteEndElement();
549 if (AloneInParagraph)
550 this.XmlOutput.WriteEndElement();
555 if (AloneInParagraph)
556 this.RenderContentView();
558 this.XmlOutput.WriteStartElement(
"Label");
559 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
562 this.XmlOutput.WriteValue(Result.ToString());
563 this.XmlOutput.WriteEndElement();
565 if (AloneInParagraph)
566 this.XmlOutput.WriteEndElement();
576 this.RenderSpan(Element.
Value);
577 return Task.CompletedTask;
587 this.Underline =
true;
591 this.Underline = Bak;
600 this.RenderSpan(Environment.NewLine);
601 return Task.CompletedTask;
611 this.Hyperlink = Element.
Url;
615 this.Hyperlink = Bak;
628 if (Multimedia is not
null)
633 this.Hyperlink = Bak;
642 StringBuilder sb =
new();
643 bool FirstOnRow =
true;
645 if (Element.
TryGetMetaData(out KeyValuePair<string, bool>[] Values))
647 foreach (KeyValuePair<string, bool> P
in Values)
657 sb.Append(Environment.NewLine);
663 this.RenderSpan(sb.ToString());
665 return Task.CompletedTask;
678 return Renderer.RenderMauiXaml(
this, Element.Items, Element.Children, Element.AloneInParagraph, Element.Document);
706 this.StrikeThrough =
true;
710 this.StrikeThrough = Bak;
719 bool Bak = this.
Bold;
734 this.Subscript =
true;
738 this.Subscript = Bak;
748 this.Superscript =
true;
752 this.Superscript = Bak;
762 this.Underline =
true;
766 this.Underline = Bak;
771 #region Block elements
779 this.XmlOutput.WriteStartElement(
"ContentView");
780 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
true,
false,
true,
true));
782 this.XmlOutput.WriteStartElement(
"Border");
783 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
true,
true,
false,
false));
784 this.XmlOutput.WriteAttributeString(
"Stroke",
"{DynamicResource ContentPrimaryWL}");
787 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
791 this.XmlOutput.WriteEndElement();
792 this.XmlOutput.WriteEndElement();
793 this.XmlOutput.WriteEndElement();
803 bool ParagraphBullet;
805 this.XmlOutput.WriteStartElement(
"ContentView");
806 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
false,
false,
true,
true));
808 this.XmlOutput.WriteStartElement(
"Grid");
809 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
810 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
812 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
814 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
815 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
816 this.XmlOutput.WriteEndElement();
818 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
819 this.XmlOutput.WriteAttributeString(
"Width",
"*");
820 this.XmlOutput.WriteEndElement();
822 this.XmlOutput.WriteEndElement();
823 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
827 this.XmlOutput.WriteStartElement(
"RowDefinition");
828 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
829 this.XmlOutput.WriteEndElement();
832 this.XmlOutput.WriteEndElement();
839 GetMargins(E, out
bool TopMargin, out
bool BottomMargin);
841 this.RenderContentView(SmallMargins(
false,
true, TopMargin, BottomMargin));
843 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
844 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
846 this.XmlOutput.WriteElementString(
"Label",
"•");
847 this.XmlOutput.WriteEndElement();
849 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
850 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
851 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
856 await this.RenderLabel(Item,
false);
858 this.XmlOutput.WriteEndElement();
864 this.XmlOutput.WriteEndElement();
865 this.XmlOutput.WriteEndElement();
868 private static string SmallMargins(
bool Left,
bool Right,
bool Top,
bool Bottom)
870 StringBuilder sb =
new();
872 sb.Append(
"{DynamicResource ");
874 if (!(Left || Right || Top || Bottom))
880 if (!(Left && Right && Top && Bottom))
896 sb.Append(
"Margins}");
898 return sb.ToString();
907 private static void GetMargins(
MarkdownElement Element, out
bool TopMargin, out
bool BottomMargin)
912 BottomMargin =
false;
918 TopMargin = BottomMargin =
false;
925 GetMargins(E, out TopMargin, out BottomMargin);
928 GetMargins(E, out
bool _, out BottomMargin);
932 GetMargins(SingleChild.Child, out TopMargin, out BottomMargin);
946 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
953 this.Alignment = Bak;
954 this.XmlOutput.WriteEndElement();
976 if (ex is AggregateException ex2)
978 foreach (Exception ex3
in ex2.InnerExceptions)
980 this.RenderContentView();
981 this.XmlOutput.WriteStartElement(
"Label");
982 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
983 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
984 this.XmlOutput.WriteValue(ex3.Message);
985 this.XmlOutput.WriteEndElement();
986 this.XmlOutput.WriteEndElement();
991 this.RenderContentView();
992 this.XmlOutput.WriteStartElement(
"Label");
993 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
994 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
995 this.XmlOutput.WriteValue(ex.Message);
996 this.XmlOutput.WriteEndElement();
997 this.XmlOutput.WriteEndElement();
1002 this.RenderContentView();
1003 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1007 for (i = Element.
Start; i <= Element.
End; i++)
1009 this.XmlOutput.WriteStartElement(
"Label");
1010 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"NoWrap");
1012 this.XmlOutput.WriteAttributeString(
"FontFamily",
"SpaceGroteskRegular");
1013 this.XmlOutput.WriteAttributeString(
"Text", Element.
Rows[i]);
1014 this.XmlOutput.WriteEndElement();
1017 this.XmlOutput.WriteEndElement();
1018 this.XmlOutput.WriteEndElement();
1027 return Task.CompletedTask;
1045 this.RenderContentView();
1047 this.XmlOutput.WriteStartElement(
"Label");
1048 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1050 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1054 XmlEntitiesOnly =
true
1061 this.XmlOutput.WriteEndElement();
1062 this.XmlOutput.WriteEndElement();
1066 this.XmlOutput.WriteStartElement(
"ContentView");
1067 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
true,
false,
false, Description == Last));
1069 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1070 await Description.
Render(
this);
1071 this.XmlOutput.WriteEndElement();
1073 this.XmlOutput.WriteEndElement();
1097 this.RenderContentView(SmallMargins(
true,
true, Top,
false));
1099 bool BoldBak = this.
Bold;
1102 await this.RenderLabel(Term,
true);
1104 this.Bold = BoldBak;
1105 this.XmlOutput.WriteEndElement();
1117 this.XmlOutput.WriteStartElement(
"ContentView");
1118 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
true,
false,
true,
true));
1120 this.XmlOutput.WriteStartElement(
"Border");
1121 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
true,
true,
false,
false));
1122 this.XmlOutput.WriteAttributeString(
"Stroke",
"{DynamicResource TnPDangerbgWL}");
1125 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1130 this.XmlOutput.WriteEndElement();
1131 this.XmlOutput.WriteEndElement();
1132 this.XmlOutput.WriteEndElement();
1150 this.RenderContentView();
1152 int Level = Math.Max(0, Math.Min(9, Element.
Level));
1154 this.XmlOutput.WriteStartElement(
"Label");
1155 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1156 this.XmlOutput.WriteAttributeString(
"Style",
"{DynamicResource Header" + Level.ToString(CultureInfo.InvariantCulture) +
"}");
1159 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1163 XmlEntitiesOnly =
true
1171 this.XmlOutput.WriteEndElement();
1172 this.XmlOutput.WriteEndElement();
1180 switch (this.Alignment)
1183 this.XmlOutput.WriteAttributeString(
"HorizontalTextAlignment",
"Start");
1187 this.XmlOutput.WriteAttributeString(
"HorizontalTextAlignment",
"End");
1191 this.XmlOutput.WriteAttributeString(
"HorizontalTextAlignment",
"Center");
1202 this.XmlOutput.WriteStartElement(
"BoxView");
1203 this.XmlOutput.WriteAttributeString(
"HeightRequest",
"1");
1204 this.XmlOutput.WriteAttributeString(
"BackgroundColor",
"{DynamicResource InputFieldsContentSecondary}");
1205 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"Fill");
1206 this.XmlOutput.WriteAttributeString(
"Margin", SmallMargins(
false,
false,
true,
true));
1207 this.XmlOutput.WriteEndElement();
1209 return Task.CompletedTask;
1218 this.RenderContentView();
1220 this.XmlOutput.WriteStartElement(
"Label");
1221 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1223 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1227 XmlEntitiesOnly =
true
1234 this.XmlOutput.WriteEndElement();
1235 this.XmlOutput.WriteEndElement();
1244 this.XmlOutput.WriteStartElement(
"ContentView");
1245 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
true,
false,
true,
true));
1247 this.XmlOutput.WriteStartElement(
"Border");
1248 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
true,
true,
false,
false));
1249 this.XmlOutput.WriteAttributeString(
"Stroke",
"{DynamicResource TnPSuccessbgWL}");
1252 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1256 this.XmlOutput.WriteEndElement();
1257 this.XmlOutput.WriteEndElement();
1258 this.XmlOutput.WriteEndElement();
1267 return Task.CompletedTask;
1276 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1283 this.Alignment = Bak;
1284 this.XmlOutput.WriteEndElement();
1293 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1300 this.Alignment = Bak;
1301 this.XmlOutput.WriteEndElement();
1316 XmlEntitiesOnly =
true
1331 if (Html is not
null)
1333 this.XmlOutput.WriteStartElement(
"Label");
1334 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1336 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1337 this.XmlOutput.WriteCData(Html.
ToString());
1338 this.XmlOutput.WriteEndElement();
1348 if (Html is not
null)
1350 this.XmlOutput.WriteStartElement(
"Label");
1351 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1353 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1354 this.XmlOutput.WriteCData(Html.
ToString());
1355 this.XmlOutput.WriteEndElement();
1382 bool ParagraphBullet;
1384 this.XmlOutput.WriteStartElement(
"ContentView");
1385 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
false,
false,
true,
true));
1387 this.XmlOutput.WriteStartElement(
"Grid");
1388 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
1389 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
1391 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
1393 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1394 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
1395 this.XmlOutput.WriteEndElement();
1397 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1398 this.XmlOutput.WriteAttributeString(
"Width",
"*");
1399 this.XmlOutput.WriteEndElement();
1401 this.XmlOutput.WriteEndElement();
1402 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
1406 this.XmlOutput.WriteStartElement(
"RowDefinition");
1407 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
1408 this.XmlOutput.WriteEndElement();
1411 this.XmlOutput.WriteEndElement();
1420 GetMargins(E, out
bool TopMargin, out
bool BottomMargin);
1422 this.RenderContentView(SmallMargins(
false,
true, TopMargin, BottomMargin));
1423 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
1424 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
1426 this.XmlOutput.WriteStartElement(
"Label");
1429 this.XmlOutput.WriteValue((Expected =
NumberedItem.
Number).ToString(CultureInfo.InvariantCulture));
1431 this.XmlOutput.WriteValue(Expected.ToString(CultureInfo.InvariantCulture));
1433 this.XmlOutput.WriteValue(
".");
1434 this.XmlOutput.WriteEndElement();
1435 this.XmlOutput.WriteEndElement();
1437 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1438 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
1439 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
1441 if (ParagraphBullet)
1444 await this.RenderLabel(Item,
false);
1446 this.XmlOutput.WriteEndElement();
1452 this.XmlOutput.WriteEndElement();
1453 this.XmlOutput.WriteEndElement();
1462 this.RenderContentView();
1463 await this.RenderLabel(Element,
false);
1464 this.XmlOutput.WriteEndElement();
1467 internal async Task RenderLabel(
MarkdownElement Element,
bool IncludeElement)
1469 bool HasLink = !Element.
ForEach((E,
_) =>
1478 this.XmlOutput.WriteStartElement(
"Label");
1479 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1487 await Element.
Render(
this);
1493 this.InLabel =
true;
1495 this.XmlOutput.WriteStartElement(
"Label.FormattedText");
1496 this.XmlOutput.WriteStartElement(
"FormattedString");
1499 await Element.
Render(
this);
1503 this.XmlOutput.WriteEndElement();
1504 this.XmlOutput.WriteEndElement();
1506 this.InLabel =
false;
1511 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1514 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Bold");
1518 XmlEntitiesOnly =
true
1529 this.XmlOutput.WriteEndElement();
1532 internal void RenderSpan(
string Text)
1536 this.XmlOutput.WriteStartElement(
"Label");
1537 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1539 this.XmlOutput.WriteStartElement(
"Label.FormattedText");
1540 this.XmlOutput.WriteStartElement(
"FormattedString");
1543 this.XmlOutput.WriteStartElement(
"Span");
1545 if (this.Superscript)
1547 else if (this.Subscript)
1550 this.XmlOutput.WriteAttributeString(
"Text", Text);
1552 if (this.Bold && this.Italic)
1553 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Italic, Bold");
1555 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Bold");
1556 else if (this.Italic)
1557 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Italic");
1559 if (this.StrikeThrough && this.Underline)
1560 this.XmlOutput.WriteAttributeString(
"TextDecorations",
"Strikethrough, Underline");
1561 else if (this.StrikeThrough)
1562 this.XmlOutput.WriteAttributeString(
"TextDecorations",
"Strikethrough");
1563 else if (this.Underline)
1564 this.XmlOutput.WriteAttributeString(
"TextDecorations",
"Underline");
1567 this.XmlOutput.WriteAttributeString(
"FontFamily",
"SpaceGroteskRegular");
1569 if (this.Hyperlink is not
null)
1571 this.XmlOutput.WriteAttributeString(
"TextColor",
"{DynamicResource TnPInfoContentWL}");
1573 this.XmlOutput.WriteStartElement(
"Span.GestureRecognizers");
1574 this.XmlOutput.WriteStartElement(
"TapGestureRecognizer");
1575 this.XmlOutput.WriteAttributeString(
"Command",
"{Binding HyperlinkClicked}");
1576 this.XmlOutput.WriteAttributeString(
"CommandParameter", this.Hyperlink);
1577 this.XmlOutput.WriteEndElement();
1578 this.XmlOutput.WriteEndElement();
1583 this.XmlOutput.WriteEndElement();
1584 this.XmlOutput.WriteEndElement();
1585 this.XmlOutput.WriteEndElement();
1588 this.XmlOutput.WriteEndElement();
1591 internal void RenderContentView()
1593 this.RenderContentView(this.Alignment, SmallMargins(
false,
false,
true,
true),
null);
1596 internal void RenderContentView(
string Margins)
1598 this.RenderContentView(this.Alignment, Margins,
null);
1603 this.RenderContentView(
Alignment, Margins,
null);
1608 this.XmlOutput.WriteStartElement(
"ContentView");
1610 if (!
string.IsNullOrEmpty(Margins))
1611 this.XmlOutput.WriteAttributeString(
"Padding", Margins);
1613 if (!
string.IsNullOrEmpty(Style))
1614 this.XmlOutput.WriteAttributeString(
"Style",
"{DynamicResource " + Style +
"}");
1619 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"Center");
1623 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"Start");
1627 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"End");
1638 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1645 this.Alignment = Bak;
1646 this.XmlOutput.WriteEndElement();
1664 this.XmlOutput.WriteStartElement(
"BoxView");
1665 this.XmlOutput.WriteAttributeString(
"HeightRequest",
"1");
1666 this.XmlOutput.WriteAttributeString(
"BackgroundColor",
"{DynamicResource InputFieldsContentSecondary}");
1667 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"Fill");
1668 this.XmlOutput.WriteAttributeString(
"Margin", SmallMargins(
false,
false,
true,
true));
1669 this.XmlOutput.WriteEndElement();
1671 return Task.CompletedTask;
1684 this.XmlOutput.WriteStartElement(
"ScrollView");
1685 this.XmlOutput.WriteAttributeString(
"Orientation",
"Horizontal");
1686 this.XmlOutput.WriteStartElement(
"ContentView");
1687 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
false,
false,
true,
true));
1689 this.XmlOutput.WriteStartElement(
"Grid");
1690 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"-2");
1691 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"-2");
1695 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
1697 for (Column = 0; Column < Element.
Columns; Column++)
1699 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1700 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
1701 this.XmlOutput.WriteEndElement();
1704 this.XmlOutput.WriteEndElement();
1705 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
1707 for (Row = 0, NrRows = Element.
Rows.Length + Element.
Headers.Length; Row < NrRows; Row++)
1709 this.XmlOutput.WriteStartElement(
"RowDefinition");
1710 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
1711 this.XmlOutput.WriteEndElement();
1714 this.XmlOutput.WriteEndElement();
1716 for (Row = 0, NrRows = Element.
Headers.Length; Row < NrRows; Row++, RowNr++)
1719 for (Row = 0, NrRows = Element.
Rows.Length; Row < NrRows; Row++, RowNr++)
1722 this.XmlOutput.WriteEndElement();
1723 this.XmlOutput.WriteEndElement();
1724 this.XmlOutput.WriteEndElement();
1728 private void ClearState()
1732 this.Italic =
false;
1733 this.StrikeThrough =
false;
1734 this.Underline =
false;
1735 this.Superscript =
false;
1736 this.Subscript =
false;
1738 this.InLabel =
false;
1739 this.Hyperlink =
null;
1742 private StateBackup Backup()
1744 return new StateBackup()
1755 Hyperlink = this.Hyperlink
1759 private void Restore(StateBackup Backup)
1761 this.Alignment = Backup.Alignment;
1762 this.Bold = Backup.Bold;
1763 this.Italic = Backup.Italic;
1764 this.StrikeThrough = Backup.StrikeThrough;
1765 this.Underline = Backup.Underline;
1766 this.Superscript = Backup.Superscript;
1767 this.Subscript = Backup.Subscript;
1768 this.Code = Backup.Code;
1769 this.InLabel = Backup.InLabel;
1770 this.Hyperlink = Backup.Hyperlink;
1773 private class StateBackup
1780 public bool Superscript;
1781 public bool Subscript;
1783 public bool InLabel;
1784 public string? Hyperlink;
1793 int NrColumns = Element.
Columns;
1795 StateBackup Bak = this.Backup();
1799 for (Column = 0; Column < NrColumns; Column++)
1801 E = CurrentRow[Column];
1806 ColSpan = Column + 1;
1807 while (ColSpan < NrColumns && CurrentRow[ColSpan] is
null)
1812 this.XmlOutput.WriteStartElement(
"Border");
1814 if ((RowNr & 1) == 0)
1815 this.XmlOutput.WriteAttributeString(
"Style",
"{DynamicResource TableCellEven}");
1817 this.XmlOutput.WriteAttributeString(
"Style",
"{DynamicResource TableCellOdd}");
1819 this.XmlOutput.WriteAttributeString(
"Grid.Column", Column.ToString(CultureInfo.InvariantCulture));
1820 this.XmlOutput.WriteAttributeString(
"Grid.Row", RowNr.ToString(CultureInfo.InvariantCulture));
1823 this.XmlOutput.WriteAttributeString(
"Grid.ColumnSpan", ColSpan.ToString(CultureInfo.InvariantCulture));
1830 await this.RenderLabel(E,
true);
1833 this.XmlOutput.WriteEndElement();
1837 this.XmlOutput.WriteStartElement(
"ContentView");
1838 this.XmlOutput.WriteAttributeString(
"Style",
null,
"{DynamicResource TableCell}");
1840 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1842 this.XmlOutput.WriteEndElement();
1844 this.XmlOutput.WriteEndElement();
1847 this.XmlOutput.WriteEndElement();
1869 bool ParagraphBullet;
1871 this.XmlOutput.WriteStartElement(
"ContentView");
1872 this.XmlOutput.WriteAttributeString(
"Padding", SmallMargins(
false,
false,
true,
true));
1874 this.XmlOutput.WriteStartElement(
"Grid");
1875 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
1876 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
1878 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
1880 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1881 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
1882 this.XmlOutput.WriteEndElement();
1884 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1885 this.XmlOutput.WriteAttributeString(
"Width",
"*");
1886 this.XmlOutput.WriteEndElement();
1888 this.XmlOutput.WriteEndElement();
1889 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
1893 this.XmlOutput.WriteStartElement(
"RowDefinition");
1894 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
1895 this.XmlOutput.WriteEndElement();
1898 this.XmlOutput.WriteEndElement();
1905 GetMargins(E, out
bool TopMargin, out
bool BottomMargin);
1909 this.RenderContentView(SmallMargins(
false,
true, TopMargin, BottomMargin));
1910 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
1911 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
1913 this.XmlOutput.WriteElementString(
"Label",
"✓");
1914 this.XmlOutput.WriteEndElement();
1917 this.XmlOutput.WriteStartElement(
"VerticalStackLayout");
1918 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
1919 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString(CultureInfo.InvariantCulture));
1921 if (ParagraphBullet)
1924 await this.RenderLabel(
TaskItem,
false);
1926 this.XmlOutput.WriteEndElement();
1932 this.XmlOutput.WriteEndElement();
1933 this.XmlOutput.WriteEndElement();
Static class containing SVG Paths for symbols used in the app.
Renders XAML (Maui flavour) from a Markdown document.
override Task RenderDocumentHeader()
Renders the document header.
override async Task Render(Emphasize Element)
Renders Element .
override async Task Render(Underline Element)
Renders Element .
override async Task Render(NestedBlock Element)
Renders Element .
override Task Render(TaskItem Element)
Renders Element .
override async Task Render(TaskList Element)
Renders Element .
void RenderLabelAlignment()
Writes a text-alignment attribute to a Maui label element.
override Task Render(InlineText Element)
Renders Element .
override async Task Render(DeleteBlocks Element)
Renders Element .
override Task Render(HtmlEntity Element)
Renders Element .
override async Task Render(Table Element)
Renders Element .
bool Subscript
If text is subscript
override Task Render(AutomaticLinkMail Element)
Renders Element .
override async Task Render(Delete Element)
Renders Element .
override async Task Render(DefinitionTerms Element)
Renders Element .
override Task Render(HashTag Element)
Renders Element .
virtual void Dispose(bool disposing)
IDisposable.Dispose
override Task Render(Footnote Element)
Renders Element .
override Task Render(HorizontalRule Element)
Renders Element .
Waher.Content.Markdown.Model.TextAlignment Alignment
Current text-alignment.
override async Task Render(FootnoteReference Element)
Renders Element .
override Task Render(CommentBlock Element)
Renders Element .
override Task Render(MultimediaReference Element)
Renders Element .
override async Task Render(InlineScript Element)
Renders Element .
override async Task Render(BlockQuote Element)
Renders Element .
readonly XmlWriter XmlOutput
XML output
override async Task Render(NumberedList Element)
Renders Element .
override async Task Render(RightAligned Element)
Renders Element .
override async Task Render(DefinitionDescriptions Element)
Renders Element .
override async Task Render(EmojiReference Element)
Renders Element .
override async Task Render(HtmlBlock Element)
Renders Element .
override async Task Render(Paragraph Element)
Renders Element .
override async Task Render(SubScript Element)
Renders Element .
override Task Render(Abbreviation Element)
Renders Element .
bool InLabel
If rendering is inside a label.
override async Task Render(LinkReference Element)
Renders Element .
override Task Render(UnnumberedItem Element)
Renders Element .
override Task Render(DetailsReference Element)
Renders Element .
MauiXamlRenderer(StringBuilder Output, XmlWriterSettings XmlSettings)
Renders XAML (Maui flavour) from a Markdown document.
override Task Render(LineBreak Element)
Renders Element .
override Task Render(InlineHTML Element)
Renders Element .
bool Superscript
If text is superscript
async Task RenderObject(object? Result, bool AloneInParagraph, Variables Variables)
Generates Maui XAML from Script output.
override Task Render(Sections Element)
Renders Element .
override Task Render(Waher.Content.Markdown.Model.SpanElements.Multimedia Element)
Renders Element .
override async Task Render(Insert Element)
Renders Element .
override async Task Render(InsertBlocks Element)
Renders Element .
override Task Render(MetaReference Element)
Renders Element .
override async Task RenderFootnotes()
Renders footnotes.
override Task RenderDocumentFooter()
Renders the document header.
override async Task Render(CenterAligned Element)
Renders Element .
override Task Render(DefinitionList Element)
Renders Element .
override Task Render(AutomaticLinkUrl Element)
Renders Element .
bool Code
If text is inline code.
override async Task Render(StrikeThrough Element)
Renders Element .
override Task Render(SectionSeparator Element)
Renders Element .
bool Italic
If text is italic
string? Hyperlink
Link, if rendering a hyperlink, null otherwise.
override Task Render(NumberedItem Element)
Renders Element .
override async Task Render(BulletList Element)
Renders Element .
override Task Render(InlineCode Element)
Renders Element .
override async Task Render(SuperScript Element)
Renders Element .
override Task Render(HtmlEntityUnicode Element)
Renders Element .
override async Task Render(Header Element)
Renders Element .
MauiXamlRenderer(XmlWriterSettings XmlSettings)
Renders XAML (Maui flavour) from a Markdown document.
override async Task Render(Link Element)
Renders Element .
override async Task Render(LeftAligned Element)
Renders Element .
override Task Render(InvisibleBreak Element)
Renders Element .
override async Task Render(CodeBlock Element)
Renders Element .
bool StrikeThrough
If text is stricken through
override async Task Render(Strong Element)
Renders Element .
bool Underline
If text is underlined
override async Task Render(MarginAligned Element)
Renders Element .
override Task RenderDocument(MarkdownDocument Document, bool Inclusion)
Renders a document.
override void Dispose()
Disposes of the renderer.
string ShortName
Emoji short name.
string Unicode
Unicode representation of emoji.
Contains information about an emoji image.
static string EntityToCharacter(string Entity)
Converts an HTML entity into a character.
Class that can be used to encapsulate Markdown to be returned from a Web Service, bypassing any encod...
Contains a markdown document. This markdown document class supports original markdown,...
static async Task< object > TransformXml(XmlDocument Xml, Variables Variables)
Transforms XML to an object that is easier to visualize.
IEnumerable< string > FootnoteOrder
Order of footnotes.
IEmojiSource EmojiSource
Source for emojis in the document.
MarkdownDocument Detail
Detail document of a master document.
Multimedia GetReference(string Label)
Gets the multimedia information referenced by a label.
static Task< MarkdownDocument > CreateAsync(string MarkdownText, params Type[] TransparentExceptionTypes)
Contains a markdown document. This markdown document class supports original markdown,...
Abstract base class for block elements with one child.
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.
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.
TextAlignment[] ColumnAlignments
Table column alignments.
MarkdownElement[][] Headers
Headers in table.
int Columns
Number of columns.
TextAlignment?[][] RowCellAlignments
Row cell alignments in table.
override ChunkedList< MarkdownElement > Children
Any children of the element.
TextAlignment?[][] HeaderCellAlignments
Header cell alignments in table.
MarkdownElement[][] Rows
Rows in table.
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.
override ChunkedList< MarkdownElement > Children
Any children of the element.
bool HasOneChild
If the element has only one child.
MarkdownElement FirstChild
First child, or null if none.
Abstract base class for all markdown elements.
virtual bool ForEach(MarkdownElementHandler Callback, object State)
Loops through all child-elements for the element.
abstract Task Render(IRenderer Output)
Renders the element.
abstract bool InlineSpanElement
If the element is an inline span element.
virtual bool OutsideParagraph
If element, parsed as a span element, can stand outside of a paragraph if alone in it.
virtual ChunkedList< MarkdownElement > Children
Any children of the element.
MarkdownDocument Document
Markdown document.
Abstract base class for all markdown elements with one child element.
string Delimiter
Delimiter string used to identify emoji.
int Level
Level (number of colons used to define the emoji)
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.
Variables Variables
Variables.
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.
Renders HTML from a Markdown document.
Contains settings that the HTML export uses to customize HTML output.
Abstract base class for Markdown renderers.
readonly StringBuilder Output
Renderer output.
Task RenderChild(MarkdownElementSingleChild Element)
Renders the child of Element .
Task RenderChildren(MarkdownElementChildren Element)
Renders the children of Element .
override string ToString()
Returns the renderer output.
virtual void Dispose()
Disposes of the renderer.
MarkdownDocument Document
Reference to Markdown document being processed.
Renders plain text from a Markdown document.
static string ToSubscript(string s)
Converts a string to subscript (as far as it goes).
static string ToSuperscript(string s)
Converts a string to superscript (as far as it goes).
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.
ToMatrix(ScriptNode Operand, bool NullCheck, int Start, int Length, Expression Expression)
To-Matrix operator.
Interface for code content Maui XAML renderers.
Interface for Emoji sources. Emoji sources provide emojis to content providers.
Task< IImageSource > GetImageSource(EmojiInfo Emoji)
Gets the image source of an emoji.
bool EmojiSupported(EmojiInfo Emoji)
If the emoji is supported by the emoji source.
Contains information about an emoji image.
Interface for objects that can be converted into matrices.
TextAlignment
Text alignment of contents.