diff --git a/lib/Sabberworm/CSS/Parser.php b/lib/Sabberworm/CSS/Parser.php index e32eb808..211709a5 100644 --- a/lib/Sabberworm/CSS/Parser.php +++ b/lib/Sabberworm/CSS/Parser.php @@ -2,6 +2,8 @@ namespace Sabberworm\CSS; +use Sabberworm\CSS\Property\CssNamespace; + use Sabberworm\CSS\CSSList\CSSList; use Sabberworm\CSS\CSSList\Document; use Sabberworm\CSS\CSSList\MediaQuery; @@ -110,6 +112,20 @@ private function parseAtRule() { $this->consume(';'); $this->setCharset($sCharset->getString()); return new Charset($sCharset); + } else if ($sIdentifier === 'namespace') { + $this->consumeWhiteSpace(); + + if ($this->comes('"')) { + $prefix = ""; + $namespace = $this->parseStringValue()->getString(); + + }else{ + $prefix = $this->parseIdentifier(false); + $this->consumeWhiteSpace(); + $namespace = $this->parseStringValue()->getString(); + } + $this->consume(';'); + return new CssNamespace($namespace, $prefix); } else { //Unknown other at rule (font-face or such) $this->consume('{'); diff --git a/lib/Sabberworm/CSS/Property/CssNamespace.php b/lib/Sabberworm/CSS/Property/CssNamespace.php new file mode 100644 index 00000000..fabac2f3 --- /dev/null +++ b/lib/Sabberworm/CSS/Property/CssNamespace.php @@ -0,0 +1,37 @@ +sValue = $sValue; + $this->sPrefix = $sPrefix; + } + + public function __toString() { + return '@namespace '.$this->sPrefix.' "'.$this->sValue.'";'; + } + + public function getValue() { + return $this->sValue; + } + + public function getPrefix() { + return $this->sPrefix; + } + + public function setValue($sValue) { + $this->sValue = $sValue; + } + + public function setPrefix($sPrefix) { + $this->sPrefix = $sPrefix; + } + +} \ No newline at end of file