A
download class.TeX.php
Language: PHP
LOC: 346
Project Info
FreeMED Project(freemed)
Server: SourceForge
Type: cvs
...reemed\freemed\freemed\lib\
   acl.php
   API.php
   bcadd.php
   calendar-functions.php
   class.AdminModule.php
   class.Agata.php
   class.Authorizations.php
   class.BaseModule.php
   class.BillingModule.php
   class.CalendarModule.php
   class.ClaimLog.php
   class.Coverage.php
   class.Debug.php
   class.diagnosis_set.php
   class.Djvu.php
   class.EMRModule.php
   class.Fax.php
   class.FixedFormEntry.php
   ...s.FixedFormRenderer.php
   class.FormRenderer.php
   class.FreeMEDSelfTest.php
   class.GeneralConfig.php
   class.GraphModule.php
   class.Guarantor.php
   class.Handler_HL7v2.php
   ...s.Handler_HL7v2_A04.php
   ...s.Handler_HL7v2_A08.php
   ...s.Handler_HL7v2_S12.php
   ...s.Handler_HL7v2_S15.php
   class.InsuranceCompany.php
   class.LanguageRegistry.php
   class.Ledger.php
   ...s.MaintenanceModule.php
   class.Messages.php
   class.OMBS_Patient.php
   class.OMBS_Wrapper.php
   class.Parser_HL7v2.php
   class.Patient.php
   class.Payer.php
   class.PHPlot.php
   class.Physician.php
   class.Procedure.php
   class.RecordLock.php
   class.Remitt.php
   class.ReportsModule.php
   class.rxlist.php
   class.Scheduler.php
   class.TeX.php
   class.User.php
   class.UtilityModule.php
   class.vCalendar.php
   class.vCalendarEvent.php
   error_handler.php
   freemed.php
   i18n.php
   iso-set.php
   macros.php
   mail-functions.php
   settings.php
   settings.php.tmpl
   xml.php
   xmlrpc_services.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
<?php
	// $Id: class.TeX.php,v 1.43 2005/08/16 12:09:03 rufustfirefly Exp $
	// $Author: rufustfirefly $

// Class: FreeMED.TeX
//
//	LaTeX rendering class.
//
class TeX {

	var $_buffer; // Internal buffer for creating TeX file
	var $options;

	function TeX ( $options = NULL ) {
		global $this_user;
		if (!is_object($this_user)) { $this_user = CreateObject('_FreeMED.User'); }

		// Pass options to internal array
		if (is_array($options)) {
			$this->options = $options;
		}
	} // end constructor

	// Method: PrintTeX
	//
	//	Prints a certain number of copies of the current TeX
	//	document.
	//
	// Parameters:
	//
	//	$copies - (optional) Number of copies of the current TeX
	//	document to print. Defaults to 1.
	//
	//	$rendered - (optional) Passed to <RenderToPDF>.
	//
	function PrintTeX ( $copies = 1, $rendered = false ) {
		$file = $this->RenderToPDF($rendered);

		// Render to postscript, since CUPS doesn't like PDF
		`( cd /tmp; pdf2ps $file $file.ps )`;

		// Check for a wrapper
		if (!is_object($this->wrapper)) { 
			syslog(LOG_INFO,"FreeMED.TeX|Failed to open wrapper class in PrintTex()");
			return false; 
		}

		// Loop for copies
		for ($i=1;$i<=$copies;$i++) {
			syslog(LOG_INFO,"FreeMED.TeX|Printing file $file.ps");
			$this->wrapper->driver->PrintFile($this->printer, $file.'.ps');
		}

		// Remove temporary files
		unlink($file);
		unlink($file.'.ps');

		// This is correct, so we return true
		return true;
	} // end method Print

	function RenderDebug ( $rendered = false ) {
		$buffer .= $this->_buffer;
		print "<pre>\n";
		print $buffer;
		print "</pre>\n";
	} // end method RenderDebug

