BUGFIX: fixed encoding of special characters when not in code snippets.

This commit is contained in:
Will Rossiter 2011-04-05 14:13:51 +12:00
parent cfaa08d858
commit ef5664f777
4 changed files with 35 additions and 6 deletions

View File

@ -42,11 +42,13 @@ class DocumentationParser {
$md = self::rewrite_api_links($md, $page);
$md = self::rewrite_heading_anchors($md, $page);
$md = self::rewrite_code_blocks($md, $page);
require_once(BASE_PATH . '/sapphiredocs/thirdparty/markdown/markdown.php');
$html = Markdown($md);
return $html;
$parser = new MarkdownExtra_Parser();
$parser->no_markup = true;
return $parser->transform($md);
}
function rewrite_code_blocks($md) {

View File

@ -217,4 +217,24 @@ HTML;
$this->assertEquals("Foo Bar's Test page.", $page->getTitle());
$this->assertEquals("Foo Bar's Test page.", $page->Title);
}
function testParserConvertsSpecialCharacters() {
$page = new DocumentationPage();
$page->setRelativePath('CodeSnippets.md');
$page->setEntity(new DocumentationEntity('parser', '2.4', BASE_PATH . '/sapphiredocs/tests/docs-parser/'));
$parsed = DocumentationParser::parse($page, '/sapphiredocs/tests/docs-parser/');
// header elements parsed
$this->assertContains(
'<% control Foo %>',
$parsed
);
// paragraphs
$this->assertContains(
'<% foo %>',
$parsed
);
}
}

View File

@ -0,0 +1,6 @@
#### <% control Foo %>
code block
<% without formatting prefix %>
Paragraph with a segment of <% foo %>

View File

@ -1419,8 +1419,9 @@ class Markdown_Parser {
$text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
'&amp;', $text);;
}
# Encode remaining <'s
$text = str_replace('<', '&lt;', $text);
# Encode remaining <'s and >'s
$text = str_replace(array('<','>'), array('&lt;','&gt;'), $text);
return $text;
}