//
        // methods
        //

        #region public IPDFComponent GetComponent(IContentParser parser, string name)

        /// <summary>
        /// Returns a new component for the parser based on the specified tag name.
        /// </summary>
        /// <param name="parser"></param>
        /// <param name="name"></param>
        /// <returns>The instaniated component or null if the name is not recognised</returns>
        public IPDFComponent GetComponent(IHtmlContentParser parser, string name, out HtmlComponentType type)
        {
            IPDFComponent           proxy = null;
            IParserComponentFactory innerfact;

            if (null != _last && _lastName == name)
            {
                proxy = _last.GetComponent(parser, name, out type);
            }
            else if (_knowntags.TryGetValue(name, out innerfact))
            {
                _last     = innerfact;
                _lastName = name;
                proxy     = innerfact.GetComponent(parser, name, out type);
            }
            else
            {
                _last     = null;
                _lastName = null;
                type      = HtmlComponentType.Unknown;
                proxy     = GetUnknownComponent(parser, name);
            }

            if (proxy is Component)
            {
                ((Component)proxy).Tag = name;
            }
            return(proxy);
        }
        /// <summary>
        /// Sets the parsed value provided on an attribute with the specified name to the parsed component of the provided name
        /// </summary>
        /// <param name="parser"></param>
        /// <param name="parsed"></param>
        /// <param name="componentName"></param>
        /// <param name="attrName"></param>
        /// <param name="attrValue"></param>
        public void SetAttribute(IHtmlContentParser parser, IPDFComponent parsed, string componentName, string attrName, string attrValue)
        {
            IParserComponentFactory innerfact;

            //Quick check on the last one used - as this generally follows the component creation
            if (null != _last && _lastName == componentName)
            {
                _last.SetAttribute(parser, parsed, componentName, attrName, attrValue);
            }
            else if (_knowntags.TryGetValue(componentName, out innerfact))
            {
                _last     = innerfact;
                _lastName = componentName;
                innerfact.SetAttribute(parser, parsed, componentName, attrName, attrValue);
            }
            else
            {
                //Skip the attribute
            }
        }
        /// <summary>
        /// Returns true if the component is a container of other components or text
        /// </summary>
        /// <param name="parser"></param>
        /// <param name="component"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool IsContainerComponent(IHtmlContentParser parser, IPDFComponent component, string name)
        {
            bool container = false;
            IParserComponentFactory innerfact;

            if (null != _last && _lastName == name)
            {
                container = _last.IsContainerComponent(parser, component, name);
            }
            else if (_knowntags.TryGetValue(name, out innerfact))
            {
                _last     = innerfact;
                _lastName = name;
                container = _last.IsContainerComponent(parser, component, name);
            }
            else
            {
                _last     = null;
                _lastName = null;
                container = false;
            }
            return(container);
        }
        //
        // implementation methods
        //

        #region protected virtual void Init(string text, IParserComponentFactory factory)

        /// <summary>
        /// Initializes this instance with the text and factory. Inheritors can override
        /// </summary>
        /// <param name="text"></param>
        /// <param name="factory"></param>
        protected virtual void Init(string text, IParserComponentFactory factory, IParserStyleFactory styles, HTMLParserSettings settings)
        {
            if (null == settings)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (null == factory)
            {
                factory = new HTMLParserComponentFactory();
            }

            if (null == styles)
            {
                styles = new CSSStyleItemAllParser();
            }

            _text         = text;
            _instanceFact = factory;
            _settings     = settings;
            _styleFact    = styles;
            _shouldlog    = null != _settings.Context;
        }
        //
        // implementation methods
        //

        #region protected virtual void Init(string text, IParserComponentFactory factory)

        /// <summary>
        /// Initializes this instance with the text and factory. Inheritors can override
        /// </summary>
        /// <param name="text"></param>
        /// <param name="factory"></param>
        protected virtual void Init(string text, IParserComponentFactory factory, IParserStyleFactory styles, HTMLParserSettings settings)
        {
            if (null == factory)
            {
                factory = new HTMLParserComponentFactory();
            }

            if (null == styles)
            {
                styles = new CSSStyleItemAllParser();
            }

            if (null == settings)
            {
                settings = new HTMLParserSettings();
            }

            _text         = text;
            _instanceFact = factory;
            _settings     = settings;
            _styleFact    = styles;

            _shouldlog = null != _settings.TraceLog && _settings.TraceLog.ShouldLog(_settings.LogLevel);
        }
 /// <summary>
 /// Creates a new instance of an HTMLParser that will convert the specified text into a series of Components using the component factory.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="componentFactory">The component factory (can be null)</param>
 /// <param name="styleFactory">The style value factory (can be null)</param>
 /// <param name="settings">The parser settings (can be null)</param>
 public HTMLParser(string text, IParserComponentFactory componentFactory, IParserStyleFactory styleFactory, HTMLParserSettings settings)
 {
     this.Init(text, componentFactory, styleFactory, settings);
 }
 /// <summary>
 /// Retuns a new textual component that represents the text string provided
 /// </summary>
 /// <param name="parser"></param>
 /// <param name="text"></param>
 /// <returns></returns>
 public virtual IPDFComponent GetTextComponent(IHtmlContentParser parser, string text)
 {
     _last     = null;
     _lastName = null;
     return(new TextLiteral(text));
 }