public function post_process($css) {
        // now resolve all image locations
        if (preg_match_all('/\[\[pix:([a-z0-9_]+\|)?([^\]]+)\]\]/', $css, $matches, PREG_SET_ORDER)) {
            $replaced = array();
            foreach ($matches as $match) {
                if (isset($replaced[$match[0]])) {
                    continue;
                }
                $replaced[$match[0]] = true;
                $imagename = $match[2];
                $component = rtrim($match[1], '|');
                $imageurl = $this->image_url($imagename, $component)->out(false);
                 // we do not need full url because the image.php is always in the same dir
                $imageurl = preg_replace('|^http.?://[^/]+|', '', $imageurl);
                $css = str_replace($match[0], $imageurl, $css);
            }
        }

        // Now resolve all font locations.
        if (preg_match_all('/\[\[font:([a-z0-9_]+\|)?([^\]]+)\]\]/', $css, $matches, PREG_SET_ORDER)) {
            $replaced = array();
            foreach ($matches as $match) {
                if (isset($replaced[$match[0]])) {
                    continue;
                }
                $replaced[$match[0]] = true;
                $fontname = $match[2];
                $component = rtrim($match[1], '|');
                $fonturl = $this->font_url($fontname, $component)->out(false);
                // We do not need full url because the font.php is always in the same dir.
                $fonturl = preg_replace('|^http.?://[^/]+|', '', $fonturl);
                $css = str_replace($match[0], $fonturl, $css);
            }
        }

        // Now resolve all theme settings or do any other postprocessing.
        // This needs to be done before calling core parser, since the parser strips [[settings]] tags.
        $csspostprocess = $this->csspostprocess;
        if (function_exists($csspostprocess)) {
            $css = $csspostprocess($css, $this);
        }

        // Post processing using an object representation of CSS.
        $treeprocessor = $this->get_css_tree_post_processor();
        $needsparsing = !empty($treeprocessor) || !empty($this->rtlmode);
        if ($needsparsing) {

            // We might need more memory/time to do this, so let's play safe.
            raise_memory_limit(MEMORY_EXTRA);
            core_php_time_limit::raise(300);

            $parser = new core_cssparser($css);
            $csstree = $parser->parse();
            unset($parser);

            if ($this->rtlmode) {
                $this->rtlize($csstree);
            }

            if ($treeprocessor) {
                $treeprocessor($csstree, $this);
            }

            $css = $csstree->render();
            unset($csstree);
        }

        return $css;
    }