function testRenderHighlightThatIsIgnorableByBulk() { $highlight1 = new Highlight(14, 14, Highlight::DELETED, 0, 0, 'ref1'); $splitPositions = array(14 => array(new SplitPosition(1, SplitPosition::ATOM, $highlight1))); $renderedText = $this->textRenderer->renderText($this->textFragment, $splitPositions); $pastedText = strip_tags($renderedText); $bulkText = preg_replace('/[!#]/', ' ', $pastedText); $cleanText = preg_replace('/\\s\\s+/', ' ', $bulkText); assertThat($cleanText, is("foo bar baz quux")); }
public function scanMonkFileRendered($tmpfname) { list($licenseIds, $highlights) = $this->scanMonk($tmpfname); $text = file_get_contents($tmpfname); $this->highlightProcessor->addReferenceTexts($highlights); $splitPositions = $this->highlightProcessor->calculateSplitPositions($highlights); $textFragment = new TextFragment(0, $text); $rendered = $this->textRenderer->renderText($textFragment, $splitPositions); return array($licenseIds, $rendered); }
/** * \brief Given a file handle, display a "hex dump" of the file. * Output goes to stdout! */ function getHex($inputFile, $startOffset = 0, $outputLength = -1, $splitPositions = array()) { if (!($outputLength = $this->checkAndPrepare($inputFile, $startOffset, $outputLength))) { return ""; } $output = ""; fseek($inputFile, $startOffset, SEEK_SET); $textFragment = new TextFragment($startOffset, fread($inputFile, $outputLength)); $output .= "<div class='mono'>"; $renderedText = $this->textRenderer->renderHex($textFragment, $splitPositions); $output .= $renderedText; $output .= "</div>\n"; return $output; }