	// Method: RenderFromTemplate
	//
	//	Renders a TeX document with substitutions from a TeX
	//	template in the lib/tex/ directory.
	//
	// Parameters:
	//
	//	$template - Name of the template to be used. For
	//	lib/tex/rx.tex this would be 'rx';
	//
	//	$rec - Associative array of primary record data.
	//
	// Returns:
	//
	//	TeX document (not rendered into a result format).
	//
	function RenderFromTemplate ( $template, $rec ) {
		if (!file_exists('lib/tex/'.$template.'.tex')) {
			die("Could not load $template TeX template.");
		}

		// Set iffi status to false
		$this->iffi = false;
		
		// Initial load of file
		$fp = fopen('lib/tex/'.$template.'.tex', 'r');
		if (!$fp) {
			die("Could not open $template TeX template.");
		}
		$buffer = '';
		while (!feof($fp)) { $buffer .= fgets($fp, 4096); }
		fclose ($fp);

		// Second-generation macros
		// 	**macro**
		if (!(strpos($buffer, '**') === false)) {
			$chunks = explode('**', $buffer);
			$buffer = ''; // overwrite what we had
			foreach ($chunks AS $k => $v) {
				if (!($k & 1)) {
					// Non macro, copy verbosely
					if (!$this->iffi) { $buffer .= $v; }
				} else {
					// Call out to buffer function
					$tmp = $this->_ParseTag($rec, $v);
					if (!$this->iffi) { $buffer .= $tmp; }
				}
			} // end foreach
		} // end checking if there are macros

		// Return processed string
		return $buffer;
	} // end method RenderFromTemplate

	// Method: RenderToPDF
	//
	//	Render to PDF and get file name of temporary file
	//
	// Parameters:
	//
	//	$rendered - (optional) Boolean. Set to true if header
	//	and footer are to be supressed.
	//
	// Returns:
	//
	//	Name of temporary file.
	//
	function RenderToPDF ( $rendered = false ) {
		$buffer .= $this->_buffer;
		
		$tmp = tempnam('/tmp', 'fmtex');

		// Send data to $tmp.ltx
		$fp = fopen ($tmp.'.ltx', 'w');
		fwrite ($fp, $buffer, strlen($buffer));
		fclose ($fp);

		// Execute pdflatex rendering
		// (twice for appropriate page numbering)
		`( cd /tmp; pdflatex --interaction nonstopmode "$tmp.ltx" "$tmp.pdf" )`;
		`( cd /tmp; pdflatex --interaction nonstopmode "$tmp.ltx" "$tmp.pdf" )`;

		// Remove intermediary step file(s)
		unlink($tmp);
		unlink($tmp.'.ltx');
		unlink($tmp.'.log');
		unlink($tmp.'.aux');

		return ($tmp.'.pdf');
	} // end method RenderToPDF

	// Method: SetPrinter
	//
	//	Sets the printer and printer wrapper for this TeX document
	//	to use when printing.
	//
	// Parameters:
	//
	//	$wrapper - PHP.PrinterWrapper object
	//
	//	$printer - Text name of the printer to use
	//
	function SetPrinter ( $wrapper, $printer ) {
		$this->wrapper = $wrapper;
		$this->printer = $printer;
	} // end method SetPrinter

	//----------- Internal Methods -----------------------------------

