예제 #1
0
 public static Element CreateElement(CodeRenderer.MarkupStructure.Tag tag, Element ParentElement)
 {
     Element element;
     switch (tag.name)
     {
         case "br":
             element = new NewLine(ParentElement);
             break;
         case "img":
             element = new Image(tag.Attributes,ParentElement);
             break;
         case "body":
             element = new Body(tag.Attributes,ParentElement);
             break;
         case "div":
             element = new Section(tag.Attributes,ParentElement);
             break;
         case "p":
             element = new Paragraph(tag.Attributes,ParentElement);
             break;
         default:
             throw new NotImplementedException();
             break;
     }
     return element;
 }
예제 #2
0
        protected static Element RenderTag(CodeRenderer.MarkupStructure.Tag tag,Element ParentElement)
        {
            Element element = Element.CreateElement(tag,ParentElement);
            bool isPrevText = false;
            switch (element.type)
            {
                case ElementType.DIVISION:

                    Section division = (Section)element;
                    foreach(CodeRenderer.MarkupStructure.Token token in tag.Content)
                        if (token is CodeRenderer.MarkupStructure.Text)
                        //if (token.type == CodeRenderer.MarkupStructure.TokenType.TEXT)
                        {
                            if (isPrevText)
                                division.Add(new Text(" ",division));
                            division.Add(new Text((CodeRenderer.MarkupStructure.Text)token,division));
                            isPrevText = true;
                        }
                        else
                        {
                            division.Add(RenderTag((CodeRenderer.MarkupStructure.Tag)token,division));
                            isPrevText = false;
                        }

                    break;
                default:
                    //throw new NotImplementedException();
                    break;
            }
            return element;
        }
예제 #3
0
 protected static Head RenderHead(CodeRenderer.MarkupStructure.Tag HeadTag,Element ParentElement)
 {
     Head Head = new Head(HeadTag.Attributes,ParentElement);
     foreach (CodeRenderer.MarkupStructure.Tag tag in HeadTag.Content)
         if (tag.name == "title")
             Head.Title = RenderTitle(tag);
         else throw new NotImplementedException();
     return Head;
 }
예제 #4
0
 public Attributes(List<CodeRenderer.MarkupStructure.TagAttribute> Attributes, Element ParentElement = null)
 {
     Map = new Dictionary<string, string>();
     if (ParentElement != null)
         Map = new Dictionary<string,string>(ParentElement.Attributes.Map);
     if (Attributes != null)
     {
         foreach (CodeRenderer.MarkupStructure.TagAttribute Attribute in Attributes)
         {
             if (Map.ContainsKey(Attribute.Key))
                 Map[Attribute.Key] = Attribute.Value;
             else Map.Add(Attribute.Key, Attribute.Value);
         }
     }
 }
예제 #5
0
파일: Style.cs 프로젝트: ramyothman/ifekra
 public Style(Attributes Attributes, Element ParentElement)
 {
     this.Map = new Dictionary<string, string>();
     if (ParentElement != null)
         this.Map = new Dictionary<string,string>(ParentElement.Style.Map);
     if (Attributes.Map.ContainsKey("style"))
     {
         List<KeyValuePair<string, string>> StyleList = ParseStyle(Attributes.Map["style"]);
         foreach (KeyValuePair<string, string> StyleToken in StyleList)
         {
             if (Map.ContainsKey(StyleToken.Key))
                 Map[StyleToken.Key] = StyleToken.Value;
             else Map.Add(StyleToken.Key, StyleToken.Value);
         }
     }
 }
예제 #6
0
 public Text(CodeRenderer.MarkupStructure.Text text, Element ParentElement)
     : base(null, ParentElement)
 {
     this.type = ElementType.TEXT;
     this.text = HtmlToText(text.text);
 }
예제 #7
0
 public Element(List<CodeRenderer.MarkupStructure.TagAttribute> Attributes, Element ParentElement)
 {
     this.ParentElement = ParentElement;
     this.Attributes = new Attributes(Attributes, ParentElement);
     this.Style = new Style(this.Attributes, ParentElement);
 }
예제 #8
0
 public virtual void Add(Element element)
 {
     Elements.Add(element);
 }
예제 #9
0
 public Text(string text, Element ParentElement)
     : base(null, ParentElement)
 {
     this.type = ElementType.TEXT;
     this.text = text;
 }
예제 #10
0
 public Section(List<CodeRenderer.MarkupStructure.TagAttribute> Attributes,Element ParentElement)
     : base(Attributes,ParentElement)
 {
     this.type = ElementType.DIVISION;
     this.Elements = new List<Element>();
 }
예제 #11
0
 public Body(List<CodeRenderer.MarkupStructure.TagAttribute> Attributes,Element ParentElement)
     : base(Attributes,ParentElement)
 {
 }
예제 #12
0
 public override void Add(Element element)
 {
     base.Add(element);
 }
예제 #13
0
 public NewLine(Element ParentElement)
 {
     this.type = ElementType.NEWLINE;
 }
예제 #14
0
 public Image(List<CodeRenderer.MarkupStructure.TagAttribute> Attributes, Element ParentElement)
     : base(Attributes, ParentElement)
 {
     foreach (CodeRenderer.MarkupStructure.TagAttribute attribute in Attributes)
     {
         switch (attribute.Key)
         {
             case "src":
                 this.Path = attribute.Value;
                 break;
             case "alt":
                 this.Alt = attribute.Value;
                 break;
             default:
                 throw new NotImplementedException();
         }
     }
 }