Пример #1
0
 /// <summary> Finish off a tag.
 /// Perhap add a virtual end tag.
 /// Set the end tag parent as this tag.
 /// Perform the semantic acton.
 /// </summary>
 /// <param name="tag">The tag to finish off.
 /// </param>
 /// <param name="lexer">A lexer positioned at the end of the tag.
 /// </param>
 protected internal virtual void FinishTag(ITag tag, Lexer lexer)
 {
     if (null == tag.GetEndTag())
     {
         tag.SetEndTag(CreateVirtualEndTag(tag, lexer, lexer.Page, lexer.Cursor.Position));
     }
     tag.GetEndTag().Parent = tag;
     tag.DoSemanticAction();
 }
        /// <summary> Scan for script.
        /// Accumulates text from the page, until &lt;/[a-zA-Z] is encountered.
        /// </summary>
        /// <param name="tag">The tag this scanner is responsible for.
        /// </param>
        /// <param name="lexer">The source of CDATA.
        /// </param>
        /// <param name="stack">The parse stack, <em>not used</em>.
        /// </param>
        public override ITag Scan(ITag tag, Lexer lexer, NodeList stack)
        {
            System.String language;
            System.String code;
            INode         content;
            int           position;
            INode         node;
            TagAttribute  attribute;

            System.Collections.ArrayList vector;

            if (tag is ScriptTag)
            {
                language = ((ScriptTag)tag).Language;
                if ((null != language) && (language.ToUpper().Equals("JScript.Encode".ToUpper()) || language.ToUpper().Equals("VBScript.Encode".ToUpper())))
                {
                    code = ScriptDecoder.Decode(lexer.Page, lexer.Cursor);
                    ((ScriptTag)tag).ScriptCode = code;
                }
            }
            content  = lexer.ParseCDATA(!STRICT);
            position = lexer.Position;
            node     = lexer.NextNode(false);
            if (null != node)
            {
                if (!(node is ITag) || !(((ITag)node).IsEndTag() && ((ITag)node).TagName.Equals(tag.Ids[0])))
                {
                    lexer.Position = position;
                    node           = null;
                }
            }

            // build new end tag if required
            if (null == node)
            {
                attribute = new TagAttribute("/script", null);
#if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR
                vector = ArrayList_WP_8_1.ArrayList.Synchronized(new System.Collections.ArrayList(10));
#else
                vector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
#endif
                vector.Add(attribute);
                node = lexer.NodeFactory.CreateTagNode(lexer.Page, position, position, vector);
            }
            tag.SetEndTag((ITag)node);
            if (null != content)
            {
                tag.Children   = new NodeList(content);
                content.Parent = tag;
            }
            node.Parent = tag;
            tag.DoSemanticAction();

            return(tag);
        }
Пример #3
0
        /// <summary> Scan for style definitions.
        /// Accumulates text from the page, until &lt;/[a-zA-Z] is encountered.
        /// </summary>
        /// <param name="tag">The tag this scanner is responsible for.
        /// </param>
        /// <param name="lexer">The source of CDATA.
        /// </param>
        /// <param name="stack">The parse stack, <em>not used</em>.
        /// </param>
        public override ITag Scan(ITag tag, Lexer lexer, NodeList stack)
        {
            INode        content;
            int          position;
            INode        node;
            TagAttribute attribute;

            System.Collections.ArrayList vector;

            content  = lexer.ParseCDATA();
            position = lexer.Position;
            node     = lexer.NextNode(false);
            if (null != node)
            {
                if (!(node is ITag) || !(((ITag)node).IsEndTag() && ((ITag)node).TagName.Equals(tag.Ids[0])))
                {
                    lexer.Position = position;
                    node           = null;
                }
            }

            // build new end tag if required
            if (null == node)
            {
                attribute = new TagAttribute("/style", null);
#if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR
                vector = ArrayList_WP_8_1.ArrayList.Synchronized(new System.Collections.ArrayList(10));
#else
                vector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
#endif
                vector.Add(attribute);
                node = lexer.NodeFactory.CreateTagNode(lexer.Page, position, position, vector);
            }
            tag.SetEndTag((ITag)node);
            if (null != content)
            {
                tag.Children   = new NodeList(content);
                content.Parent = tag;
            }
            node.Parent = tag;
            tag.DoSemanticAction();

            return(tag);
        }
		/// <summary> Scan for style definitions.
		/// Accumulates text from the page, until &lt;/[a-zA-Z] is encountered.
		/// </summary>
		/// <param name="tag">The tag this scanner is responsible for.
		/// </param>
		/// <param name="lexer">The source of CDATA.
		/// </param>
		/// <param name="stack">The parse stack, <em>not used</em>.
		/// </param>
		public override ITag Scan(ITag tag, Lexer lexer, NodeList stack)
		{
			INode content;
			int position;
			INode node;
			TagAttribute attribute;
			System.Collections.ArrayList vector;
			
			content = lexer.ParseCDATA();
			position = lexer.Position;
			node = lexer.NextNode(false);
			if (null != node)
				if (!(node is ITag) || !(((ITag) node).IsEndTag() && ((ITag) node).TagName.Equals(tag.Ids[0])))
				{
					lexer.Position = position;
					node = null;
				}
			
			// build new end tag if required
			if (null == node)
			{
				attribute = new TagAttribute("/style", null);
				vector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
				vector.Add(attribute);
				node = lexer.NodeFactory.CreateTagNode(lexer.Page, position, position, vector);
			}
			tag.SetEndTag((ITag) node);
			if (null != content)
			{
				tag.Children = new NodeList(content);
				content.Parent = tag;
			}
			node.Parent = tag;
			tag.DoSemanticAction();
			
			return (tag);
		}
