public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
        {
            var closing = self.NextNodeOfType <YouTubeCloseTag>();

            var content = self.Next.GetOriginalContentUntilNode(closing);

            if (!string.IsNullOrEmpty(content))
            {
                string content2 = content.Replace("autoplay=1", "");
                var    match    = Regex.Match(content2, "v=([^&]+)");
                if (match.Success)
                {
                    context.AppendFormat("<iframe width=\"420\" height=\"315\" src=\"https://www.youtube.com/embed/{0}\" frameborder=\"0\" hd=\"1\" allowfullscreen=\"1\"></iframe>", match.Groups[1].Value);
                    return(closing.Next);
                }
                match = Regex.Match(content2, @"\.be/([^&]+)");
                if (match.Success)
                {
                    context.AppendFormat("<iframe width=\"420\" height=\"315\" src=\"https://www.youtube.com/embed/{0}\" frameborder=\"0\" hd=\"1\" allowfullscreen=\"1\"></iframe>", match.Groups[1].Value);
                    return(closing.Next);
                }
            }

            return(closing.Next);
        }
        public override LinkedListNode<Tag> Translate(TranslateContext context, LinkedListNode<Tag> self) {
            if (Text.IsValidLink())
            {
                // implicit linkification and imagifination
                if (Text.EndsWith(".png") || Text.EndsWith(".gif") || Text.EndsWith(".jpg") || Text.EndsWith(".jpeg")) context.AppendFormat("<a href=\"{0}\" target=\"_blank\" ><img src=\"{0}\" max-width=\"100%\" height=\"auto\"/></a>", Text);
                // YouTube auto-embed
                else if (Text.StartsWith("http://www.youtube.com/watch") || Text.StartsWith("https://www.youtube.com/watch"))
                {
                    var m = Regex.Match(Text,"v=([^&]+)");
                    if (m.Success)
                    {
                        context.AppendFormat("<iframe width=\"420\" height=\"315\" src=\"http://www.youtube.com/embed/{0}\" frameborder=\"0\" hd=\"1\" allowfullscreen=\"1\"></iframe>", m.Groups[1].Value);
                    }
                }
                else if (Text.StartsWith("http://youtu.be/") || Text.StartsWith("https://youtu.be/"))
                {
                    var m = Regex.Match(Text, @"\.be/([^&?]+)");
                    if (m.Success)
                    {
                        context.AppendFormat("<iframe width=\"420\" height=\"315\" src=\"http://www.youtube.com/embed/{0}\" frameborder=\"0\" hd=\"1\" allowfullscreen=\"1\"></iframe>", m.Groups[1].Value);
                    }
                }
                else context.AppendFormat("<a href=\"{0}\">{0}</a>", Text);
            } else context.Append(HttpUtility.HtmlEncode(Text));

            return self.Next;
        }
Example #3
0
        public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
        {
            var closing = self.FirstNode(x => x.Value is CodeCloseTag);
            var str     = self.Next.GetOriginalContentUntilNode(closing);

            context.AppendFormat("<pre>{0}</pre>", HttpUtility.HtmlEncode(str));
            return(closing.Next);
        }
        public override LinkedListNode<Tag> Translate(TranslateContext context, LinkedListNode<Tag> self) {
            var parts = arguments.Split(new[] { ' ' }, 2);
            var name = parts.Length > 1 ? parts[1] : parts[0];
            var link = parts[0];
            if (link.IsValidLink()) context.AppendFormat("<a href=\"{0}\">{1}</a>", link, name);
            else context.Append(context.Html?.ActionLink(name, "Index", "Wiki", new { node = link }, null));

            return self.Next;
        }
        public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
        {
            if (Text.IsValidLink())
            {
                // implicit linkification and imagifination
                if ((Text.EndsWith(".png") || Text.EndsWith(".gif") || Text.EndsWith(".jpg") || Text.EndsWith(".jpeg")) && Text.IsValidLinkOrRelativeUrl(true))
                {
                    context.AppendFormat("<a href=\"{0}\" target=\"_blank\" ><img src=\"{0}\" max-width=\"100%\" height=\"auto\"/></a>", Text);
                }
                // YouTube auto-embed
                else if (Text.StartsWith("http://www.youtube.com/watch") || Text.StartsWith("https://www.youtube.com/watch"))
                {
                    var m = Regex.Match(Text.Replace("autoplay=1", ""), "v=([^&]+)");
                    if (m.Success)
                    {
                        context.AppendFormat("<iframe width=\"420\" height=\"315\" src=\"https://www.youtube.com/embed/{0}\" frameborder=\"0\" hd=\"1\" allowfullscreen=\"1\"></iframe>", m.Groups[1].Value);
                    }
                }
                else if (Text.StartsWith("http://youtu.be/") || Text.StartsWith("https://youtu.be/"))
                {
                    var m = Regex.Match(Text.Replace("autoplay=1", ""), @"\.be/([^&?]+)");
                    if (m.Success)
                    {
                        context.AppendFormat("<iframe width=\"420\" height=\"315\" src=\"https://www.youtube.com/embed/{0}\" frameborder=\"0\" hd=\"1\" allowfullscreen=\"1\"></iframe>", m.Groups[1].Value);
                    }
                }
                else
                {
                    context.AppendFormat("<a href=\"{0}\">{0}</a>", Text);
                }
            }
            else
            {
                context.Append(HttpUtility.HtmlEncode(Text));
            }

            return(self.Next);
        }
