IsImplicitlyClosed() public method

Determines if given element can be implicitly closed like <li> or <td> in HTML"
public IsImplicitlyClosed ( ITextProvider text, ITextRange name, string &containerElementNames ) : bool
text ITextProvider Text provider
name ITextRange Element name
containerElementNames string
return bool
Esempio n. 1
0
        /// <summary>
        /// Detemines of element can be implicitly closed (i.e. element does not require closing tag) like &lt;td&gt;
        /// Only applies to regular HTML elements. Does not apply to elements with prefixes or namespaces.
        /// </summary>
        /// <param name="textProvider">Text provider</param>
        /// <param name="nameRange">Range of the element name</param>
        /// <returns>True if element can be implicitly closed</returns>
        public bool IsImplicitlyClosed(ITextProvider textProvider, ITextRange nameRange, out string[] containerNames)
        {
            Debug.Assert(nameRange.Length > 0);

            // Only HTML elements can be implicitly closed
            return(_defaultProvider.IsImplicitlyClosed(textProvider, nameRange, out containerNames));
        }
        public void IsImplicitlyClosedTest() {
            string[] implicitlyClosingElements = new string[]{
               "frame",
                "dd",
                "dt",
                "li",
                "Option",
                "p",
                "tbOdy",
                "tfoot",
                "TD",
                "th",
                "thead",
                "tr",
            };

            string[] notImplicitlyClosingElements = new string[]{
               "html",
                "123",
                " ",
                "!",
                "абвгд",
             };


            var target = new DefaultHtmlClosureProvider();
            bool actual;

            foreach (string s in implicitlyClosingElements) {
                string[] containerNames;

                actual = target.IsImplicitlyClosed(new TextStream(s), TextRange.FromBounds(0, s.Length), out containerNames);
                Assert.True(actual);
            }

            foreach (string s in notImplicitlyClosingElements) {
                string[] containerNames;

                actual = target.IsImplicitlyClosed(new TextStream(s), TextRange.FromBounds(0, s.Length), out containerNames);
                Assert.False(actual);
            }
        }