public void Visit(HtmlTag table)
 {
     if (table.TagName().ToLower() != HtmlTagConstants.Table)
     {
         throw new ArgumentException(string.Format("Expected tag to be a <{0}> tag, but was <{1}>", HtmlTagConstants.Table,
                                                   table.TagName()));
     }
     table.Children.ForEach(VisitTableChild);
 }
 public ExportImage VisitImage(HtmlTag imageTag)
 {
     if (imageTag.TagName().ToLower() != HtmlTagConstants.Img)
     {
         throw new ArgumentException(string.Format("Expected tag to be a <{0}> tag, but was <{1}>", HtmlTagConstants.Img,
                                                   imageTag.TagName()));
     }
     var image = (ImageTag) imageTag;
     return new ExportImage {Source = image.Src(), AlternateText = image.Alt()};
 }
 public ExportList VisitList(HtmlTag list )
 {
     if(list.TagName().ToLower() != HtmlTagConstants.Ul )
     {
         throw new ArgumentException(string.Format("Expected tag to be a <{0}> tag, but was <{1}>", HtmlTagConstants.Ul,
                                               list.TagName()));
     }
     var exportList = new ExportList();
     list.Children.ForEach(f => VisitListItem(f, exportList));
     return exportList;
 }
 private void AssertOptionGroup(
     HtmlTag optgroup,
     string display)
 {
     Assert.Equal("optgroup", optgroup.TagName());
     Assert.Equal(display, optgroup.Attr("label"));
 }
        public void do_nothing_to_a_link_that_is_authorized()
        {
            var tag = new HtmlTag("a").Authorized(true)
                .ReadOnlyIfNotAuthorized();

            tag.Authorized().ShouldBeTrue();
            tag.TagName().ShouldEqual("a");
        }
        public void do_nothing_to_a_div()
        {
            var tag = new HtmlTag("div").Authorized(false)
                .ReadOnlyIfNotAuthorized();

            tag.Authorized().ShouldBeFalse();
            tag.TagName().ShouldEqual("div");
        }
        public void change_an_unauthorized_link_to_a_span_and_authorize_the_span()
        {
            var tag = new HtmlTag("a").Authorized(false)
                .ReadOnlyIfNotAuthorized();

            tag.Authorized().ShouldBeTrue();
            tag.TagName().ShouldEqual("span");
        }
 private void AssertOption(
     HtmlTag option,
     string display, 
     object value)
 {
     Assert.Equal("option", option.TagName());
     Assert.Equal(display, option.Text());
     Assert.True(option.ValueIsEqual(value));
 }
        public void VisitListItem(HtmlTag list, ExportListItem exportList)
        {
            var item = new ExportListItem();
            if(list.TagName().ToLower() == HtmlTagConstants.Ul)
            {
                item = new ExportList();
            }

            list.Children.ForEach(f => VisitListItem(f, item));
            item.Text = ExportFromTable.HtmlTagRegex.Replace(list.Text(), String.Empty);

            exportList.AddItem(item);
        }
Esempio n. 10
0
        public void AssertValid(HtmlTag tag, string tagName, string name, string type = "", object value = null)
        {
            Assert.Equal(tagName, tag.TagName());
            Assert.Equal(name, tag.Attr("name"));
            Assert.Equal(name, tag.Attr("id"));

            if (type == null)
                Assert.False(tag.HasAttr("type"));
            else
                Assert.Equal(type, tag.Attr("type"));

            if (value == null)
                Assert.True(!tag.HasAttr("value") || tag.Attr("value") == "");
            else
                Assert.Equal(value.ToString(), tag.Attr("value"));
        }
Esempio n. 11
0
            public ChildTagBuilder(SpecHierarchyBuilder builder, HtmlTag parent)
            {
                if (parent.TagName() != "ul")
                {
                    throw new ArgumentOutOfRangeException("Only ul tags are valid here:  \n" + parent.ToString());
                }

                _builder = builder;
                _parent = parent;
            }
Esempio n. 12
0
        public HtmlTag TopTag(HtmlTag topChild)
        {
            if (topChild.TagName() != "ul")
            {
                throw new ArgumentOutOfRangeException("Only ul tags are valid here:  \n" + topChild.ToString());
            }

            var topUrl = _urls.UrlFor<JasminePages>(x => x.AllSpecs());
            return new HtmlTag("ul", tag =>
            {
                tag.Id("all-specs-node").AddClass("filetree");

                var link = new LinkTag("All Specs", topUrl, "all-specs");
                var li = tag.Add("li");
                li.Add("span").AddClass("folder").Append(link);

                li.Append(topChild);
            });
        }
 private void VisitTableChild(HtmlTag child)
 {
     var tag = child.TagName().ToLower();
     switch (tag)
     {
         case HtmlTagConstants.Tr:
             VisitTableRow(child);
             break;
         case HtmlTagConstants.Caption:
             VisitCaption(child);
             break;
         default:
             child.Children.ForEach(VisitTableChild);
             break;
     }
 }
        private static void VisitTableCell(HtmlTag cell, ExportRow exportRow)
        {
            var tag = cell.TagName().ToLower();
            if (tag != HtmlTagConstants.Td && tag != HtmlTagConstants.Th )
            {
                cell.Children.ForEach(c => VisitTableCell(c, exportRow));
                return;
            }
            var isImage = cell.Children.Any(c => c.TagName().ToLower() == HtmlTagConstants.Img);
            var text = cell.Children.Any() ? cell.ToString() : cell.Text();
            var exportCell = new ExportCell
                             	{
                                    Text =  ExportFromTable.HtmlTagRegex.Replace(text ?? string.Empty, string.Empty),
                                    Markup = isImage ? cell.FirstChild().ToString():string.Empty
                                };

            SetColspan(cell, exportCell);
            exportRow.AddCell(exportCell);
        }