Changeset 1618 for trunk/buildscripts
- Timestamp:
- 01/13/2007 08:10:24 PM (23 months ago)
- Location:
- trunk/buildscripts
- Files:
-
- 2 added
- 2 modified
-
chmbuilder/assets (added)
-
chmbuilder/index.php (added)
-
texbuilder/Page2Tex.php (modified) (3 diffs)
-
texbuilder/quickstart/build.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/buildscripts/texbuilder/Page2Tex.php
r1598 r1618 5 5 private $_current_page; 6 6 private static $header_count = 0; 7 private static $p_count=0; 8 private static $hil_count=0; 9 private $page_count=0; 7 10 private $_base; 8 11 private $_dir; … … 271 274 272 275 273 function set_header_id($content) 274 { 276 function set_header_id($content, $j) 277 { 278 $this->page_count=$j; 275 279 $content = preg_replace_callback('/<h1>/', array($this,"h1"), $content); 276 280 $content = preg_replace_callback('/<h2>/', array($this,"h2"), $content); 277 281 $content = preg_replace_callback('/<h3>/', array($this,"h3"), $content); 282 $content = $this->set_block_content_id($content); 278 283 return $content; 279 284 } … … 281 286 function h1($matches) 282 287 { 283 return "<h1 id=\"".(++self::$header_count)."\">"; 288 $page = $this->page_count*1000; 289 return "<h1 id=\"".($page + (++self::$header_count))."\">"; 284 290 } 285 291 286 292 function h2($matches) 287 293 { 288 return "<h2 id=\"".(++self::$header_count)."\">"; 294 $page = $this->page_count*1000; 295 return "<h2 id=\"".($page + (++self::$header_count))."\">"; 289 296 } 290 297 291 298 function h3($matches) 292 299 { 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 } 296 336 } 297 337 -
trunk/buildscripts/texbuilder/quickstart/build.php
r1411 r1618 37 37 $parser->setCurrentPage($current_path); 38 38 39 //add id to <h1>, <h2>, < 3>39 //add id to <h1>, <h2>, <h3> and <p> 40 40 $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); 42 42 43 43 $content .= $parser->get_section_label($section);
