function testRewriteCodeBlocks() { $page = new DocumentationPage(); $page->setRelativePath('test.md'); $page->setEntity(new DocumentationEntity('mymodule', '2.4', BASE_PATH . '/sapphiredocs/tests/docs/')); $page->setLang('en'); $page->setVersion('2.4'); $result = DocumentationParser::rewrite_code_blocks($page->getMarkdown()); $expected = <<<HTML <pre class="brush: php"> code block with multiple lines \tand tab indent \tand escaped < brackets </pre> Normal text after code block HTML; $this->assertContains($expected, $result, 'Custom code blocks with ::: prefix'); $expected = <<<HTML <pre> code block without formatting prefix </pre> HTML; $this->assertContains($expected, $result, 'Traditional markdown code blocks'); }
public function testRewriteCodeBlocks() { $codePage = new DocumentationPage($this->entityAlt, 'CodeSnippets.md', DOCSVIEWER_PATH . '/tests/docs-parser/en/CodeSnippets.md'); $result = DocumentationParser::rewrite_code_blocks($codePage->getMarkdown()); $expected = <<<HTML #### <% control Foo %> ``` code block <% without formatting prefix %> ``` Paragraph with a segment of <% foo %> ``` code block that has a line in it ``` This is a yaml block ```yaml foo: bar baz: qux ``` This is a yaml block with tab in that new line ```yaml foo: bar baz: qux ``` HTML; $this->assertEquals($expected, $result, 'Code blocks support line breaks'); $result = DocumentationParser::rewrite_code_blocks($this->page->getMarkdown()); $expected = <<<HTML ```php code block with multiple lines \tand tab indent \tand escaped < brackets \t ``` Normal text after code block HTML; $this->assertContains($expected, $result, 'Custom code blocks with ::: prefix'); $expected = <<<HTML ``` code block without formatting prefix ``` HTML; $this->assertContains($expected, $result, 'Traditional markdown code blocks'); $expected = <<<HTML ``` Fenced code block ``` HTML; $this->assertContains($expected, $result, 'Backtick code blocks'); $expected = <<<HTML ```php Fenced box with new lines in between content ``` HTML; $this->assertContains($expected, $result, 'Backtick with newlines'); }