Package Torello.CSS

Class CSSUtil

    • Constructor Summary

      Constructors 
      Constructor Description
      CSSUtil()  
    • Method Detail

      • consumeEscapedUnicode

        🡅  🡇     🗕  🗗  🗖
        protected static int consumeEscapedUnicode​
                    (int[] css,
                     int sPos,
                     java.util.stream.IntStream.Builder b)
        
        This is a tokenizer method which "consumes" an escaped Unicode Code-Point.

        Tokenizer: Escaped-Unicode Consume Method, Pseudo-Code

        Making use of the CSS Parser DOES NOT require any knowledge of how the underlying Pass 1 Tokenizer actually works. Below is the CSS Working Group's Escaped-Unicode Rail-Road Diagram. It is here for informational purposes.
        These Parsing Pseudo-Code Instructions and Rail-Road Diagrams have been copied from the CSS-Working-Group Web-Site:
        https://drafts.csswg.org/css-syntax/#consume-escaped-code-point

        Consume an escaped code point

        This section describes how to consume an escaped code point. It assumes that the U+005C REVERSE SOLIDUS (\) has already been consumed and that the next input code point has already been verified to be part of a valid escape. It will return a code point.

        Consume the next input code point.

        hex digit
        Consume as many hex digits as possible, but no more than 5. Note that this means 1-6 hex digits have been consumed in total. If the next input code point is whitespace, consume it as well. Interpret the hex digits as a hexadecimal number. If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point, return U+FFFD REPLACEMENT CHARACTER (�). Otherwise, return the code point with that value.
        EOF
        This is a parse error. Return U+FFFD REPLACEMENT CHARACTER (�).
        anything else
        Return the current input code point.
        escape
        \ not newline or hex digit hex digit 1-6 times whitespace
      • isValidEscape

        🡅     🗕  🗗  🗖
        public static boolean isValidEscape​(int codePoint1,
                                            int codePoint2)
        Checks whether or not the next token to consume constitutes a valid Escape-Sequence

        Tokenizer: Unicode-Range Check Method, Pseudo-Code

        Making use of the CSS Parser DOES NOT require any knowledge of how the underlying Pass 1 Tokenizer actually works. Browser-War people are usually pretty convincing that parsing CSS is a "Moving Target" type of operation, not to be engaged by mere mortals.

        Below is the CSS Working Group's Unicode-Range Pseudo-Code. You may review it if you are at wit's end, and have nothing better to do. There is no need to actually invoke this method, it is here solely for informational purposes.

        These Parsing Pseudo-Code Instructions and Rail-Road Diagrams have been copied from the CSS-Working-Group Web-Site:
        https://drafts.csswg.org/css-syntax/#check-if-two-code-points-are-a-valid-escape

        Check if two code points are a valid escape

        This section describes how to check if two code points are a valid escape. The algorithm described here can be called explicitly with two code points, or can be called with the input stream itself. In the latter case, the two code points in question are the current input code point and the next input code point, in that order.

        Note: This algorithm will not consume any additional code point.

        If the first code point is not U+005C REVERSE SOLIDUS (\), return false.

        Otherwise, if the second code point is a newline, return false.

        Otherwise, return true.