Пример #1
0
 /** Set the RTF text this Note object should represent. Overwrites any previously set RTF data. */
 function setRTF($rtf)
 {
     $this->raw_rtf = $rtf;
     $rtf = $this->stripOuterBraces($rtf);
     $tree = $this->convertBracesToArray($rtf);
     // find 'text' section (last element of tree array) and escape RTF tokens (brace lexer un-escapes them)
     $textSection = $tree[count($tree) - 1];
     $textSection = str_replace('{', '\\{', $textSection);
     $textSection = str_replace('}', '\\}', $textSection);
     $tree[count($tree) - 1] = $textSection;
     $sectionLexer = new JoshRibakoff_Note_SectionLexer();
     $sectionLexer->setInput($tree);
     $this->rtf_fonttable = $sectionLexer->fontTable();
     $this->rtf_colortable = $sectionLexer->colorTable();
     $this->rtf_text_pieces = $sectionLexer->textPieces();
     $this->rtf_text = $sectionLexer->text();
 }
Пример #2
0
 function testShouldPreserveTrailingWhitespaceInTextPieces()
 {
     $lexer = new JoshRibakoff_Note_SectionLexer();
     $lexer->setInput(array("\n" . 'test \\par'));
     $actual = $lexer->textPieces();
     $this->assertEquals('test ', $actual[0]['text'], 'should lex out text');
 }
Пример #3
0
 function testSectionLexerShouldParsePlainText()
 {
     $sectionLexer = new JoshRibakoff_Note_SectionLexer();
     $actual = $sectionLexer->lineOfText('3/29/2013 2:19:29 PM - gviguet:  l/vm in re to Counseling..............');
     $this->assertEquals('3/29/2013 2:19:29 PM - gviguet:  l/vm in re to Counseling..............', $actual['text'], 'should return line of text');
 }