commit 79f10efe077b74177c4c4e24b8d1af955460b526
parent 9b500e0c4342b51683f18e1607ac3f594f077fbb
Author: dankert <devnull@localhost>
Date: Wed, 2 Nov 2005 22:27:29 +0100
Abbildung einer Eingabe-Textzeile
Diffstat:
1 file changed, 100 insertions(+), 0 deletions(-)
diff --git a/serviceClasses/Line.class.php b/serviceClasses/Line.class.php
@@ -0,0 +1,99 @@
+<?php
+
+/**
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.services
+ */
+class Line
+{
+ var $source;
+ var $value;
+
+ var $isList = false;
+ var $isNumberedList = false;
+ var $indent = 0;
+
+ var $isHeadline = false;
+ var $isHeadlineUnderline = false;
+ var $headlineLevel = 0;
+
+
+ var $isTableOfContent = false;
+ var $isTable = false;
+ var $isCode = false;
+ var $isQuote = false;
+ var $isQuotePraefix = false;
+
+ var $isUnparsed = false;
+
+ var $isEmpty = false;
+
+
+
+ function Line( $s )
+ {
+ $this->source = $s;
+ $this->value = $s;
+
+ $this->isList = substr(ltrim($s),0,1) == '-';
+ $this->isNumberedList = substr(ltrim($s),0,1) == '#';
+ $this->indent = strlen($s)-strlen(ltrim($s))+1;
+
+ if ( $this->isList || $this->isNumberedList )
+ $this->value = ltrim(substr($s,$this->indent));
+
+ $this->level = strspn( $s,'+' );
+ $this->isHeadline = $this->level >= 1;
+
+ if ( $this->isHeadline )
+ $this->value = ltrim(substr($s,$this->level));
+
+
+ $hl = array(1=>'=',2=>'-',3=>'.');
+ foreach($hl as $lev=>$char )
+ {
+ if ( substr($s,0,3)==str_repeat($char,3) )
+ {
+ $this->isHeadlineUnderline = true;
+ $this->level = intval($lev);
+ }
+ }
+
+ if ( substr($s,0,7)=='##TOC##' )
+ {
+ $this->isTableOfContent = true;
+ $this->value = '';
+ }
+ elseif ( substr($s,0,1)=='|' )
+ {
+ $this->isTable = true;
+ $this->value = '';
+ }
+ elseif ( substr($s,0,1)=='=' && !$this->isHeadlineUnderline )
+ {
+ $this->isCode = true;
+ $this->value = '';
+ }
+ elseif ( trim($s)=='>' )
+ {
+ $this->isQuote = true;
+ }
+ elseif ( substr($s,0,1)=='>' && strlen(trim($s)>1) )
+ {
+ $this->isQuotePraefix = true;
+ $this->level = strspn( str_replace(' ','',$s),'>' );
+ }
+ elseif ( substr($s,0,1)== '`' )
+ {
+ $this->isUnparsed = true;
+ $this->value = substr($this->value,1);
+ }
+ elseif ( $s == '' )
+ {
+ $this->isEmpty = true;
+ }
+ }
+}
+
+?>+
\ No newline at end of file