mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
BUGFIX: fixed encoding of special characters when not in code snippets.
This commit is contained in:
parent
cfaa08d858
commit
ef5664f777
@ -44,9 +44,11 @@ class DocumentationParser {
|
||||
$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) {
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
6
tests/docs-parser/en/CodeSnippets.md
Normal file
6
tests/docs-parser/en/CodeSnippets.md
Normal file
@ -0,0 +1,6 @@
|
||||
#### <% control Foo %>
|
||||
|
||||
code block
|
||||
<% without formatting prefix %>
|
||||
|
||||
Paragraph with a segment of <% foo %>
|
5
thirdparty/markdown/markdown.php
vendored
5
thirdparty/markdown/markdown.php
vendored
@ -1419,8 +1419,9 @@ class Markdown_Parser {
|
||||
$text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
|
||||
'&', $text);;
|
||||
}
|
||||
# Encode remaining <'s
|
||||
$text = str_replace('<', '<', $text);
|
||||
|
||||
# Encode remaining <'s and >'s
|
||||
$text = str_replace(array('<','>'), array('<','>'), $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user