Esempio n. 1
0
        public static XPathDocument InputAs <TIn>(TIn input)
        {
            if (input == null)
            {
                return(null);
            }

            if (typeof(TIn).Equals(typeof(string)))
            {
                string s = input as string;
                s = HtmlUtility.ConvertToXml(s);
                s = LatinGlyphs.Condense(s);

                return(XmlUtility.GetNavigableDocument(s));
            }
            else if (typeof(TIn).Equals(typeof(XmlDocument)))
            {
                return(XmlUtility.GetNavigableDocument(input as XmlDocument));
            }
            else if (typeof(TIn).Equals(typeof(XPathDocument)))
            {
                return(input as XPathDocument);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Expands selected Latin glyphs
        /// into their decimal entity equivalent.
        /// </summary>
        /// <param name="glyphText">
        /// The <see cref="System.String"/>
        /// containing the glyphs.
        /// </param>
        /// <returns>
        /// Returns a <see cref="System.String"/>
        /// with decimal entities.
        /// </returns>
        public static string Expand(string glyphText)
        {
            if (_glyphs.Count == 0)
            {
                LatinGlyphs.AddGlyphs();
            }

            foreach (string s in _glyphs.Keys)
            {
                glyphText = glyphText.Replace(s, _glyphs[s]);
            }
            return(glyphText);
        }
Esempio n. 3
0
        /// <summary>
        /// Condenses selected decimal entities
        /// into their Latin glyph equivalent.
        /// </summary>
        /// <param name="entityText">
        /// The <see cref="System.String"/>
        /// containing the decimal entities.
        /// </param>
        /// <returns>
        /// Returns a <see cref="System.String"/>
        /// with Latin glyphs.
        /// </returns>
        public static string Condense(string entityText)
        {
            if (_glyphs.Count == 0)
            {
                LatinGlyphs.AddGlyphs();
            }

            foreach (string s in _glyphs.Keys)
            {
                entityText = entityText.Replace(_glyphs[s], s);
            }

            //Search for selected named entities:
            entityText = entityText.Replace("&copy;", "©");
            entityText = entityText.Replace("&eacute;", "é");
            entityText = entityText.Replace("&nbsp;", " ");
            entityText = entityText.Replace("&reg;", "®");
            entityText = entityText.Replace("&trade;", "™");

            return(entityText);
        }