NAME
SVG::Rasterize::Regexes
- Commonly used regular expressions
VERSION
Version 0.002002
DESCRIPTION
This package offers a set of regular expressions for export. Many of them are precompiled into downstream expressions, therefore changing them would probably not have the desired outcome. Therefore they are also not documented in full detail, see the code for the details.
A
versus P
Floating point number expressions are divided into A
(for attribute) and P
(for property) versions, e.g. $RE_NUMBER{A_FLOAT}
and $RE_NUMBER{P_FLOAT}
. The reason for that is that apparently, the CSS
specification prohibits floating point numbers in scientific notation (e.g. 3e-7
). However, the XML
standard allows such numbers in attribute values. Currently, however, SVG::Rasterize
does not make use of this distinction and always uses the A
version. Therefore, it will not complain if you provide a number in scientific notation within a style
attribute although strictly, this is forbidden by the specification. This may or may not change in the future.
p
and w
The regular expressions from this package might be used to build more complex expressions, but are also used to validate values which should match the expression fully (not a substring). Therefore, some expressions have p
(for pure) and w
(for white space) versions. If $RE
is an expression then $p_RE
will be qr/^$RE$/
, and $w_RE
will be qr/^$WSP*$RE$WSP*$/
.
LIST OF EXPRESSIONS
Two expressions are exported directly as scalars, the other ones are organized in a set of hashes:
$WSP = qr/[\x{20}\x{9}\x{D}\x{A}]/
This is one white space character as defined by the
SVG
specification (inherited fromXML
I suppose). The character class consists ofSPACE
,TAB
,CR
, andLF
.$CWSP = qr/(?:$WSP+\,?$WSP*|\,$WSP*)/
White space or comma, possibly surrounded by white space.
%RE_PACKAGE
Currently, this hash contains only one entry:
$RE_PACKAGE{p_PACKAGE_NAME} = qr/^$package_part(?:\:\:$package_part)*$/;
where
$package_part
is a lexical variable with the valueqr/[a-zA-Z][a-zA-Z0-9\_]*/
.Package names given to some methods in this distribution have to match this regular expression. I am not sure which package names exactly are allowed. If you know where in the Perl manpages or the Camel book this is described, please point me to it. If this pattern is too strict for your favourite package name, you can change this variable.
%RE_NUMBER
Contains expressions for integer and floating point numbers. The reasons for building own regular expressions are that the format is specified in terms of a Backus Naur form in the
SVG
specification, e.g. here: http://www.w3.org/TR/SVG11/coords.html#TransformAttribute. Note that these expressions allow leading zeroes like '00030' or '000.123'.%RE_LENGTH
Lengths in
SVG
consist of a number and optionally a length unit. See Units inSVG::Rasterize
.%RE_COLOR
Currently only contains
$RE_COLOR{p_RGB}
representing anSVG
color specification as something likergb(0, 255, 31)
. It will probably be expanded whenSVG::Rasterize
supports color profiles and such.%RE_TRANSFORM
Regular expressions required to parse values of the
transform
attribute. These expressions are constructed according to the Backus Naur form at http://www.w3.org/TR/SVG11/coords.html#TransformAttribute.%RE_VIEW_BOX
Regular expressions required to parse values of the
viewBox
andpreserveAspectRatio
attributes.%RE_PATH
Regular expressions required to parse path data strings. These expressions are constructed according to the Backus Naur form at http://www.w3.org/TR/SVG11/paths.html#PathDataBNF.
%RE_DASHARRAY
Regular expressions required to parse values of the
stroke-dasharray
property.%RE_POLY
Regular expressions required to parse values of the
points
attribute ofpolyline
andpolygon
elements. These expressions are constructed according to the Backus Naur form at http://www.w3.org/TR/SVG11/shapes.html#PointsBNF.
EXPORT_TAGS
The following export tags can be used like
use SVG::Rasterize::Regexes qw(:whitespace);
:all
:whitespace
$WSP
and$CWSP
.:attributes
%RE_NUMBER
,%RE_LENGTH
,%RE_COLOR
,%RE_TRANSFORM
,%RE_VIEW_BOX
,%RE_PATH
,%RE_DASHARRAY
,%RE_POLY
.
SEE ALSO
AUTHOR
Lutz Gehlen, <perl at lutzgehlen.de>
LICENSE AND COPYRIGHT
Copyright 2010 Lutz Gehlen.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.