	// Method: _HTMLToRichText
	//
	//	Convert SGML/HTML formatted "rich text" to LaTeX-formatted
	//	rich text, while sanitizing.
	//
	// Parameters:
	//
	//	$orig - Original marked up string
	//
	// Returns:
	//
	//	LaTeX-style rich text
	//
	function _HTMLToRichText ( $orig ) {
		// Sanitize all but HTML markers
		$text = $this->_SanitizeText($orig, true);
		$text = str_replace('\\\\', '\\', $text); // kill double slashes

		// Remove leading CRs if present (mucks with the formatting)
		if (substr($text, 0, 1) == "\n") {
			while (substr($text, 0, 1) == "\n") {
				$text = substr($text, -(strlen($text) - 1));
			}
		}

		// Remove ending <br /><br /> from Gecko (thanks to Volker)
		if (substr($text, -13) == "<br /><br />\n") {
			$text = substr($text, 0, strlen($text)-13);
		}

		// Thanks to Adam for the Perl regular expressions to
		// do all of this work ....

		// Deal with whitespace
		$text = preg_replace("#<\s*#i", '<', $text);
		$text = preg_replace("#\s*>#i", '>', $text);
		$text = preg_replace("#<[^>\S]*/\s*#i", '</', $text);

		// Format paragraph breaks properly
		$text = preg_replace("#\s*<P>#i", "\n\n", $text);

		// Format tags, one by one
		$text = preg_replace("#<B>(.*?)</B>#i", '\textbf{$1}', $text);
		$text = preg_replace("#<I>(.*?)</I>#i", '\textit{$1}', $text);
		$text = preg_replace("#<U>(.*?)</U>#i", '\underline{$1}', $text);

		// Switch BR and SPAN tags (fix for HTMLArea JS)
		while (preg_match("#<BR\s/></SPAN>#i", $text)) {
			$text = preg_replace("#<BR\s/></SPAN>#i", "</span><br />", $text);
		}
		$text = preg_replace("#<SPAN\sSTYLE=\"FONT\-WEIGHT:\sBOLD\;\"><BR\s/>#i", "<br /><span style=\"font-weight: bold;\">", $text);

		// Remove empty tags from HTMLarea malformatting
		$text = str_replace('<span style="font-weight: bold;"></span>', '', $text);
		$text = str_replace('<b></b>', '', $text);
		$text = str_replace('<strong></strong>', '', $text);
		$text = str_replace('<span style="font-style: italic;"></span>', '', $text);
		$text = str_replace('<i></i>', '', $text);
		$text = str_replace('<em></em>', '', $text);
		$text = str_replace('<span style="font-decoration: underline;"></span>', '', $text);
		$text = str_replace('<u></u>', '', $text);
		$text = preg_replace("#<U>\s<BR\s/>\s</U>#i", "", $text);

		// Also do "SPAN" tags, which are put out by HTMLarea JS,
		// and STRONG/EM tags which IE puts out
		$text = preg_replace("#<SPAN\sSTYLE=\"FONT\-WEIGHT:\sBOLD\;\">(.*?)</SPAN>#i", '\textbf{$1}', $text);
		$text = preg_replace("#<STRONG>(.*?)</STRONG>#i", '\textbf{$1}', $text);
		$text = preg_replace("#<SPAN\sSTYLE=\"FONT\-STYLE:\sITALIC\;\">(.*?)</SPAN>#i", '\textit{$1}', $text);
		$text = preg_replace("#<EM>(.*?)</EM>#i", '\textit{$1}', $text);
		$text = preg_replace("#<SPAN\sSTYLE=\"TEXT\-DECORATION:\sUNDERLINE\;\">(.*?)</SPAN>#i", '\underline{$1}', $text);

		// And combination <B><U> things sadly need to be handled...
		$text = preg_replace("#<SPAN\sSTYLE=\"FONT\-WEIGHT:\sBOLD\;\sTEXT\-DECORATION:\sUNDERLINE\;\">(.*?)</SPAN>#i", '\textbf{\underline{$1}}', $text);
		$text = preg_replace("#<SPAN\sSTYLE=\"TEXT\-DECORATION:\sUNDERLINE\;\sFONT\-WEIGHT:\sBOLD\;\">(.*?)</SPAN>#i", '\textbf{\underline{$1}}', $text);

		// Do something about <br /> and <br> tags (<br /> are used
		// by HTMLarea JS). For now, we treat them as though they
		// were paragraph breaks. What is the proper way to handle
		// these?
		$text = preg_replace("#\s*<BR\s/><BR\s/>#i", "\n\\medskip\n", $text);
		$text = preg_replace("#\s*<BR\s/>#i", " \n", $text);
		$text = preg_replace("#\s*<BR>#i", " \n", $text);
	
		// Remove all tags we can't understand
		$text = preg_replace("#<[^>]*?>#i", '', $text);

		// Sanitize out quotes
		$text = $this->_ReplaceQuotes($text);
	
		// Handle embedded CRs... for now we treat them as line
		// breaks
		$text = str_replace("\n", "\\  \\\\\n", $text);

		return $text;
	} // end method _HTMLToRichText

