.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "CSS::DOM::PropertyParser 3pm" .TH CSS::DOM::PropertyParser 3pm "2018-02-12" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CSS::DOM::PropertyParser \- Parser for CSS property values .SH "VERSION" .IX Header "VERSION" Version 0.17 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use CSS::DOM::PropertyParser; \& \& $spec = new CSS::DOM::PropertyParser; # empty \& # OR \& $spec = $CSS::DOM::PropertyParser::Default\->clone; \& \& $spec\->add_property( \& overflow => { \& format => \*(Aqvisible|hidden|scroll|auto\*(Aq, \& default => \*(Aqvisible\*(Aq, \& inherit => 0, \& } \& ); \& \& $hashref = $spec\->get_property(\*(Aqoverflow\*(Aq); \& \& $hashref = $spec\->delete_property(\*(Aqoverflow\*(Aq); \& \& @names = $spec\->property_names; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Objects of this class provide lists of supported properties for \s-1CSS::DOM\s0 style sheets. They also describe the syntax and parsing of those properties' values. .PP Some \s-1CSS\s0 properties simply have their own values (e.g., overflow); some are abbreviated forms of several other properties (e.g., font). These are referred to in this documentation as 'simple' and 'shorthand' properties. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" \&\f(CW\*(C`$spec = new CSS::DOM::PropertyParser\*(C'\fR returns an object that does not recognise any properties, to which you can add your own properties. .PP There are two parser objects that come with this module. These are \&\f(CW$CSS::DOM::PropertyParser::CSS21\fR, which contains all of \s-1CSS 2.1,\s0 and \&\f(CW$CSS::DOM::PropertyParser::Default\fR, which is currently identical to the former, but to which parts of \s-1CSS 3\s0 which eventually be added. .PP If one of the default specs will do, you don't need a constructor. Simply pass it to the \s-1CSS::DOM\s0 constructor. If you want to modify it, clone it first, using the \f(CW\*(C`clone\*(C'\fR method (as shown in the \*(L"\s-1SYNOPSIS\*(R"\s0). It is often convenient to clone the \f(CW$Default\fR spec and delete those properties that are not supported. .SH "METHODS" .IX Header "METHODS" .IP "clone" 4 .IX Item "clone" Returns a deep clone of the object. (It's deep so that you can modify the hashes/arrays inside it without modifying the original.) .ie n .IP "add_property ( $name, \e%spec )" 4 .el .IP "add_property ( \f(CW$name\fR, \e%spec )" 4 .IX Item "add_property ( $name, %spec )" Adds the specification for the named property. See \&\*(L"\s-1HOW INDIVIDUAL PROPERTIES ARE SPECIFIED\*(R"\s0, below. .ie n .IP "get_property ( $name )" 4 .el .IP "get_property ( \f(CW$name\fR )" 4 .IX Item "get_property ( $name )" Returns the hashref passed to the previous method. .ie n .IP "delete_property ( $name )" 4 .el .IP "delete_property ( \f(CW$name\fR )" 4 .IX Item "delete_property ( $name )" Deletes the property and returns the hash ref. .IP "property_names" 4 .IX Item "property_names" Returns a list of the names of supported properties. .ie n .IP "subproperty_names ( $name )" 4 .el .IP "subproperty_names ( \f(CW$name\fR )" 4 .IX Item "subproperty_names ( $name )" Returns a list of the names of \f(CW$name\fR's sub-properties if it is a shorthand property. .IP "match" 4 .IX Item "match" Currently for internal use only. See the source code for documentation. Use at your own risk. .SH "HOW INDIVIDUAL PROPERTIES ARE SPECIFIED" .IX Header "HOW INDIVIDUAL PROPERTIES ARE SPECIFIED" Before you read this the first time, look at the \*(L"Example\*(R" below, and then come back and use this for reference. .PP The specification for an individual property is a hash ref. There are several keys that each hash ref can have: .IP "format" 4 .IX Item "format" This is set to a string that describes the format of the property. The syntax used is based on the \s-1CSS 2.1\s0 spec, but is not exactly the same. Unlike regular expressions, these formats are applied to properties on a token-by-token basis, not one character at a time. (This means that \&\f(CW\*(C`100|200\*(C'\fR cannot be written as \f(CW\*(C`[1|2]00\*(C'\fR, as that would mean \&\f(CW\*(C`1 00 | 2 00\*(C'\fR.) .Sp Whitespace is ignored in the format and in the \s-1CSS\s0 property except as a token separator. .Sp There are several metachars (in order of precedence): .Sp .Vb 9 \& [...] grouping (like (?:...) ) \& (...) capturing group (just like a regexp) \& ? optional \& * zero or more \& + one or more \& || alternates that can come in any order and are optional, \& but at least one must be specified (the order will be \& retained if possible) \& | alternates, exactly one of which is required .Ve .Sp In addition, the following datatypes can be specified in angle brackets: .Sp .Vb 10 \& A number with a \*(Aqdeg\*(Aq, \*(Aqrad\*(Aq or \*(Aqgrad\*(Aq suffix \& attr(...) \& (You can omit the \*(Aqu\*(Aq if you want to.) One of CSS\*(Aqs \& predefined colour or system colour names, or a # \& followed by 3 or 6 hex digits, or the \*(Aqrgb(...)\*(Aq \& format (rgba is supported, too) \& counter(...) \& A unit of Hz or kHz \& An identifier token \& An integer (really?!) \& Number followed by a length unit (em, ex, px, in, cm, \& mm, pt, pc) \& A number token \& Number followed by % \& rect(...) \& A string token \& A sequence of identifiers or a single string (e.g., a \& font name) \&