/** 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(); }
function testShouldKeepEscapedCurlyBraces() { $lexer = new JoshRibakoff_Note_SectionLexer(); $lexer->setInput(array('\\{\\}')); $textPieces = $lexer->textPieces(); $this->assertEquals('\\{\\}', $textPieces[0]['rtf']); $text = $lexer->text(); $this->assertEquals('\\{\\}', $text); }