Changeset 1618 for trunk/buildscripts

Show
Ignore:
Timestamp:
01/13/2007 08:10:24 PM (23 months ago)
Author:
wei
Message:

Add "block-content" to allow user comments on block level elements in quickstart docs.

Location:
trunk/buildscripts
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/buildscripts/texbuilder/Page2Tex.php

    r1598 r1618  
    55        private $_current_page; 
    66        private static $header_count = 0; 
     7        private static $p_count=0; 
     8        private static $hil_count=0; 
     9        private $page_count=0; 
    710        private $_base; 
    811        private $_dir; 
     
    271274 
    272275 
    273         function set_header_id($content) 
    274         { 
     276        function set_header_id($content, $j) 
     277        { 
     278                $this->page_count=$j; 
    275279                $content = preg_replace_callback('/<h1>/', array($this,"h1"), $content); 
    276280                $content = preg_replace_callback('/<h2>/', array($this,"h2"), $content); 
    277281                $content = preg_replace_callback('/<h3>/', array($this,"h3"), $content); 
     282                $content = $this->set_block_content_id($content); 
    278283                return $content; 
    279284        } 
     
    281286        function h1($matches) 
    282287        { 
    283                 return "<h1 id=\"".(++self::$header_count)."\">"; 
     288                $page = $this->page_count*1000; 
     289                return "<h1 id=\"".($page + (++self::$header_count))."\">"; 
    284290        } 
    285291 
    286292        function h2($matches) 
    287293        { 
    288                 return "<h2 id=\"".(++self::$header_count)."\">"; 
     294                $page = $this->page_count*1000; 
     295                return "<h2 id=\"".($page + (++self::$header_count))."\">"; 
    289296        } 
    290297 
    291298        function h3($matches) 
    292299        { 
    293                 return "<h3 id=\"".(++self::$header_count)."\">"; 
    294         } 
    295  
     300                $page = $this->page_count*1000; 
     301                return "<h3 id=\"".($page + (++self::$header_count))."\">"; 
     302        } 
     303         
     304        function set_block_content_id($content) 
     305        { 
     306                $content = preg_replace_callback('/<p>/',  array($this, 'add_p'), $content); 
     307                $content = preg_replace_callback('/<com:TTextHighlighter([^>]+)>/', array($this, 'hil'), $content); 
     308                return $content; 
     309        } 
     310 
     311        function hil($matches) 
     312        { 
     313                $id = ($this->page_count*10000) + (++self::$hil_count); 
     314                if(preg_match('/id="code-\d+"/i', $matches[1])) 
     315                { 
     316                        $code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]); 
     317                        //var_dump($code); 
     318                        return $code; 
     319                } 
     320                else if(preg_match('/id="[^"]+"/i', $matches[1])) 
     321                { 
     322                        return $matches[0]; 
     323                } 
     324                else 
     325                {        
     326                        $changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]); 
     327                        return $changes; 
     328                } 
     329        } 
     330 
     331        function add_p($matches) 
     332        { 
     333                 $page = $this->page_count*10000; 
     334                 return "<p id=\"".($page + (++self::$p_count))."\" class=\"block-content\">"; 
     335        } 
    296336} 
    297337 
  • trunk/buildscripts/texbuilder/quickstart/build.php

    r1411 r1618  
    3737                $parser->setCurrentPage($current_path); 
    3838 
    39                 //add id to <h1>, <h2>, <3> 
     39                //add id to <h1>, <h2>, <h3> and <p> 
    4040                $tmp_content = $parser->set_header_id(file_get_contents($page),$j++); 
    41 //              file_put_contents($page, $tmp_content); 
     41                file_put_contents($page, $tmp_content); 
    4242 
    4343                $content .= $parser->get_section_label($section);