Пример #5
0
        /// <summary> Scan the tag.
        /// For this implementation, the only operation is to perform the tag's
        /// semantic action.
        /// </summary>
        /// <param name="tag">The tag to scan.
        /// </param>
        /// <param name="lexer">Provides html page access.
        /// </param>
        /// <param name="stack">The parse stack. May contain pending tags that enclose
        /// this tag.
        /// </param>
        /// <returns> The resultant tag (may be unchanged).
        /// </returns>
        public virtual ITag Scan(ITag tag, Winista.Text.HtmlParser.Lex.Lexer lexer, NodeList stack)
        {
            tag.DoSemanticAction();

            return(tag);
        }
		/// <summary> Scan the tag.
		/// For this implementation, the only operation is to perform the tag's
		/// semantic action.
		/// </summary>
		/// <param name="tag">The tag to scan.
		/// </param>
		/// <param name="lexer">Provides html page access.
		/// </param>
		/// <param name="stack">The parse stack. May contain pending tags that enclose
		/// this tag.
		/// </param>
		/// <returns> The resultant tag (may be unchanged).
		/// </returns>
		public virtual ITag Scan(ITag tag, Winista.Text.HtmlParser.Lex.Lexer lexer, NodeList stack)
		{
			tag.DoSemanticAction();
			
			return (tag);
		}
		/// <summary> Scan for script.
		/// Accumulates text from the page, until &lt;/[a-zA-Z] is encountered.
		/// </summary>
		/// <param name="tag">The tag this scanner is responsible for.
		/// </param>
		/// <param name="lexer">The source of CDATA.
		/// </param>
		/// <param name="stack">The parse stack, <em>not used</em>.
		/// </param>
		public override ITag Scan(ITag tag, Lexer lexer, NodeList stack)
		{
			System.String language;
			System.String code;
			INode content;
			int position;
			INode node;
			TagAttribute attribute;
			System.Collections.ArrayList vector;
			
			if (tag is ScriptTag)
			{
				language = ((ScriptTag) tag).Language;
				if ((null != language) && (language.ToUpper().Equals("JScript.Encode".ToUpper()) || language.ToUpper().Equals("VBScript.Encode".ToUpper())))
				{
					code = ScriptDecoder.Decode(lexer.Page, lexer.Cursor);
					((ScriptTag) tag).ScriptCode = code;
				}
			}
			content = lexer.ParseCDATA(!STRICT);
			position = lexer.Position;
			node = lexer.NextNode(false);
			if (null != node)
				if (!(node is ITag) || !(((ITag) node).IsEndTag() && ((ITag) node).TagName.Equals(tag.Ids[0])))
				{
					lexer.Position = position;
					node = null;
				}
			
			// build new end tag if required
			if (null == node)
			{
				attribute = new TagAttribute("/script", null);
				vector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
				vector.Add(attribute);
				node = lexer.NodeFactory.CreateTagNode(lexer.Page, position, position, vector);
			}
			tag.SetEndTag((ITag) node);
			if (null != content)
			{
				tag.Children = new NodeList(content);
				content.Parent = tag;
			}
			node.Parent = tag;
			tag.DoSemanticAction();
			
			return (tag);
		}
		/// <summary> Finish off a tag.
		/// Perhap add a virtual end tag.
		/// Set the end tag parent as this tag.
		/// Perform the semantic acton.
		/// </summary>
		/// <param name="tag">The tag to finish off.
		/// </param>
		/// <param name="lexer">A lexer positioned at the end of the tag.
		/// </param>
		protected internal virtual void FinishTag(ITag tag, Lexer lexer)
		{
			if (null == tag.GetEndTag())
			{
				tag.SetEndTag(CreateVirtualEndTag(tag, lexer, lexer.Page, lexer.Cursor.Position));
			}
			tag.GetEndTag().Parent = tag;
			tag.DoSemanticAction();
		}