/** * Parse input into nodes * * @param net.daringfireball.markdown.Input $lines * @return net.daringfireball.markdown.Node */ public function parse($lines) { $result = new CodeBlock($this->language); while ($lines->hasMoreLines()) { $line = $lines->nextLine(); if (0 === strncmp($line, '```', 3)) { break; } else { $result->add(new Text($line)); } } return $result; }
/** * Returns a json encoded array of CodeBlock dataobjects in the format: (ID, Name) * Note: only objects with AdvertType of 'Embed Javascript' and Status of 'Active' are returned * * @param SS_HTTPRequest $request * @return SS_HTTPResonse A http response containing a json encoded array * @see: code-blocks/_config/routes.yml */ public function json(SS_HTTPRequest $request) { $this->response->addHeader('Content-Type', 'application/json'); if ($list = CodeBlock::get()->filter(array('Status' => 'Active'))->map('ID', 'Name')) { $this->response->setBody(json_encode($list->toArray())); return $this->response; } }
/** * return some info */ function getInfo() { $info = parent::getInfo(); $info['date'] = '2010-12-16'; $info['name'] = 'Project-file content Plugin'; $info['desc'] = 'display the content tag in a project file'; return $info; }
/** * Parse input into nodes * * @param net.daringfireball.markdown.Input $lines * @return net.daringfireball.markdown.Node */ public function parse($lines) { $result = new CodeBlock(); while ($lines->hasMoreLines()) { $line = $lines->nextLine(); if ("\t" === $line->chr()) { $result->add(new Text(substr($line, 1))); } else { if (0 === strncmp($line, ' ', 4)) { $result->add(new Text(substr($line, 4))); } else { $lines->resetLine($line); break; } } } return $result; }
public function testVoid() { $codeBlock = new CodeBlock('$a = 1 + 2;'); $this->assertInstanceOf('hanneskod\\readmetester\\Result', $codeBlock->execute()); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The chunk "header" is already in use. */ public function testDuplicateChunk() { $block = new CodeBlock(); $block->set(CodeBlock::HEADER, 'foo'); $block->set(CodeBlock::HEADER, 'bar'); }