Esempio n. 1
0
        public void SetStyle(string style)
        {
            OpeningHtmlTags = openingHtmlTags
                              .ToDictionary(x => x.Key, x => string.Format(x.Value, style))
                              .ToImmutableDictionary();

            htmlUrlTag = $"<a href=\"{{1}}\"{style}>{{0}}</a>";

            CodeBlockTags = new TagPair($"<pre{style}><code{style}>", "</code></pre>");
            ListTags      = new TagPair($"<ol{style}>", "</ol>");
            ListEntryTag  = new TagPair($"<li{style}>", "</li>");
            UrlTags       = new TagPair("(", ")");
            BaseTags      = new TagPair($"<html{style}>", "</html>");
            ParagraphTags = new TagPair($"<p{style}>", "</p>");
        }
Esempio n. 2
0
        private void RenderEntry(Tag starting, TagPair entryTags)
        {
            var length = text.Length;

            while (position < length)
            {
                string parsedTag;
                var    success = TryParseTag(position, out parsedTag);
                position = success ? position + parsedTag.Length : position + 1;
                if ((parsedTag == null || !language.IsLineDelimiter(parsedTag)) && position < length)
                {
                    continue;
                }
                builder.Append(entryTags.OpeningTag);
                builder.Append(text.Substring(rendered + starting.Name.Length, position - rendered - starting.Name.Length));
                builder.Append(entryTags.ClosingTag);
                rendered = position;
                return;
            }
        }
Esempio n. 3
0
        private void RenderMultilineTag(Tag opening, TagPair surroundingTags, TagPair entryTags)
        {
            builder.Append(text.Substring(rendered, opening.Position - rendered));
            builder.Append(surroundingTags.OpeningTag);
            rendered = opening.Position;
            var length   = text.Length;
            var previous = opening;

            while (position < length)
            {
                if (previous.Name != null)
                {
                    RenderEntry(previous, entryTags);
                }
                string tag;
                var    success = TryParseTag(position, out tag);
                previous = new Tag(tag, position);
                position = success ? position + tag.Length : position + 1;
            }
            builder.Append(surroundingTags.ClosingTag);
        }