	// Method: _ParseTag
	//
	//	Parse appropriate information from tag to convert into output
	//	data to be passed back to TeX.
	//
	// Parameters:
	//
	//	$rec - Associative array of data to be used for processing.
	//
	//	$tag - Text of the tag to be processed.
	//
	// Returns:
	//
	//	TeX formatted text.
	//
	function _ParseTag ( $rec, $tag ) {
		// Seperate the tag by : seperated parameters
		$params = explode ( ':', $tag );

		// Deal with this by the first parameter, explaining type
		switch ($params[0]) {
			case 'if':
				// Format:
				//	if:(conditiontype):(var):(test?)
				// Needs to be broken with a 'fi' tag
				switch ($params[1]) {
					case 'equals':
					$p = explode(',', $params[3]);
					foreach ($p AS $my_p) {
						if (!($rec[$params[2]] == $my_p)) { $this->iffi = true; }
					}
					break;

					case 'not':
					if ($rec[$params[2]]) { $this->iffi = true; }
					break;
					
					case 'linkexists':
					$p = explode(',', $params[2]);
					$linkrec = freemed::get_link_rec($rec[$p[0]], $p[1]);
					if (!$linkrec[$params[3]]) { $this->iffi = true; }
					break;

					case 'lengthge':
					if (strlen($rec[$params[2]]) < $params[3]) { $this->iffi = true; }
					break;

					case 'lengthle':
					if (strlen($rec[$params[2]]) > $params[3]) { $this->iffi = true; }
					break;

					case 'linklengthge':
					$p = explode(',', $params[2]);
					$linkrec = freemed::get_link_rec($rec[$p[0]], $p[1]);
					if (strlen($linkrec[$params[3]]) != $params[4]) { $this->iffi = true; }
					break;

					case 'linklengthge':
					$p = explode(',', $params[2]);
					$linkrec = freemed::get_link_rec($rec[$p[0]], $p[1]);
					if (strlen($linkrec[$params[3]]) < $params[4]) { $this->iffi = true; }
					break;

					case 'linklengthle':
					$p = explode(',', $params[2]);
					$linkrec = freemed::get_link_rec($rec[$p[0]], $p[1]);
					if (strlen($linkrec[$params[3]]) > $params[4]) { $this->iffi = true; }
					break;

					case 'module':
					$value = module_function (
						$params[2],
						$params[3],
						array (
							$rec[$params[4]]
						)
					);
					unset ($obj);
					if (!$value) { $this->iffi = true; }
					break;

					default:
					if (!$rec[$params[2]]) { $this->iffi = true; }
					break;
				}
				return ''; // need to send blanks back
				break; // end if

			case 'fi':
				// Format:
				//	fi
				// Breaks an 'if' tag
				$this->iffi = false;
				return ''; // need to send blanks back
				break; // end if

			case 'method':
				// Format:
				//	method:(class):(method):(objparameter)
				$ids = explode(',', $rec[$params[3]]);
				foreach ($ids AS $v) {
					$obj = CreateObject('_FreeMED.'.$params[1], $v);
					$values[] = call_user_method($params[2], $obj);
					unset ($obj);
				}
				return $this->_SanitizeText(join(', ', $values));
				break; // end method

			case 'module':
				// Format:
				//	module:(module):(method):(fieldtopass)
				return $this->_SanitizeText(
					module_function (
						$params[1],
						$params[2],
						array (
							$rec[$params[3]]
						)
					)
				);
				break; // end module

			case 'field':
				// Format:
				//	field:(fieldname):(optionalformatting)
				switch ($params[2]) {
					case 'html':
					return '\dohtml'."\n".
						'<html>'."\n".
						$rec[$params[1]]."\n".
						'</html>'."\n";
					break;

					case 'date':
					return $this->_SanitizeText(fm_date_print($rec[$params[1]]));
					break;

					case 'ssn':
					return $this->_SanitizeText('('.substr($rec[$params[1]], 0, 3).'-'.substr($rec[$params[1]], 3, 2).'-'.substr($rec[$params[1]], 5, 4));
					break;

					case 'phone':
					return $this->_SanitizeText('('.substr($rec[$params[1]], 0, 3).') '.substr($rec[$params[1]], 3, 3).'-'.substr($rec[$params[1]], 6, 4));
					break;

					case 'fixcase':
					return $this->_SanitizeText($this->_FixCase($rec[$params[1]]));
					break;

					default:
					return $this->_HTMLToRichText($rec[$params[1]]);
					break;
				}
				break; // end field

			case 'link':
				// Format:
				//	link:(fieldname):(table):(targetfield):(optionalformatting)
				$linkrec = freemed::get_link_rec($rec[$params[1]], $params[2]);
				switch ($params[4]) {
					case 'date':
					return $this->_SanitizeText(fm_date_print($linkrec[$params[3]]));
					break;

					case 'phone':
					$ph = $linkrec[$params[3]];
					return $this->_SanitizeText('('.substr($ph, 0, 3).') '.substr($ph, 3, 3).'-'.substr($ph, 6, 4));
					break;

					case 'ssn':
					$ssn = $linkrec[$params[3]];
					return $this->_SanitizeText('('.substr($ssn, 0, 3).'-'.substr($ssn, 3, 2).'-'.substr($ssn, 5, 4));
					break;

					case 'multiple':
					$ids = explode(',', $rec[$params[1]]);
					foreach ($ids AS $v) {
						$linkrec = freemed::get_link_rec($v, $params[2]);
						
						$values[] = $this->_HTMLToRichText($linkrec[$params[3]]);
					}
					return join(', ', $values);
					break;

					case 'fixcase':
					return $this->_HTMLToRichText($this->_FixCase($linkrec[$params[3]]));
					break;

					default:
					return $this->_HTMLToRichText($linkrec[$params[3]]);
					break;
				} // end optional formatting switch
				break; // end field

			default: // unhandled
				return "(unhandled tag)";
				break;
		} // end case params
		die("Should never reach here");
	} // end method _ParseTag