Example #6
0
        public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
        {
            var closingTag = self.NextNodeOfType <ImgCloseTag>();

            // get url either from param or from inner literal between tags
            var url = arguments.Length == 0 ? self.Next.GetOriginalContentUntilNode(closingTag) : arguments.Substring(1, arguments.Length - 1);

            if (url.IsValidLinkOrRelativeUrl(true))
            {
                context.AppendFormat("<a href=\"{0}\" target=\"_blank\" ><img src=\"{0}\" max-width=\"100%\" height=\"auto\"/></a>", url);
            }

            return(closingTag?.Next); // move to after closing img
        }
Example #7
0
        public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
        {
            var parts = arguments.Split(new[] { ' ' }, 2);
            var name  = parts.Length > 1 ? parts[1] : parts[0];
            var link  = parts[0];

            if (link.IsValidLink())
            {
                context.AppendFormat("<a href=\"{0}\">{1}</a>", link, name);
            }
            else
            {
                context.Append(context.Html?.ActionLink(name, "Index", "Wiki", new { node = link }, null));
            }

            return(self.Next);
        }
        public override LinkedListNode<Tag> Translate(TranslateContext context, LinkedListNode<Tag> self) {
            var level = Text.Length;

            var ender = self.Next.FirstNode(x => x.Value is HeaderTag || x.Value is NewLineTag);
            if (ender?.Value is HeaderTag && ender.Value.Text.Length == level)
            {
                var name = HttpUtility.HtmlEncode(self.Next.GetOriginalContentUntilNode(ender).Trim());
                var link =  Account.StripInvalidLobbyNameChars(name.Replace(" ", "_").Replace("\"", "_").Replace("'", "_"));
                context.AppendFormat("<h{0}><a name=\"{1}\"></a>{2}</h{0}>", level, link, name);
                context.AddTocEntry(new TocEntry(name, link, level));

                return ender.Next;
            }

            context.Append(Text);
            return self.Next;
        }
Example #9
0
        public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
        {
            var level = Text.Length;

            var ender = self.Next.FirstNode(x => x.Value is HeaderTag || x.Value is NewLineTag);

            if (ender?.Value is HeaderTag && ender.Value.Text.Length == level)
            {
                var name = HttpUtility.HtmlEncode(self.Next.GetOriginalContentUntilNode(ender).Trim());
                var link = Utils.StripInvalidLobbyNameChars(name.Replace(" ", "_").Replace("\"", "_").Replace("'", "_"));
                context.AppendFormat("<h{0}><a name=\"{1}\"></a>{2}</h{0}>", level, link, name);
                context.AddTocEntry(new TocEntry(name, link, level));

                return(ender.Next);
            }

            context.Append(Text);
            return(self.Next);
        }
Example #10
0
        public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
        {
            var closing = self.NextNodeOfType <VidCloseTag>();

            var content = self.Next.GetOriginalContentUntilNode(closing);

            if (!string.IsNullOrEmpty(content))
            {
                var match = Regex.Match(content, @"(https?\:\/\/)((\w|-|_|\.|\/)+\.)(mp4|webm|ogg|ogv|3gp|gifv)", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    var urlPart = match.Groups[1].Value + match.Groups[2].Value;
                    context.AppendFormat(
                        "<div class=\"video-container\"><video preload=\"auto\" height=\"auto\" width=\"auto\" controls=\"controls\"><source type=\"video/webm\" src=\"{0}webm\"><source type=\"video/mp4\" src=\"{0}mp4\"><source type=\"video/ogg\" src=\"{0}ogg\"><source type=\"video/ogv\" src=\"{0}ogv\"><source type=\"video/3gp\" src=\"{0}3gp\">Your browser does not support the video tag. Find out if your Browser is supported at www.w3schools.com/tags/tag_video.asp</video></div>",
                        urlPart);
                }
            }

            return(closing.Next);
        }
Example #11
0
 public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
 {
     context.AppendFormat("<span nicetitle=\"{0}\">", arguments);
     return(self.Next);
 }
Example #12
0
 public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
 {
     context.AppendFormat("<a href=\"{0}\" target=\"_blank\">", arguments);
     return(self.Next);
 }
Example #13
0
 public override LinkedListNode <Tag> Translate(TranslateContext context, LinkedListNode <Tag> self)
 {
     context.AppendFormat(
         "<small class=\"js_expand\"><a nicetitle-processed=\"Expand/Collapse\" style=\"display:block\" href=\"#\">[Spoiler]</a></small><div style=\"display: none;\" class=\"collapse\">");
     return(self.Next);
 }