5using System.Threading.Tasks;
94 this.XmlOutput = XmlWriter.Create(this.
Output, XmlSettings);
107 this.XmlOutput = XmlWriter.Create(this.Output, XmlSettings);
115 this.XmlOutput.Dispose();
128 this.StrikeThrough =
false;
129 this.Underline =
false;
130 this.Superscript =
false;
131 this.Subscript =
false;
133 this.InLabel =
false;
134 this.Hyperlink =
null;
136 return base.RenderDocument(
Document, Inclusion);
144 this.XmlOutput.WriteStartElement(
"StackLayout",
"http://xamarin.com/schemas/2014/forms");
145 this.XmlOutput.WriteAttributeString(
"xmlns",
"x",
null,
"http://schemas.microsoft.com/winfx/2009/xaml");
146 this.XmlOutput.WriteAttributeString(
"Spacing",
"0");
148 return Task.CompletedTask;
157 string FootnoteMargin =
"0," + this.XamlSettings.ParagraphMarginTop.
ToString() +
"," +
158 this.XamlSettings.FootnoteSeparator.ToString() +
"," +
159 this.XamlSettings.ParagraphMarginBottom.ToString();
161 string Offset = this.XamlSettings.SuperscriptOffset.ToString();
165 this.XmlOutput.WriteStartElement(
"BoxView");
166 this.XmlOutput.WriteAttributeString(
"HeightRequest",
"1");
167 this.XmlOutput.WriteAttributeString(
"BackgroundColor", this.XamlSettings.TableCellBorderColor);
168 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"FillAndExpand");
169 this.XmlOutput.WriteAttributeString(
"Margin", this.XamlSettings.ParagraphMargins);
170 this.XmlOutput.WriteEndElement();
172 this.XmlOutput.WriteStartElement(
"Grid");
173 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
174 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
176 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
178 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
179 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
180 this.XmlOutput.WriteEndElement();
182 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
183 this.XmlOutput.WriteAttributeString(
"Width",
"*");
184 this.XmlOutput.WriteEndElement();
186 this.XmlOutput.WriteEndElement();
187 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
191 if ((this.
Document?.TryGetFootnoteNumber(Key, out Nr) ??
false) &&
195 this.XmlOutput.WriteStartElement(
"RowDefinition");
196 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
197 this.XmlOutput.WriteEndElement();
201 this.XmlOutput.WriteEndElement();
205 if ((this.
Document?.TryGetFootnoteNumber(Key, out Nr) ??
false) &&
209 this.XmlOutput.WriteStartElement(
"ContentView");
210 this.XmlOutput.WriteAttributeString(
"Margin", FootnoteMargin);
211 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
212 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
213 this.XmlOutput.WriteAttributeString(
"Scale", Scale);
214 this.XmlOutput.WriteAttributeString(
"TranslationY", Offset);
216 this.XmlOutput.WriteStartElement(
"Label");
217 this.XmlOutput.WriteAttributeString(
"Text", Nr.ToString());
218 this.XmlOutput.WriteEndElement();
219 this.XmlOutput.WriteEndElement();
221 this.XmlOutput.WriteStartElement(
"ContentView");
222 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
223 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
225 this.XmlOutput.WriteEndElement();
231 this.XmlOutput.WriteEndElement();
239 this.XmlOutput.WriteEndElement();
240 this.XmlOutput.Flush();
242 return Task.CompletedTask;
245 #region Span Elements
263 this.Hyperlink =
"mailto:" + Element.
EMail;
264 this.RenderSpan(this.Hyperlink);
265 this.Hyperlink = Bak;
267 return Task.CompletedTask;
277 this.Hyperlink = Element.
URL;
278 this.RenderSpan(Element.
URL);
279 this.Hyperlink = Bak;
281 return Task.CompletedTask;
291 this.StrikeThrough =
true;
295 this.StrikeThrough = Bak;
322 if (EmojiSource is
null)
329 await
Multimedia.ImageContent.OutputXamarinForms(this.XmlOutput, Source);
358 await this.
Render(Footnote);
359 else if (this.
Document?.TryGetFootnoteNumber(Element.
Key, out
int Nr) ??
false)
362 this.Superscript =
true;
364 this.RenderSpan(Nr.ToString());
366 this.Superscript = Bak;
369 Footnote.Referenced =
true;
379 this.RenderSpan(Element.
Tag);
380 return Task.CompletedTask;
389 string s = Html.HtmlEntity.EntityToCharacter(Element.
Entity);
390 if (!
string.IsNullOrEmpty(s))
393 return Task.CompletedTask;
402 this.RenderSpan(
new string((
char)Element.
Code, 1));
403 return Task.CompletedTask;
412 bool Bak = this.
Code;
415 this.RenderSpan(Element.
Code);
419 return Task.CompletedTask;
428 this.XmlOutput.WriteComment(Element.
HTML);
429 return Task.CompletedTask;
455 if (Result is XmlDocument Xml)
462 s = Result?.ToString();
463 if (!
string.IsNullOrEmpty(s))
464 this.RenderSpan(Result?.
ToString() ??
string.Empty);
469 if (Result is
Graph G)
474 s =
"data:image/png;base64," + Convert.ToBase64String(Bin, 0, Bin.Length);
479 Width = Pixels.
Width,
480 Height = Pixels.Height
483 else if (Result is SKImage Img)
485 using (SKData Data = Img.Encode(SKEncodedImageFormat.Png, 100))
487 byte[] Bin = Data.ToArray();
489 s =
"data:image/png;base64," + Convert.ToBase64String(Bin, 0, Bin.Length);
502 Doc.ProcessAsyncTasks();
508 Doc.ProcessAsyncTasks();
510 else if (Result is Exception ex)
514 if (ex is AggregateException ex2)
516 foreach (Exception ex3
in ex2.InnerExceptions)
518 this.RenderContentView();
519 this.XmlOutput.WriteStartElement(
"Label");
520 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
521 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
522 this.XmlOutput.WriteValue(ex3.Message);
523 this.XmlOutput.WriteEndElement();
524 this.XmlOutput.WriteEndElement();
529 if (AloneInParagraph)
530 this.RenderContentView();
532 this.XmlOutput.WriteStartElement(
"Label");
533 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
534 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
535 this.XmlOutput.WriteValue(ex.Message);
536 this.XmlOutput.WriteEndElement();
538 if (AloneInParagraph)
539 this.XmlOutput.WriteEndElement();
544 if (AloneInParagraph)
545 this.RenderContentView();
547 this.XmlOutput.WriteStartElement(
"Label");
548 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
551 this.XmlOutput.WriteValue(Result.ToString());
552 this.XmlOutput.WriteEndElement();
554 if (AloneInParagraph)
555 this.XmlOutput.WriteEndElement();
565 this.RenderSpan(Element.
Value);
566 return Task.CompletedTask;
576 this.Underline =
true;
580 this.Underline = Bak;
589 this.RenderSpan(Environment.NewLine);
590 return Task.CompletedTask;
600 this.Hyperlink = Element.
Url;
604 this.Hyperlink = Bak;
617 if (!(Multimedia is
null))
622 this.Hyperlink = Bak;
631 StringBuilder sb =
new StringBuilder();
632 bool FirstOnRow =
true;
634 if (Element.
TryGetMetaData(out KeyValuePair<string, bool>[] Values))
636 foreach (KeyValuePair<string, bool> P
in Values)
646 sb.Append(Environment.NewLine);
652 this.RenderSpan(sb.ToString());
654 return Task.CompletedTask;
661 public override Task
Render(Model.SpanElements.Multimedia Element)
667 return Renderer.RenderXamarinFormsXaml(
this, Element.Items, Element.Children, Element.AloneInParagraph, Element.Document);
695 this.StrikeThrough =
true;
699 this.StrikeThrough = Bak;
708 bool Bak = this.
Bold;
723 this.Subscript =
true;
727 this.Subscript = Bak;
737 this.Superscript =
true;
741 this.Superscript = Bak;
751 this.Underline =
true;
755 this.Underline = Bak;
760 #region Block elements
768 this.XmlOutput.WriteStartElement(
"ContentView");
769 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.BlockQuoteMargin.ToString() +
"," +
770 this.XamlSettings.ParagraphMarginTop.ToString() +
",0," +
this.XamlSettings.ParagraphMarginBottom.ToString());
772 this.XmlOutput.WriteStartElement(
"Frame");
773 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.BlockQuotePadding.ToString() +
774 ",0," +
this.XamlSettings.BlockQuotePadding.ToString() +
",0");
775 this.XmlOutput.WriteAttributeString(
"BorderColor", this.XamlSettings.BlockQuoteBorderColor);
778 this.XmlOutput.WriteStartElement(
"StackLayout");
779 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
783 this.XmlOutput.WriteEndElement();
784 this.XmlOutput.WriteEndElement();
785 this.XmlOutput.WriteEndElement();
795 bool ParagraphBullet;
798 this.XmlOutput.WriteStartElement(
"ContentView");
799 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.ParagraphMargins);
801 this.XmlOutput.WriteStartElement(
"Grid");
802 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
803 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
805 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
807 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
808 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
809 this.XmlOutput.WriteEndElement();
811 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
812 this.XmlOutput.WriteAttributeString(
"Width",
"*");
813 this.XmlOutput.WriteEndElement();
815 this.XmlOutput.WriteEndElement();
816 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
820 this.XmlOutput.WriteStartElement(
"RowDefinition");
821 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
822 this.XmlOutput.WriteEndElement();
825 this.XmlOutput.WriteEndElement();
830 while (!(Loop is
null))
832 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
837 this.GetMargins(E, out
int TopMargin, out
int BottomMargin);
839 this.RenderContentView(
"0," + TopMargin.ToString() +
"," +
this.XamlSettings.ListContentMargin.ToString() +
"," +
840 BottomMargin.ToString());
841 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
842 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
844 this.XmlOutput.WriteElementString(
"Label",
"•");
845 this.XmlOutput.WriteEndElement();
847 this.XmlOutput.WriteStartElement(
"StackLayout");
848 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
849 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
850 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
855 await this.RenderLabel(E,
false);
857 this.XmlOutput.WriteEndElement();
865 this.XmlOutput.WriteEndElement();
866 this.XmlOutput.WriteEndElement();
875 private void GetMargins(
MarkdownElement Element, out
int TopMargin, out
int BottomMargin)
889 TopMargin = BottomMargin = 0;
891 while (!(Loop is
null))
893 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
900 this.GetMargins(E, out TopMargin, out BottomMargin);
903 this.GetMargins(E, out
int _, out BottomMargin);
910 this.GetMargins(SingleChild.Child, out TopMargin, out BottomMargin);
913 TopMargin = this.XamlSettings.ParagraphMarginTop;
914 BottomMargin = this.XamlSettings.ParagraphMarginBottom;
924 this.XmlOutput.WriteStartElement(
"StackLayout");
925 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
932 this.Alignment = Bak;
933 this.XmlOutput.WriteEndElement();
955 if (ex is AggregateException ex2)
957 foreach (Exception ex3
in ex2.InnerExceptions)
959 this.RenderContentView();
960 this.XmlOutput.WriteStartElement(
"Label");
961 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
962 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
963 this.XmlOutput.WriteValue(ex3.Message);
964 this.XmlOutput.WriteEndElement();
965 this.XmlOutput.WriteEndElement();
970 this.RenderContentView();
971 this.XmlOutput.WriteStartElement(
"Label");
972 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
973 this.XmlOutput.WriteAttributeString(
"TextColor",
"Red");
974 this.XmlOutput.WriteValue(ex.Message);
975 this.XmlOutput.WriteEndElement();
976 this.XmlOutput.WriteEndElement();
981 this.RenderContentView();
982 this.XmlOutput.WriteStartElement(
"StackLayout");
983 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
987 for (i = Element.
Start; i <= Element.
End; i++)
989 this.XmlOutput.WriteStartElement(
"Label");
990 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"NoWrap");
992 this.XmlOutput.WriteAttributeString(
"FontFamily",
"Courier New");
993 this.XmlOutput.WriteAttributeString(
"Text", Element.
Rows[i]);
994 this.XmlOutput.WriteEndElement();
997 this.XmlOutput.WriteEndElement();
998 this.XmlOutput.WriteEndElement();
1007 return Task.CompletedTask;
1016 MarkdownElement Last = Element.Children.HasLastItem ? Element.Children.LastItem :
null;
1021 while (!(Loop is
null))
1023 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
1029 this.RenderContentView();
1031 this.XmlOutput.WriteStartElement(
"Label");
1032 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1034 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1038 XmlEntitiesOnly =
true
1045 this.XmlOutput.WriteEndElement();
1046 this.XmlOutput.WriteEndElement();
1050 this.XmlOutput.WriteStartElement(
"ContentView");
1051 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.DefinitionMargin.ToString() +
",0,0," +
1052 (E == Last ? this.XamlSettings.DefinitionSeparator : 0).
ToString());
1054 this.XmlOutput.WriteStartElement(
"StackLayout");
1056 this.XmlOutput.WriteEndElement();
1058 this.XmlOutput.WriteEndElement();
1081 int TopMargin = this.XamlSettings.ParagraphMarginTop;
1085 while (!(Loop is
null))
1087 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
1089 this.RenderContentView(this.XamlSettings.ParagraphMarginLeft.ToString() +
"," + TopMargin.ToString() +
"," +
1090 this.XamlSettings.ParagraphMarginRight.ToString() +
",0");
1092 bool BoldBak = this.
Bold;
1095 await this.RenderLabel(Loop[i],
true);
1097 this.Bold = BoldBak;
1098 this.XmlOutput.WriteEndElement();
1113 this.XmlOutput.WriteStartElement(
"ContentView");
1114 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.BlockQuoteMargin.ToString() +
"," +
1115 this.XamlSettings.ParagraphMarginTop.ToString() +
",0," +
this.XamlSettings.ParagraphMarginBottom.ToString());
1117 this.XmlOutput.WriteStartElement(
"Frame");
1118 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.BlockQuotePadding.ToString() +
1119 ",0," +
this.XamlSettings.BlockQuotePadding.ToString() +
",0");
1120 this.XmlOutput.WriteAttributeString(
"BorderColor", this.XamlSettings.DeletedBlockQuoteBorderColor);
1123 this.XmlOutput.WriteStartElement(
"StackLayout");
1124 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
1128 this.XmlOutput.WriteEndElement();
1129 this.XmlOutput.WriteEndElement();
1130 this.XmlOutput.WriteEndElement();
1148 this.RenderContentView();
1150 this.XmlOutput.WriteStartElement(
"Label");
1151 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1154 if (Element.
Level > 0 && Element.
Level <=
this.XamlSettings.HeaderFontSize.Length)
1156 this.XmlOutput.WriteAttributeString(
"FontSize", this.XamlSettings.HeaderFontSize[Element.
Level - 1].ToString());
1157 this.XmlOutput.WriteAttributeString(
"TextColor", this.XamlSettings.HeaderForegroundColor[Element.
Level - 1].ToString());
1160 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1164 XmlEntitiesOnly =
true
1172 this.XmlOutput.WriteEndElement();
1173 this.XmlOutput.WriteEndElement();
1181 switch (this.Alignment)
1184 this.XmlOutput.WriteAttributeString(
"HorizontalTextAlignment",
"Start");
1188 this.XmlOutput.WriteAttributeString(
"HorizontalTextAlignment",
"End");
1192 this.XmlOutput.WriteAttributeString(
"HorizontalTextAlignment",
"Center");
1203 this.XmlOutput.WriteStartElement(
"BoxView");
1204 this.XmlOutput.WriteAttributeString(
"HeightRequest",
"1");
1205 this.XmlOutput.WriteAttributeString(
"BackgroundColor", this.XamlSettings.TableCellBorderColor);
1206 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"FillAndExpand");
1207 this.XmlOutput.WriteAttributeString(
"Margin", this.XamlSettings.ParagraphMargins);
1208 this.XmlOutput.WriteEndElement();
1210 return Task.CompletedTask;
1219 this.RenderContentView();
1221 this.XmlOutput.WriteStartElement(
"Label");
1222 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1224 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1228 XmlEntitiesOnly =
true
1235 this.XmlOutput.WriteEndElement();
1236 this.XmlOutput.WriteEndElement();
1246 this.XmlOutput.WriteStartElement(
"ContentView");
1247 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.BlockQuoteMargin.ToString() +
"," +
1248 this.XamlSettings.ParagraphMarginTop.ToString() +
",0," +
this.XamlSettings.ParagraphMarginBottom.ToString());
1250 this.XmlOutput.WriteStartElement(
"Frame");
1251 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.BlockQuotePadding.ToString() +
1252 ",0," +
this.XamlSettings.BlockQuotePadding.ToString() +
",0");
1253 this.XmlOutput.WriteAttributeString(
"BorderColor", this.XamlSettings.InsertedBlockQuoteBorderColor);
1256 this.XmlOutput.WriteStartElement(
"StackLayout");
1257 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
1261 this.XmlOutput.WriteEndElement();
1262 this.XmlOutput.WriteEndElement();
1263 this.XmlOutput.WriteEndElement();
1272 return Task.CompletedTask;
1281 this.XmlOutput.WriteStartElement(
"StackLayout");
1282 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
1289 this.Alignment = Bak;
1290 this.XmlOutput.WriteEndElement();
1299 this.XmlOutput.WriteStartElement(
"StackLayout");
1300 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
1307 this.Alignment = Bak;
1308 this.XmlOutput.WriteEndElement();
1323 XmlEntitiesOnly =
true
1333 while (!(Loop is
null))
1335 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
1348 if (!(Html is
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();
1368 if (!(Html is
null))
1370 this.XmlOutput.WriteStartElement(
"Label");
1371 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1373 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1374 this.XmlOutput.WriteCData(Html.
ToString());
1375 this.XmlOutput.WriteEndElement();
1402 bool ParagraphBullet;
1405 this.XmlOutput.WriteStartElement(
"ContentView");
1406 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.ParagraphMargins);
1408 this.XmlOutput.WriteStartElement(
"Grid");
1409 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
1410 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
1412 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
1414 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1415 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
1416 this.XmlOutput.WriteEndElement();
1418 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1419 this.XmlOutput.WriteAttributeString(
"Width",
"*");
1420 this.XmlOutput.WriteEndElement();
1422 this.XmlOutput.WriteEndElement();
1423 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
1427 this.XmlOutput.WriteStartElement(
"RowDefinition");
1428 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
1429 this.XmlOutput.WriteEndElement();
1432 this.XmlOutput.WriteEndElement();
1437 while (!(Loop is
null))
1439 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
1445 this.GetMargins(E, out
int TopMargin, out
int BottomMargin);
1447 this.RenderContentView(
"0," + TopMargin.ToString() +
"," +
this.XamlSettings.ListContentMargin.ToString() +
"," +
1448 BottomMargin.ToString());
1449 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
1450 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
1452 this.XmlOutput.WriteStartElement(
"Label");
1457 this.XmlOutput.WriteValue(Expected.ToString());
1459 this.XmlOutput.WriteValue(
".");
1460 this.XmlOutput.WriteEndElement();
1461 this.XmlOutput.WriteEndElement();
1463 this.XmlOutput.WriteStartElement(
"StackLayout");
1464 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
1465 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
1466 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
1468 if (ParagraphBullet)
1471 await this.RenderLabel(E,
false);
1473 this.XmlOutput.WriteEndElement();
1481 this.XmlOutput.WriteEndElement();
1482 this.XmlOutput.WriteEndElement();
1491 this.RenderContentView();
1492 await this.RenderLabel(Element,
false);
1493 this.XmlOutput.WriteEndElement();
1496 internal async Task RenderLabel(
MarkdownElement Element,
bool IncludeElement)
1498 bool HasLink = !Element.
ForEach((E,
_) =>
1507 this.XmlOutput.WriteStartElement(
"Label");
1508 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1516 await Element.
Render(
this);
1522 this.InLabel =
true;
1524 this.XmlOutput.WriteStartElement(
"Label.FormattedText");
1525 this.XmlOutput.WriteStartElement(
"FormattedString");
1528 await Element.
Render(
this);
1532 this.XmlOutput.WriteEndElement();
1533 this.XmlOutput.WriteEndElement();
1535 this.InLabel =
false;
1540 this.XmlOutput.WriteAttributeString(
"TextType",
"Html");
1543 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Bold");
1547 XmlEntitiesOnly =
true
1559 this.XmlOutput.WriteEndElement();
1562 internal void RenderSpan(
string Text)
1566 this.XmlOutput.WriteStartElement(
"Label");
1567 this.XmlOutput.WriteAttributeString(
"LineBreakMode",
"WordWrap");
1569 this.XmlOutput.WriteStartElement(
"Label.FormattedText");
1570 this.XmlOutput.WriteStartElement(
"FormattedString");
1573 this.XmlOutput.WriteStartElement(
"Span");
1575 if (this.Superscript)
1577 else if (this.Subscript)
1580 this.XmlOutput.WriteAttributeString(
"Text", Text);
1582 if (this.Bold && this.Italic)
1583 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Italic, Bold");
1585 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Bold");
1586 else if (this.Italic)
1587 this.XmlOutput.WriteAttributeString(
"FontAttributes",
"Italic");
1589 if (this.StrikeThrough && this.Underline)
1590 this.XmlOutput.WriteAttributeString(
"TextDecorations",
"Strikethrough, Underline");
1591 else if (this.StrikeThrough)
1592 this.XmlOutput.WriteAttributeString(
"TextDecorations",
"Strikethrough");
1593 else if (this.Underline)
1594 this.XmlOutput.WriteAttributeString(
"TextDecorations",
"Underline");
1597 this.XmlOutput.WriteAttributeString(
"FontFamily",
"Courier New");
1599 if (!(this.Hyperlink is
null))
1601 this.XmlOutput.WriteAttributeString(
"TextColor",
"{Binding HyperlinkColor}");
1603 this.XmlOutput.WriteStartElement(
"Span.GestureRecognizers");
1604 this.XmlOutput.WriteStartElement(
"TapGestureRecognizer");
1605 this.XmlOutput.WriteAttributeString(
"Command",
"{Binding HyperlinkClicked}");
1606 this.XmlOutput.WriteAttributeString(
"CommandParameter", this.Hyperlink);
1607 this.XmlOutput.WriteEndElement();
1608 this.XmlOutput.WriteEndElement();
1613 this.XmlOutput.WriteEndElement();
1614 this.XmlOutput.WriteEndElement();
1615 this.XmlOutput.WriteEndElement();
1618 this.XmlOutput.WriteEndElement();
1621 internal void RenderContentView()
1623 this.RenderContentView(this.Alignment, this.XamlSettings.ParagraphMargins);
1626 internal void RenderContentView(
string Margins)
1628 this.RenderContentView(this.Alignment, Margins);
1633 this.XmlOutput.WriteStartElement(
"ContentView");
1634 this.XmlOutput.WriteAttributeString(
"Padding", Margins);
1639 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"Center");
1643 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"Start");
1647 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"End");
1658 this.XmlOutput.WriteStartElement(
"StackLayout");
1659 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
1666 this.Alignment = Bak;
1667 this.XmlOutput.WriteEndElement();
1685 this.XmlOutput.WriteStartElement(
"BoxView");
1686 this.XmlOutput.WriteAttributeString(
"HeightRequest",
"1");
1687 this.XmlOutput.WriteAttributeString(
"BackgroundColor", this.XamlSettings.TableCellBorderColor);
1688 this.XmlOutput.WriteAttributeString(
"HorizontalOptions",
"FillAndExpand");
1689 this.XmlOutput.WriteAttributeString(
"Margin", this.XamlSettings.ParagraphMargins);
1690 this.XmlOutput.WriteEndElement();
1692 return Task.CompletedTask;
1705 this.XmlOutput.WriteStartElement(
"ContentView");
1706 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.ParagraphMargins);
1708 this.XmlOutput.WriteStartElement(
"Grid");
1709 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"-2");
1710 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"-2");
1714 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
1716 for (Column = 0; Column < Element.
Columns; Column++)
1718 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1719 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
1720 this.XmlOutput.WriteEndElement();
1723 this.XmlOutput.WriteEndElement();
1724 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
1726 for (Row = 0, NrRows = Element.
Rows.Length + Element.
Headers.Length; Row < NrRows; Row++)
1728 this.XmlOutput.WriteStartElement(
"RowDefinition");
1729 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
1730 this.XmlOutput.WriteEndElement();
1733 this.XmlOutput.WriteEndElement();
1735 for (Row = 0, NrRows = Element.
Headers.Length; Row < NrRows; Row++, RowNr++)
1738 for (Row = 0, NrRows = Element.
Rows.Length; Row < NrRows; Row++, RowNr++)
1741 this.XmlOutput.WriteEndElement();
1742 this.XmlOutput.WriteEndElement();
1745 private void ClearState()
1749 this.Italic =
false;
1750 this.StrikeThrough =
false;
1751 this.Underline =
false;
1752 this.Superscript =
false;
1753 this.Subscript =
false;
1755 this.InLabel =
false;
1756 this.Hyperlink =
null;
1759 private StateBackup Backup()
1761 return new StateBackup()
1772 hyperlink = this.Hyperlink
1776 private void Restore(StateBackup Backup)
1778 this.Alignment = Backup.alignment;
1779 this.Bold = Backup.bold;
1780 this.Italic = Backup.italic;
1781 this.StrikeThrough = Backup.strikeThrough;
1782 this.Underline = Backup.underline;
1783 this.Superscript = Backup.superscript;
1784 this.Subscript = Backup.subscript;
1785 this.Code = Backup.code;
1786 this.InLabel = Backup.inLabel;
1787 this.Hyperlink = Backup.hyperlink;
1790 private class StateBackup
1795 public bool strikeThrough;
1796 public bool underline;
1797 public bool superscript;
1798 public bool subscript;
1800 public bool inLabel;
1801 public string hyperlink;
1809 int NrColumns = Element.
Columns;
1811 StateBackup Bak = this.Backup();
1815 for (Column = 0; Column < NrColumns; Column++)
1817 E = CurrentRow[Column];
1822 ColSpan = Column + 1;
1823 while (ColSpan < NrColumns && CurrentRow[ColSpan] is
null)
1828 this.XmlOutput.WriteStartElement(
"Frame");
1829 this.XmlOutput.WriteAttributeString(
"Padding",
"0,0,0,0");
1830 this.XmlOutput.WriteAttributeString(
"BorderColor", this.XamlSettings.TableCellBorderColor);
1833 if ((RowNr & 1) == 0)
1835 if (!
string.IsNullOrEmpty(this.XamlSettings.TableCellRowBackgroundColor1))
1836 this.XmlOutput.WriteAttributeString(
"BackgroundColor", this.XamlSettings.TableCellRowBackgroundColor1);
1840 if (!
string.IsNullOrEmpty(this.XamlSettings.TableCellRowBackgroundColor2))
1841 this.XmlOutput.WriteAttributeString(
"BackgroundColor", this.XamlSettings.TableCellRowBackgroundColor2);
1844 this.XmlOutput.WriteAttributeString(
"Grid.Column", Column.ToString());
1845 this.XmlOutput.WriteAttributeString(
"Grid.Row", RowNr.ToString());
1848 this.XmlOutput.WriteAttributeString(
"Grid.ColumnSpan", ColSpan.ToString());
1852 this.RenderContentView(
TextAlignment, this.XamlSettings.TableCellPadding);
1855 await this.RenderLabel(E,
true);
1858 this.XmlOutput.WriteEndElement();
1862 this.XmlOutput.WriteStartElement(
"ContentView");
1863 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.TableCellPadding);
1865 this.XmlOutput.WriteStartElement(
"StackLayout");
1867 this.XmlOutput.WriteEndElement();
1869 this.XmlOutput.WriteEndElement();
1872 this.XmlOutput.WriteEndElement();
1894 bool ParagraphBullet;
1897 this.XmlOutput.WriteStartElement(
"ContentView");
1898 this.XmlOutput.WriteAttributeString(
"Padding", this.XamlSettings.ParagraphMargins);
1900 this.XmlOutput.WriteStartElement(
"Grid");
1901 this.XmlOutput.WriteAttributeString(
"RowSpacing",
"0");
1902 this.XmlOutput.WriteAttributeString(
"ColumnSpacing",
"0");
1904 this.XmlOutput.WriteStartElement(
"Grid.ColumnDefinitions");
1906 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1907 this.XmlOutput.WriteAttributeString(
"Width",
"Auto");
1908 this.XmlOutput.WriteEndElement();
1910 this.XmlOutput.WriteStartElement(
"ColumnDefinition");
1911 this.XmlOutput.WriteAttributeString(
"Width",
"*");
1912 this.XmlOutput.WriteEndElement();
1914 this.XmlOutput.WriteEndElement();
1915 this.XmlOutput.WriteStartElement(
"Grid.RowDefinitions");
1919 this.XmlOutput.WriteStartElement(
"RowDefinition");
1920 this.XmlOutput.WriteAttributeString(
"Height",
"Auto");
1921 this.XmlOutput.WriteEndElement();
1924 this.XmlOutput.WriteEndElement();
1929 while (!(Loop is
null))
1931 for (i = Loop.
Start, c = Loop.
Pos; i < c; i++)
1936 this.GetMargins(E, out
int TopMargin, out
int BottomMargin);
1940 this.RenderContentView(
"0," + TopMargin.ToString() +
"," +
this.XamlSettings.ListContentMargin.ToString() +
"," +
1941 BottomMargin.ToString());
1942 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"0");
1943 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
1945 this.XmlOutput.WriteElementString(
"Label",
"✓");
1946 this.XmlOutput.WriteEndElement();
1949 this.XmlOutput.WriteStartElement(
"StackLayout");
1950 this.XmlOutput.WriteAttributeString(
"Grid.Column",
"1");
1951 this.XmlOutput.WriteAttributeString(
"Grid.Row", Row.ToString());
1952 this.XmlOutput.WriteAttributeString(
"Orientation",
"Vertical");
1954 if (ParagraphBullet)
1957 await this.RenderLabel(E,
false);
1959 this.XmlOutput.WriteEndElement();
1967 this.XmlOutput.WriteEndElement();
1968 this.XmlOutput.WriteEndElement();
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
string ShortName
Emoji short name.
string Unicode
Unicode representation of emoji.
Contains information about an emoji image.
int? Width
Width of image, if available.
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,...
Contains settings that the Markdown parser uses to customize its behavior.
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.
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).
Renders XAML (Xamarin.Forms flavour) from a Markdown document.
override async Task Render(DefinitionTerms Element)
Renders Element .
override async Task Render(CodeBlock Element)
Renders Element .
override async Task Render(Header Element)
Renders Element .
override async Task Render(LeftAligned Element)
Renders Element .
override async Task Render(Table Element)
Renders Element .
override Task Render(NumberedItem Element)
Renders Element .
TextAlignment Alignment
Current text-alignment.
override Task Render(Model.SpanElements.Multimedia Element)
Renders Element .
XamarinFormsXamlRenderer(XmlWriterSettings XmlSettings, XamlSettings XamlSettings)
Renders XAML (Xamarin.Forms flavour) from a Markdown document.
void RenderLabelAlignment()
Writes a text-alignment attribute to a Xamarin.Forms label element.
override async Task Render(DefinitionDescriptions Element)
Renders Element .
override Task Render(HtmlEntity Element)
Renders Element .
override async Task Render(SuperScript Element)
Renders Element .
override async Task Render(InsertBlocks Element)
Renders Element .
bool Underline
If text is underlined
async Task RenderObject(object Result, bool AloneInParagraph, Variables Variables)
Generates Xamarin.Forms XAML from Script output.
override Task Render(Abbreviation Element)
Renders Element .
override Task Render(HashTag Element)
Renders Element .
override async Task Render(HtmlBlock Element)
Renders Element .
override Task Render(InlineText Element)
Renders Element .
override Task Render(MetaReference Element)
Renders Element .
override async Task Render(Delete Element)
Renders Element .
override Task Render(AutomaticLinkMail Element)
Renders Element .
override async Task Render(LinkReference Element)
Renders Element .
override void Dispose()
Disposes of the renderer.
override Task Render(DefinitionList Element)
Renders Element .
override async Task Render(Insert Element)
Renders Element .
override Task RenderDocumentFooter()
Renders the document header.
override Task Render(UnnumberedItem Element)
Renders Element .
override Task RenderDocument(MarkdownDocument Document, bool Inclusion)
Renders a document.
override Task Render(MultimediaReference Element)
Renders Element .
readonly XamlSettings XamlSettings
XAML settings.
override async Task Render(InlineScript Element)
Renders Element .
override Task Render(LineBreak Element)
Renders Element .
override async Task Render(FootnoteReference Element)
Renders Element .
override async Task Render(Strong Element)
Renders Element .
override Task Render(Footnote Element)
Renders Element .
override Task Render(HorizontalRule Element)
Renders Element .
override async Task Render(CenterAligned Element)
Renders Element .
override async Task Render(NestedBlock Element)
Renders Element .
override async Task RenderFootnotes()
Renders footnotes.
override Task Render(Sections Element)
Renders Element .
bool Italic
If text is italic
override Task Render(CommentBlock Element)
Renders Element .
bool StrikeThrough
If text is stricken through
override async Task Render(Underline Element)
Renders Element .
bool Subscript
If text is subscript
override Task Render(TaskItem Element)
Renders Element .
override Task Render(InlineCode Element)
Renders Element .
override Task Render(InlineHTML Element)
Renders Element .
override Task Render(InvisibleBreak Element)
Renders Element .
readonly XmlWriter XmlOutput
XML output
bool Code
If text is inline code.
override async Task Render(SubScript Element)
Renders Element .
override async Task Render(BulletList Element)
Renders Element .
override async Task Render(NumberedList Element)
Renders Element .
override Task Render(SectionSeparator Element)
Renders Element .
override async Task Render(MarginAligned Element)
Renders Element .
bool InLabel
If rendering is inside a label.
override async Task Render(TaskList Element)
Renders Element .
override Task Render(AutomaticLinkUrl Element)
Renders Element .
override Task RenderDocumentHeader()
Renders the document header.
bool Superscript
If text is superscript
override async Task Render(StrikeThrough Element)
Renders Element .
override Task Render(DetailsReference Element)
Renders Element .
override async Task Render(Paragraph Element)
Renders Element .
override async Task Render(Link Element)
Renders Element .
override async Task Render(BlockQuote Element)
Renders Element .
string Hyperlink
Link, if rendering a hyperlink, null otherwise.
override async Task Render(Emphasize Element)
Renders Element .
override async Task Render(DeleteBlocks Element)
Renders Element .
override async Task Render(RightAligned Element)
Renders Element .
XamarinFormsXamlRenderer(StringBuilder Output, XmlWriterSettings XmlSettings, XamlSettings XamlSettings)
Renders XAML (Xamarin.Forms flavour) from a Markdown document.
override Task Render(HtmlEntityUnicode Element)
Renders Element .
override async Task Render(EmojiReference Element)
Renders Element .
Contains settings that the XAML export uses to customize XAML output.
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.
ChunkNode< T > FirstChunk
First chunk
int Count
Number of elements in collection.
ToMatrix(ScriptNode Operand, bool NullCheck, int Start, int Length, Expression Expression)
To-Matrix operator.
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 code content Xamarin.Forms XAML renderers.
Interface for multimedia content Xamarin.Forms XAML renderers.
Interface for objects that can be converted into matrices.
TextAlignment
Text alignment of contents.