	// Method: _FixCase
	//
	//	Fix capitalization with what we think is "natural"
	//	capitalization.
	//
	// Parameters:
	//
	//	$string - Original string
	//
	// Returns:
	//
	//	String with appropriate capitalization.
	//
	function _FixCase ( $string ) {
		// Simple substitutions
		$subs = array (
			'Ii' => 'II', // The second
			'Iii' => 'III', // The third
			'Iv' => 'IV', // The fourth
			'Po' => 'PO', // PO Box 
			'St' => 'St.', // Street/Saint
			'Nh' => 'NH', // New Hampshire abbrev
			'Us' => 'US', // United States route abbrev
		);
		$a = explode(' ', $string);
		foreach ($a AS $k => $v) {
			$a[$k] = ucfirst(strtolower($v));

			// Handle obvious substitutions
			foreach ($subs AS $s_k => $s_v) {
				if ($a[$k] == $s_k) { $a[$k] = $s_v; }
			}

			// Handle McDonald and kin
			if ((substr($a[$k], 0, 2) == 'Mc') and (strlen($a[$k])>3)) { 
				$a[$k] = 'Mc' . ucfirst(strtolower(substr($a[$k], -(strlen($a[$k])-2) )));
			}

			// Handle rural routes
			if (substr($a[$k], 0, 2) == 'Rr') { 
				$a[$k] = strtoupper($a[$k]);
			}
			
			// Handle things like 212B Baker Street
			if ((substr($a[$k], 0, 1) + 0) > 0) {
				$a[$k] = strtoupper($a[$k]);
			}

			// Handle single letter abbreviations
			if (strlen($a[$k]) == 1) {
				// Only for letters
				if (chr(strtoupper($a[$k])) >= 65 and chr(strtoupper($a[$k])) <= 90) {
					$a[$k] = strtoupper($a[$k]).'.';
				}
			}
		} // end foreach part of the string
		return join(' ', $a);
	} // end method _FixCase

