예제 #1
0
 protected override void Write(MamlRenderer renderer, AutolinkInline obj)
 {
     renderer.Push(MamlElements.externalLink);
     renderer.Push(MamlElements.linkUri);
     renderer.Write(obj.Url);
     renderer.PopTo(MamlElements.linkUri);
     renderer.PopTo(MamlElements.externalLink);
 }
예제 #2
0
        protected override void Write(MamlRenderer renderer, ThematicBreakBlock obj)
        {
            // since there is no direct equivalent to a thematic break in Maml,
            // here we use a paragraph with 80 underlines

            renderer.Push(MamlElements.markup);
            renderer.Write("<hr/>");
            renderer.PopTo(MamlElements.markup);
        }
예제 #3
0
        protected override void Write(MamlRenderer renderer, Table table)
        {
            renderer.Push(MamlElements.table);
            renderer.Push(MamlElements.tableHeader);

            foreach (TableRow row in table)
            {
                if (row.IsHeader)
                {
                    renderer.Push(MamlElements.row);

                    foreach (TableCell cell in row)
                    {
                        renderer.Push(MamlElements.entry);
                        renderer.Write(cell);
                        renderer.PopTo(MamlElements.entry);
                    }

                    renderer.PopTo(MamlElements.row);
                }
            }

            renderer.PopTo(MamlElements.tableHeader);

            foreach (TableRow row in table)
            {
                if (!row.IsHeader)
                {
                    renderer.Push(MamlElements.row);

                    foreach (TableCell cell in row)
                    {
                        renderer.Push(MamlElements.entry);
                        renderer.Write(cell);
                        renderer.PopTo(MamlElements.entry);
                    }

                    renderer.PopTo(MamlElements.row);
                }
            }

            renderer.PopTo(MamlElements.table);
        }
예제 #4
0
        /// <inheritdoc/>
        protected override void Write(MamlRenderer renderer, LinkInline link)
        {
            var url = link.GetDynamicUrl != null?link.GetDynamicUrl() ?? link.Url : link.Url;

            if (link.IsImage)
            {
                RenderImage(renderer, link, url);
            }
            else // link is not an image
            {
                if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
                {
                    renderer.Push(MamlElements.externalLink);
                    renderer.Push(MamlElements.linkText);
                    renderer.WriteChildren(link);
                    renderer.PopTo(MamlElements.linkText);

                    renderer.Push(MamlElements.linkUri);
                    renderer.Write(url);
                    renderer.PopTo(MamlElements.linkUri);
                    renderer.PopTo(MamlElements.externalLink);
                }
                else // not a well formed Uri String - then it is probably a fragment reference
                {
                    // the challenge here is to find out where (in which file) our target is. The file might even not be defined in the moment
                    var(fileGuid, localUrl) = renderer.FindFragmentLink(url);
                    string totalAddress = string.Empty;
                    if (null != fileGuid && null != localUrl)
                    {
                        totalAddress = fileGuid + "#" + localUrl;
                    }

                    renderer.Push(MamlElements.link, new[] { new KeyValuePair <string, string>("xlink:href", totalAddress) });
                    renderer.WriteChildren(link);
                    renderer.PopTo(MamlElements.link);
                }
            }
        }