Example #1
0
 public function format_programlisting($open, $name, $attrs)
 {
     if ($open) {
         if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) {
             $this->role = $attrs[Reader::XMLNS_DOCBOOK]["role"];
         } else {
             $this->role = false;
         }
         $ret = '<div class="example-contents">';
         if (isset($attrs[Reader::XMLNS_DOCBOOK]["location"])) {
             $full_loc = Config::sample_code_root() . $attrs[Reader::XMLNS_DOCBOOK]["location"];
             if (file_exists($full_loc)) {
                 $code = file_get_contents($full_loc);
                 // Extra newline to CDATA because this would normally follow
                 // a CDATA tag and line numbers expect it.
                 $ret .= "\n" . $this->CDATA("\n" . $code);
             }
         }
         return $ret;
     }
     $this->role = false;
     return "</div>\n";
 }