	// Method: _ReplaceQuotes
	//
	//	Replace quotes with proper beginning and ending quotation
	//	marks, TeX-style.
	//
	// Parameters:
	//
	//	$string - String to be mucked with.
	//
	// Returns:
	//
	//	TeX-quoted string
	//
	function _ReplaceQuotes ( $string ) {
		// Skip if there are no quotes
		if (strpos($string, '"') === false) { return $string; }

		$quotetype = 0;
		for ($i=0; $i<strlen($string); $i++) {
			if (substr($string, $i, 1) == '"') {
				switch ($quotetype) {
					case 0:
					$output .= '``';
					$quotetype = 1;
					break;

					case 1:
					$output .= '\'\'';
					$quotetype = 0;
					break;
				}
			} else {
				$output .= substr($string, $i, 1);
			}
		}
		return $output;
	} // end method _ReplaceQuotes

	// Method: _SanitizeText
	//
	//	Escapes offending TeX control sequences.
	//
	// Parameters:
	//
	//	$text - Text to be sanitized
	//
	//	$skip_html - (optional) Whether or not to skip HTML
	//	specific escape sequences. This is useful if presenting
	//	rich text markup (which uses SGML/HTML tags) to the
	//	renderer. Defaults to false.
	//
	// Returns:
	//
	//	Text that can be cleanly inserted into TeX code.
	//
	function _SanitizeText ( $text, $skip_html=false ) {
		$string = stripslashes($text);

		// First, sanitize escape character
		$string = str_replace('\\', '\\\\', $string);

		// Get rid of \r character
		$string = str_replace("\r", "", $string);

		// Sanitize {, } (do NOT escape [ and ])
		$string = str_replace('{', '\lbrace\ ', $string);
		$string = str_replace('}', '\lbrace\ ', $string);
		$string = str_replace('[', '\lbrack\ ', $string);
		$string = str_replace(']', '\rbrack\ ', $string);

		// Make sure dollar sign escaping used before $+$ escaped
		$string = str_replace('$', '\$', $string);

		// Get rid of #, _, %, +
		$string = str_replace('#', '\#', $string);
		$string = str_replace('_', '\_', $string);
		$string = str_replace('%', '\%', $string);
		$string = str_replace('+', '$+$', $string);

		// Deal with amphersands, and &quot; &amp; stuff
		$string = str_replace('&quot;', '"', $string);
		$string = str_replace('&amp;', '&', $string);
		$string = str_replace('&lt;', '$<$', $string);
		$string = str_replace('&gt;', '$>$', $string);
		$string = str_replace('&', '\&', $string);
		$string = str_replace('&nbsp;', '\ ', $string);

		// HTML/SGML specific texts
		if (!$skip_html) {
			// This one isn't *really* right, since there are
			// technically opening and closing quotes, but it
			// will do for now.
			$string = $this->_ReplaceQuotes($string);

			$string = str_replace('<', '\<', $string);
			$string = str_replace('>', '\>', $string);
		}

		// Return processed string
		return $string;
	} // end method _SanitizeText

} // end class TeX

?>

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us