Changeset 1411 for trunk/buildscripts
- Timestamp:
- 09/13/2006 06:33:41 PM (2 years ago)
- Location:
- trunk/buildscripts/texbuilder
- Files:
-
- 4 modified
-
Page2Tex.php (modified) (18 diffs)
-
quickstart/build.php (modified) (3 diffs)
-
quickstart/pages.php (modified) (3 diffs)
-
quickstart/quickstart.tex (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/buildscripts/texbuilder/Page2Tex.php
r1265 r1411 1 1 <?php 2 2 3 class Page2Tex 3 class Page2Tex 4 4 { 5 5 private $_current_page; … … 17 17 $this->_dir = $dir; 18 18 } 19 19 20 20 function setCurrentPage($current) 21 21 { … … 25 25 function escape_verbatim($matches) 26 26 { 27 return "\begin{verbatim}".str_replace($this->_verb_find, $this->_verb_replace, $matches[1])."\end{verbatim}\n"; 28 } 29 27 return "\begin{small}\begin{verbatim}". 28 str_replace($this->_verb_find, $this->_verb_replace, $matches[1]). 29 "\end{verbatim}\end{small}\n"; 30 } 31 30 32 function escape_verb($matches) 31 33 { 32 34 $text = str_replace($this->_verb_find, $this->_verb_replace, $matches[1]); 33 return '\ verb<'.$text.'<';34 } 35 35 return '\begin{small}\verb<'.$text.'< \end{small}'; 36 } 37 36 38 function include_image($matches) 37 39 { 38 40 39 41 $current_path = $this->_current_page; 40 42 41 43 $image = dirname($current_path).'/'.trim($matches[1]); 42 44 43 45 $file = realpath($image); 44 46 $info = getimagesize($file); … … 52 54 } 53 55 $base = $this->_base; 54 56 55 57 if(isset($im)) 56 58 { … … 65 67 } 66 68 } 67 69 68 70 function include_figure($info, $filename) 69 71 { … … 77 79 '; 78 80 } 79 81 80 82 function anchor($matches) 81 83 { … … 83 85 return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}'; 84 86 } 85 87 86 88 function texttt($matches) 87 89 { 88 90 return '\texttt{'.str_replace(array('#','_'),array('\#','\_'), $matches[1]).'}'; 89 91 } 90 92 91 93 function get_current_path() 92 94 { … … 96 98 return $page; 97 99 } 98 100 99 101 function make_link($matches) 100 102 { … … 121 123 return '\href{'.$matches[1].'}{'.$matches[2].'}'; 122 124 } 123 125 124 126 function parse_html($page,$html) 125 127 { 126 127 128 128 $html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html); 129 129 $html = preg_replace('/<\/?p [^>]*>/', '', $html); 130 130 $html = preg_replace('/<\/?p>/', '', $html); 131 131 132 132 $html = preg_replace('/(\s+|\(+|\[+)"/', '$1``', $html); 133 133 134 134 //escape { and } 135 135 $html = preg_replace('/([^\s]+){([^}]*)}([^\s]+)/', '$1\\\{$2\\\}$3', $html); 136 136 137 137 $html = preg_replace_callback('/<img\s+src="?<%~([^"]*)%>"?[^>]*\/>/', array($this, 'include_image'), $html); 138 138 139 139 //escape % 140 140 $html = str_replace('%', '\%', $html); 141 141 142 142 //codes 143 143 $html = str_replace('$', '\$', $html); 144 144 145 145 $html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter>/', array($this,'escape_verbatim'), $html); 146 146 // $html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html); … … 148 148 $html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this,'escape_verbatim'), $html); 149 149 $html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html); 150 150 151 151 //<code> 152 152 $html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this,'escape_verb'), $html); 153 153 154 154 //runbar 155 155 $html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/', 156 156 '\href{http://www.pradosoft.com/demos/quickstart/index.php?page=$1}{$1 Demo}', $html); 157 157 158 158 //DocLink 159 159 $html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/', 160 160 '\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html); 161 161 162 162 //text modifiers 163 $html = preg_replace('/< b[^>]*>([^<]*)<\/b>/', '\textbf{$1}', $html);163 $html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html); 164 164 $html = preg_replace('/<i[^>]*>([^<]*)<\/i>/', '\emph{$1}', $html); 165 165 $html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html); 166 166 167 167 //links 168 168 $html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/', … … 170 170 //anchor 171 171 $html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html); 172 172 173 173 //description <dl> 174 174 $html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html); … … 176 176 $html = preg_replace('/<dl>/', '\begin{description}', $html); 177 177 $html = preg_replace('/<\/dl>/', '\end{description}', $html); 178 178 179 179 //item lists 180 180 $html = preg_replace('/<ul[^>]*>/', '\begin{itemize}', $html); … … 184 184 $html = preg_replace('/<li[^>]*>/', '\item ', $html); 185 185 $html = preg_replace('/<\/li>/', '', $html); 186 186 187 187 //headings 188 188 $html = preg_replace('/<h1(\s+id="[^"]+")?>([^<]+)<\/h1>/', '\section{$2}', $html); 189 189 $html = preg_replace('/<h2(\s+id="[^"]+")?>([^<]+)<\/h2>/', '\subsection{$2}', $html); 190 190 $html = preg_replace('/<h3(\s+id="[^"]+")?>([^<]+)<\/h3>/', '\subsubsection{$2}', $html); 191 191 192 192 //div box 193 193 $html = preg_replace_callback('/<div class="[tipnofe]*?">((.|\n)*?)<\/div>/', 194 array($this, 'mbox'), $html); 195 194 array($this, 'mbox'), $html); 195 196 196 //tabular 197 197 $html = preg_replace_callback('/<!--\s*tabular:([^-]*)-->\s*<table[^>]*>((.|\n)*?)<\/table>/', 198 198 array($this, 'tabular'), $html); 199 199 200 $html = preg_replace('/<!--(.*)-->/', '', $html); 201 202 200 203 $html = html_entity_decode($html); 201 204 202 205 return $html; 203 206 } 204 207 205 208 function tabular($matches) 206 209 { … … 211 214 $options[trim($sub[0])] = trim($sub[1]); 212 215 } 213 216 214 217 $widths = explode(' ',preg_replace('/\(|\)/', '', $options['width'])); 215 218 $this->_tabular_widths = $widths; 216 219 217 220 $this->_tabular_total = count($widths); 218 221 $this->_tabular_col = 0; 219 222 220 223 $begin = "\begin{table}[!hpt]\centering \n \begin{tabular}{".$options['align']."}\\hline"; 221 224 $end = "\end{tabular} \n \end{table}\n"; … … 225 228 $table = preg_replace_callback('/<td>((.|\n)*?)<\/td>/', array($this, 'table_column'), $table); 226 229 $table = preg_replace('/<br \/>/', ' \\\\\\\\', $table); 227 230 228 231 $table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table); 229 232 return $begin.$table.$end; 230 233 } 231 234 232 235 function table_column($matches) 233 236 { … … 240 243 $matches[1].'\vspace{3mm}\end{minipage} & '; 241 244 } 242 245 243 246 function mbox($matches) 244 247 { 245 248 return "\n\begin{mybox}\n".$matches[1]."\n\end{mybox}\n"; 246 249 } 247 250 248 251 function get_chapter_label($chapter) 249 252 { 250 253 return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}'; 251 254 } 252 255 253 256 function get_section_label($section) 254 257 { … … 256 259 return '\hypertarget{'.str_replace('/', '.', $section).'}{}'; 257 260 } 258 259 261 262 260 263 function set_header_id($content, $count) 261 264 { … … 266 269 return $content; 267 270 } 268 271 269 272 function h1($matches) 270 273 { 271 274 return "<h1 id=\"".(++self::$header_count)."\">"; 272 275 } 273 276 274 277 function h2($matches) 275 278 { 276 279 return "<h2 id=\"".(++self::$header_count)."\">"; 277 280 } 278 281 279 282 function h3($matches) 280 283 { 281 284 return "<h3 id=\"".(++self::$header_count)."\">"; 282 285 } 283 286 284 287 } 285 288 -
trunk/buildscripts/texbuilder/quickstart/build.php
r1266 r1411 11 11 $base = realpath(dirname(__FILE__).'/../../../demos/quickstart/protected/pages/'); 12 12 13 $pages = include('pages.php'); 14 13 15 //-------------- END CONFIG ------------------ 14 16 15 $pages = include('pages.php'); 16 17 function escape_verbatim($matches) 18 { 19 return "\begin{verbatim}".str_replace('\$', '$', $matches[2])."\end{verbatim}\n"; 20 } 21 22 function escape_verb($matches) 23 { 24 $text = str_replace(array('\{', '\}'), array('{','}'), $matches[1]); 25 return '\verb<'.$text.'<'; 26 } 27 28 function include_image($matches) 29 { 30 global $current_path; 31 32 $image = dirname($current_path).'/'.trim($matches[1]); 33 34 $file = realpath($image); 35 $info = getimagesize($file); 36 switch($info[2]) 37 { 38 case 1: 39 $im = imagecreatefromgif($file); 40 break; 41 case 2: $im = imagecreatefromjpeg($file); break; 42 case 3: $im = imagecreatefrompng($file); break; 43 } 44 global $base; 45 46 if(isset($im)) 47 { 48 $prefix = strtolower(str_replace(realpath($base), '', $file)); 49 $filename = preg_replace('/\\\|\//', '_', substr($prefix,1)); 50 $filename = substr($filename, 0, strrpos($filename,'.')).'.png'; 51 $newfile = dirname(__FILE__).'/'.$filename; 52 imagepng($im,$newfile); 53 imagedestroy($im); 54 55 return include_figure($info, $filename); 56 } 57 } 58 59 function include_figure($info, $filename) 60 { 61 $width = sprintf('%0.2f', $info[0]/(135/2.54)); 62 return ' 63 \begin{figure}[ht] 64 \centering 65 \includegraphics[width='.$width.'cm]{'.$filename.'} 66 \label{fig:'.$filename.'} 67 \end{figure} 68 '; 69 } 70 71 function anchor($matches) 72 { 73 $page = get_current_path(); 74 return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}'; 75 } 76 77 function texttt($matches) 78 { 79 return '\texttt{'.str_replace(array('#','_'),array('\#','\_'), $matches[1]).'}'; 80 } 81 82 function get_current_path() 83 { 84 global $current_path, $base; 85 $page = strtolower(substr(str_replace($base, '', $current_path),1)); 86 return $page; 87 } 88 89 function make_link($matches) 90 { 91 if(is_int(strpos($matches[1], '#'))) 92 { 93 if(strpos($matches[1],'?') ===false) 94 { 95 $target = get_current_path().'/'.substr($matches[1],1); 96 return '\hyperlink{'.$target.'}{'.$matches[2].'}'; 97 } 98 else 99 { 100 $page = strtolower(str_replace('?page=', '', $matches[1])); 101 $page = str_replace('.','/',$page); 102 $page = str_replace('#','.page/',$page); 103 return '\hyperlink{'.$page.'}{'.$matches[2].'}'; 104 } 105 } 106 else if(is_int(strpos($matches[1],'?'))) 107 { 108 $page = str_replace('?page=','',$matches[1]); 109 return '\hyperlink{'.$page.'}{'.$matches[2].'}'; 110 } 111 return '\href{'.$matches[1].'}{'.$matches[2].'}'; 112 } 113 114 function parse_html($page,$html) 115 { 116 $html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html); 117 $html = preg_replace('/<\/?p>/m', '', $html); 118 119 //escape { and } 120 $html = preg_replace('/([^\s]+){([^}]*)}([^\s]+)/', '$1\\\{$2\\\}$3', $html); 121 122 //codes 123 $html = str_replace('$', '\$', $html); 124 $html = preg_replace('/<com:TTextHighlighter[^>]*>/', '`1`', $html); 125 $html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html); 126 $html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', 'escape_verbatim', $html); 127 $html = preg_replace_callback('/(<div class="source">)([^<]*)(<\/div>)/', 'escape_verbatim', $html); 128 $html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', 'escape_verbatim', $html); 129 130 //<code> 131 $html = preg_replace_callback('/<code>([^<]*)<\/code>/', 'escape_verb', $html); 132 133 $html = preg_replace_callback('/<img\s+src="?<%~([^"]*)%>"?[^\\/]*\/>/', 'include_image', $html); 134 135 //runbar 136 $html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/', 137 '\href{http://www.pradosoft.com/demos/quickstart/index.php?page=$1}{$1 Demo}', $html); 138 139 //DocLink 140 $html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/', 141 '\href{http://www.pradosoft.com/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html); 142 143 //text modifiers 144 $html = preg_replace('/<b>([^<]*)<\/b>/', '\textbf{$1}', $html); 145 $html = preg_replace('/<i>([^<]*)<\/i>/', '\emph{$1}', $html); 146 $html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', 'texttt', $html); 147 148 //links 149 $html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/', 150 'make_link', $html); 151 //anchor 152 $html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', 'anchor', $html); 153 154 //description <dl> 155 $html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html); 156 $html = preg_replace('/<\/?dd>/', '', $html); 157 $html = preg_replace('/<dl>/', '\begin{description}', $html); 158 $html = preg_replace('/<\/dl>/', '\end{description}', $html); 159 160 //item lists 161 $html = preg_replace('/<ul>/', '\begin{itemize}', $html); 162 $html = preg_replace('/<\/ul>/', '\end{itemize}', $html); 163 $html = preg_replace('/<ol>/', '\begin{enumerate}', $html); 164 $html = preg_replace('/<\/ol>/', '\end{enumerate}', $html); 165 $html = preg_replace('/<li>/', '\item ', $html); 166 $html = preg_replace('/<\/li>/', '', $html); 167 168 //headings 169 $html = preg_replace('/<h1\s+id="[^"]+">([^<]+)<\/h1>/', '\section{$1}', $html); 170 $html = preg_replace('/<h2\s+id="[^"]+">([^<]+)<\/h2>/', '\subsection{$1}', $html); 171 $html = preg_replace('/<h3\s+id="[^"]+">([^<]+)<\/h3>/', '\subsubsection{$1}', $html); 172 173 174 175 $html = html_entity_decode($html); 176 177 178 return $html; 179 } 180 181 function get_chapter_label($chapter) 182 { 183 return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}'; 184 } 185 186 function get_section_label($section) 187 { 188 $section = str_replace('.page', '', $section); 189 return '\hypertarget{'.str_replace('/', '.', $section).'}{}'; 190 } 191 192 193 function set_header_id($content, $count) 194 { 195 global $header_count; 196 $header_count = $count*100; 197 $content = preg_replace_callback('/<h1>/', "h1", $content); 198 $content = preg_replace_callback('/<h2>/', "h2", $content); 199 $content = preg_replace_callback('/<h3>/', "h3", $content); 200 return $content; 201 } 202 203 function h1($matches) 204 { 205 global $header_count; 206 return "<h1 id=\"".(++$header_count)."\">"; 207 } 208 209 function h2($matches) 210 { 211 global $header_count; 212 return "<h2 id=\"".(++$header_count)."\">"; 213 } 214 215 function h3($matches) 216 { 217 global $header_count; 218 return "<h3 id=\"".(++$header_count)."\">"; 219 } 220 221 $header_count = 0; 222 223 //--------------- BEGIN PROCESSING ------------------- 224 225 226 //--------------- Indexer ------------------- 227 228 //require_once('create_index.php'); 229 //$indexer = new quickstart_index($index_dir); 17 include(dirname(__FILE__).'.../../../texbuilder/Page2Tex.php'); 230 18 231 19 // ---------------- Create the Tex files --------- … … 235 23 echo "Compiling .page files to Latex files\n\n"; 236 24 25 $parser = new Page2Tex($base, dirname(__FILE__)); 26 237 27 foreach($pages as $chapter => $sections) 238 28 { 239 $content = '\chapter{'.$chapter.'}'. get_chapter_label($chapter);29 $content = '\chapter{'.$chapter.'}'.$parser->get_chapter_label($chapter); 240 30 echo "Creating ch{$count}.txt => Chapter {$count}: {$chapter}\n"; 241 31 echo str_repeat('-',60)."\n"; … … 245 35 $page = $base.'/'.$section; 246 36 $current_path = $page; 37 $parser->setCurrentPage($current_path); 247 38 248 39 //add id to <h1>, <h2>, <3> 249 $tmp_content = set_header_id(file_get_contents($page),$j++);250 file_put_contents($page, $tmp_content);40 $tmp_content = $parser->set_header_id(file_get_contents($page),$j++); 41 // file_put_contents($page, $tmp_content); 251 42 252 $content .= get_section_label($section);43 $content .= $parser->get_section_label($section); 253 44 $file_content = file_get_contents($page); 254 45 $tex = 255 $content .= parse_html($page,$file_content);46 $content .= $parser->parse_html($page,$file_content); 256 47 } 257 48 -
trunk/buildscripts/texbuilder/quickstart/pages.php
r1261 r1411 1 1 <?php 2 2 /* 3 * Created on 11/05/20063 * $Id$ 4 4 */ 5 5 … … 75 75 'Controls/Repeater.page'); 76 76 77 $pages['Control Reference : Active Controls (AJAX)'] = array( 78 'ActiveControls/ActiveButton.page', 79 'ActiveControls/ActiveCheckBox.page', 80 'ActiveControls/ActiveCustomValidator.page'); 81 82 $pages['Active Control Overview'] = array( 83 'ActiveControls/Home.page', 84 'ActiveControls/Introduction.page'); 85 77 86 $pages['Write New Controls'] = array( 78 87 'Controls/NewControl.page'); … … 97 106 'Advanced/Scripts3.page'); 98 107 99 100 108 return $pages; 101 109 //-------------- END CONFIG ---------------- -
trunk/buildscripts/texbuilder/quickstart/quickstart.tex
r1261 r1411 43 43 %----------------- TITLE -------------- 44 44 45 \title{\Huge \bfseries PRADO v3. 0.3Quickstart Tutorial45 \title{\Huge \bfseries PRADO v3.1 Quickstart Tutorial 46 46 \thanks{Copyright 2005-2006. All Rights Reserved.} 47 47 } … … 69 69 \addcontentsline{toc}{chapter}{License} 70 70 PRADO is free software released under the terms of the following BSD license.\\ 71 Copyright 2004-2006, The PRADO Group (http://www.pradosoft.com) \\71 Copyright 2004-2006, The PRADO Group (http://www.pradosoft.com) 72 72 All rights reserved. 73 73 … … 119 119 \include{ch12} 120 120 \include{ch13} 121 \include{ch14} 122 \include{ch15} 121 123 122 124 \end{document}
