Enum HtmlTextEscapingMode

  • All Implemented Interfaces:
    Serializable, Comparable<HtmlTextEscapingMode>

    public enum HtmlTextEscapingMode
    extends Enum<HtmlTextEscapingMode>
    From section 8.1.2.6 of http://www.whatwg.org/specs/web-apps/current-work/

    The text in CDATA and RCDATA elements must not contain any occurrences of the string "</" (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of the element followed by one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or U+002F SOLIDUS (/), unless that string is part of an escaping text span.

    See also http://www.whatwg.org/specs/web-apps/current-work/#cdata-rcdata-restrictions for the elements which fall in each category.

    Author:
    Mike Samuel ([email protected])
    • Enum Constant Detail

      • PCDATA

        public static final HtmlTextEscapingMode PCDATA
        Normally escaped character data that breaks around comments and tags.
      • CDATA

        public static final HtmlTextEscapingMode CDATA
        A span of text where HTML special characters are interpreted literally, as in a SCRIPT tag.
      • RCDATA

        public static final HtmlTextEscapingMode RCDATA
        A span of text and character entity references where HTML special characters are interpreted literally, as in a TITLE tag.
      • PLAIN_TEXT

        public static final HtmlTextEscapingMode PLAIN_TEXT
        A span of text where HTML special characters are interpreted literally, where there is no end tag. PLAIN_TEXT runs until the end of the file.
    • Method Detail

      • values

        public static HtmlTextEscapingMode[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (HtmlTextEscapingMode c : HtmlTextEscapingMode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static HtmlTextEscapingMode valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getModeForTag

        public static HtmlTextEscapingMode getModeForTag​(String canonTagName)
        The mode used for content following a start tag with the given name.
      • isTagFollowedByLiteralContent

        public static boolean isTagFollowedByLiteralContent​(String canonTagName)
        True if content immediately following the start tag must be treated as special CDATA so that <'s are not treated as starting tags, comments or directives.
      • isVoidElement

        public static boolean isVoidElement​(String canonTagName)
        True iff the tag cannot contain any content -- will an HTML parser consider the element to have ended immediately after the start tag.