private function assertTestFile($num, $markup)
 {
     if (!file_exists(__DIR__ . "/fixtures/input/{$markup}/{$num}") || !file_exists(__DIR__ . "/fixtures/output/{$markup}/{$num}")) {
         return false;
     }
     $input = file_get_contents(__DIR__ . "/fixtures/input/{$markup}/{$num}");
     $output = file_get_contents(__DIR__ . "/fixtures/output/{$markup}/{$num}");
     $result = wiki_parser_proxy::parse($input, $markup, array('pretty_print' => true));
     //removes line breaks to avoid line break encoding causing tests to fail.
     $result['parsed_text'] = preg_replace('~[\\r\\n]~', '', $result['parsed_text']);
     $output = preg_replace('~[\\r\\n]~', '', $output);
     $this->assertEquals($result['parsed_text'], $output);
     return true;
 }
Beispiel #2
0
    public static function parse(&$string, $type, $options = array()) {

        if(empty(self::$basepath)) {
            global $CFG;
            self::$basepath = $CFG->dirroot.'/mod/wiki/parser/';
        }

        $type = strtolower($type);
        if(self::create_parser_instance($type)) {
            return self::$parsers[$type]->parse($string, $options);
        }
        else {
            return false;
        }
    }
Beispiel #3
0
 public static function parse(&$string, $type, $options = array())
 {
     if (empty(self::$basepath)) {
         global $CFG;
         self::$basepath = $CFG->dirroot . '/mod/wiki/parser/';
     }
     $type = strtolower($type);
     self::$parsers[$type] = null;
     // Reset the current parser because it may have other options.
     if (self::create_parser_instance($type)) {
         return self::$parsers[$type]->parse($string, $options);
     } else {
         return false;
     }
 }
Beispiel #4
0
/**
 * Returns the token used by a wiki language to represent a given tag or "object" (bold -> **)
 *
 * @return A string when it has only one token at the beginning (f. ex. lists). An array composed by 2 strings when it has 2 tokens, one at the beginning and one at the end (f. ex. italics). Returns false otherwise.
 * @author Josep Arús Pous
 **/
function wiki_parser_get_token($markup, $name)
{
    return wiki_parser_proxy::get_token($name, $markup);
}
 /**
  * Check that headings with special characters work as expected with HTML.
  *
  * - The heading itself is well displayed,
  * - The TOC heading is well display,
  * - The edit link points to the right page,
  * - The links properly works with get_section.
  */
 public function test_special_headings()
 {
     // First testing HTML markup.
     // Test section name using HTML entities.
     $input = '<h1>Code &amp; Test</h1>';
     $output = '<h1><a name="toc-1"></a>Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" ' . 'class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+' . 'Test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Code &amp; Test');
     $actual = wiki_parser_proxy::parse($input, 'html');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name using non-ASCII characters.
     $input = '<h1>Another áéíóúç€ test</h1>';
     $output = '<h1><a name="toc-1"></a>Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Another áéíóúç€ test');
     $actual = wiki_parser_proxy::parse($input, 'html');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name with a URL.
     $input = '<h1>Another http://moodle.org test</h1>';
     $output = '<h1><a name="toc-1"></a>Another <a href="http://moodle.org">http://moodle.org</a> test <a href="edit.php' . '?pageid=&amp;section=Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another http://moodle.org test <a href="edit.php?pageid=&amp;section=' . 'Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Another http://moodle.org test');
     $actual = wiki_parser_proxy::parse($input, 'html', array('link_callback' => '/mod/wiki/locallib.php:wiki_parser_link'));
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Now going to test Creole markup.
     // Note that Creole uses links to the escaped version of the section.
     // Test section name using HTML entities.
     $input = '= Code & Test =';
     $output = '<h1><a name="toc-1"></a>Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" ' . 'class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+' . 'Test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'creole', 'Code &amp; Test');
     $actual = wiki_parser_proxy::parse($input, 'creole');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name using non-ASCII characters.
     $input = '= Another áéíóúç€ test =';
     $output = '<h1><a name="toc-1"></a>Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'creole', 'Another áéíóúç€ test');
     $actual = wiki_parser_proxy::parse($input, 'creole');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name with a URL, creole does not support linking links in a heading.
     $input = '= Another http://moodle.org test =';
     $output = '<h1><a name="toc-1"></a>Another http://moodle.org test <a href="edit.php' . '?pageid=&amp;section=Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another http://moodle.org test <a href="edit.php?pageid=&amp;section=' . 'Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'creole', 'Another http://moodle.org test');
     $actual = wiki_parser_proxy::parse($input, 'creole');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Now going to test NWiki markup.
     // Note that Creole uses links to the escaped version of the section.
     // Test section name using HTML entities.
     $input = '= Code & Test =';
     $output = '<h1><a name="toc-1"></a>Code & Test <a href="edit.php?pageid=&amp;section=Code+%26+Test" ' . 'class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Code & Test <a href="edit.php?pageid=&amp;section=Code+%26+' . 'Test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'nwiki', 'Code & Test');
     $actual = wiki_parser_proxy::parse($input, 'nwiki');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name using non-ASCII characters.
     $input = '= Another áéíóúç€ test =';
     $output = '<h1><a name="toc-1"></a>Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'nwiki', 'Another áéíóúç€ test');
     $actual = wiki_parser_proxy::parse($input, 'nwiki');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name with a URL, nwiki does not support linking links in a heading.
     $input = '= Another http://moodle.org test =';
     $output = '<h1><a name="toc-1"></a>Another http://moodle.org test <a href="edit.php' . '?pageid=&amp;section=Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></h1>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another http://moodle.org test <a href="edit.php?pageid=&amp;section=' . 'Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'nwiki', 'Another http://moodle.org test');
     $actual = wiki_parser_proxy::parse($input, 'nwiki');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
 }
Beispiel #6
0
 /**
  * Edit a page contents.
  *
  * @param int $pageid The page ID.
  * @param string $content Page contents.
  * @param int $section Section to be edited.
  * @return array of warnings and page data.
  * @since Moodle 3.1
  */
 public static function edit_page($pageid, $content, $section = null)
 {
     global $USER;
     $params = self::validate_parameters(self::edit_page_parameters(), array('pageid' => $pageid, 'content' => $content, 'section' => $section));
     $warnings = array();
     // Get wiki page.
     if (!($page = wiki_get_page($params['pageid']))) {
         throw new moodle_exception('incorrectpageid', 'wiki');
     }
     // Get wiki instance.
     if (!($wiki = wiki_get_wiki_from_pageid($params['pageid']))) {
         throw new moodle_exception('incorrectwikiid', 'wiki');
     }
     // Get subwiki instance.
     if (!($subwiki = wiki_get_subwiki($page->subwikiid))) {
         throw new moodle_exception('incorrectsubwikiid', 'wiki');
     }
     // Permission validation.
     $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     if (!wiki_user_can_edit($subwiki)) {
         throw new moodle_exception('cannoteditpage', 'wiki');
     }
     if (wiki_is_page_section_locked($page->id, $USER->id, $params['section'])) {
         throw new moodle_exception('pageislocked', 'wiki');
     }
     // Save content.
     if (!is_null($params['section'])) {
         $version = wiki_get_current_version($page->id);
         $content = wiki_parser_proxy::get_section($version->content, $version->contentformat, $params['section'], false);
         if (!$content) {
             throw new moodle_exception('invalidsection', 'wiki');
         }
         $save = wiki_save_section($page, $params['section'], $params['content'], $USER->id);
     } else {
         $save = wiki_save_page($page, $params['content'], $USER->id);
     }
     wiki_delete_locks($page->id, $USER->id, $params['section']);
     if (!$save) {
         throw new moodle_exception('savingerror', 'wiki');
     }
     $result = array();
     $result['pageid'] = $page->id;
     $result['warnings'] = $warnings;
     return $result;
 }
Beispiel #7
0
 /**
  * Check that headings with special characters work as expected with HTML.
  *
  * - The heading itself is well displayed,
  * - The TOC heading is well display,
  * - The edit link points to the right page,
  * - The links properly works with get_section.
  */
 public function test_special_headings()
 {
     // First testing HTML markup.
     // Test section name using HTML entities.
     $input = '<h1>Code &amp; Test</h1>';
     $output = '<h3><a name="toc-1"></a>Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" ' . 'class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+' . 'Test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Code &amp; Test');
     $actual = wiki_parser_proxy::parse($input, 'html');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name using non-ASCII characters.
     $input = '<h1>Another áéíóúç€ test</h1>';
     $output = '<h3><a name="toc-1"></a>Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Another áéíóúç€ test');
     $actual = wiki_parser_proxy::parse($input, 'html');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name with a URL.
     $input = '<h1>Another http://moodle.org test</h1>';
     $output = '<h3><a name="toc-1"></a>Another <a href="http://moodle.org">http://moodle.org</a> test <a href="edit.php' . '?pageid=&amp;section=Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another http://moodle.org test <a href="edit.php?pageid=&amp;section=' . 'Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Another http://moodle.org test');
     $actual = wiki_parser_proxy::parse($input, 'html', array('link_callback' => '/mod/wiki/locallib.php:wiki_parser_link'));
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test toc section names being wikilinks.
     $input = '<h1>[[Heading 1]]</h1><h2>[[Heading A]]</h2><h2>Heading D</h2>';
     $regexpoutput = '!<h3><a name="toc-1"></a>' . '<a class="wiki_newentry" href.*mod/wiki/create\\.php\\?.*title=Heading\\+1.*action=new.*>Heading 1<.*' . '<h4><a name="toc-2"></a>' . '<a class="wiki_newentry" href.*mod/wiki/create\\.php\\?.*title=Heading\\+A.*action=new.*>Heading A<.*' . '<h4><a name="toc-3"></a>' . 'Heading D!ms';
     $regexptoc = '!<a href="#toc-1">Heading 1.*<a href="#toc-2">Heading A</a>.*<a href="#toc-3">Heading D</a>!ms';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Another [[wikilinked]] test');
     $actual = wiki_parser_proxy::parse($input, 'html', array('link_callback' => '/mod/wiki/locallib.php:wiki_parser_link', 'link_callback_args' => array('swid' => 1)));
     $this->assertRegExp($regexpoutput, $actual['parsed_text']);
     $this->assertRegExp($regexptoc, $actual['toc']);
     // Now going to test Creole markup.
     // Note that Creole uses links to the escaped version of the section.
     // Test section name using HTML entities.
     $input = '= Code & Test =';
     $output = '<h3><a name="toc-1"></a>Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+Test" ' . 'class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Code &amp; Test <a href="edit.php?pageid=&amp;section=Code+%26amp%3B+' . 'Test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'creole', 'Code &amp; Test');
     $actual = wiki_parser_proxy::parse($input, 'creole');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name using non-ASCII characters.
     $input = '= Another áéíóúç€ test =';
     $output = '<h3><a name="toc-1"></a>Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'creole', 'Another áéíóúç€ test');
     $actual = wiki_parser_proxy::parse($input, 'creole');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name with a URL, creole does not support linking links in a heading.
     $input = '= Another http://moodle.org test =';
     $output = '<h3><a name="toc-1"></a>Another http://moodle.org test <a href="edit.php' . '?pageid=&amp;section=Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another http://moodle.org test <a href="edit.php?pageid=&amp;section=' . 'Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'creole', 'Another http://moodle.org test');
     $actual = wiki_parser_proxy::parse($input, 'creole');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Now going to test NWiki markup.
     // Note that Creole uses links to the escaped version of the section.
     // Test section name using HTML entities.
     $input = '= Code & Test =';
     $output = '<h3><a name="toc-1"></a>Code & Test <a href="edit.php?pageid=&amp;section=Code+%26+Test" ' . 'class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Code & Test <a href="edit.php?pageid=&amp;section=Code+%26+' . 'Test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'nwiki', 'Code & Test');
     $actual = wiki_parser_proxy::parse($input, 'nwiki');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name using non-ASCII characters.
     $input = '= Another áéíóúç€ test =';
     $output = '<h3><a name="toc-1"></a>Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another áéíóúç€ test <a href="edit.php?pageid=&amp;section=Another+%C' . '3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%A7%E2%82%AC+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'nwiki', 'Another áéíóúç€ test');
     $actual = wiki_parser_proxy::parse($input, 'nwiki');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section name with a URL, nwiki does not support linking links in a heading.
     $input = '= Another http://moodle.org test =';
     $output = '<h3><a name="toc-1"></a>Another http://moodle.org test <a href="edit.php' . '?pageid=&amp;section=Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></h3>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Another http://moodle.org test <a href="edit.php?pageid=&amp;section=' . 'Another+http%3A%2F%2Fmoodle.org+test" class="wiki_edit_section">[edit]</a></a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'nwiki', 'Another http://moodle.org test');
     $actual = wiki_parser_proxy::parse($input, 'nwiki');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
     // Test section names when headings start with level 3.
     $input = '<h3>Heading test</h3><h4>Subsection</h4>';
     $output = '<h3><a name="toc-1"></a>Heading test <a href="edit.php?pageid=&amp;section=Heading+test" ' . 'class="wiki_edit_section">[edit]</a></h3>' . "\n" . '<h4><a name="toc-2"></a>Subsection</h4>' . "\n";
     $toc = '<div class="wiki-toc"><p class="wiki-toc-title">Table of contents</p><p class="wiki-toc-section-1 ' . 'wiki-toc-section">1. <a href="#toc-1">Heading test <a href="edit.php?pageid=&amp;section=Heading+' . 'test" class="wiki_edit_section">[edit]</a></a></p><p class="wiki-toc-section-2 wiki-toc-section">' . '1.1. <a href="#toc-2">Subsection</a></p></div>';
     $section = wiki_parser_proxy::get_section($input, 'html', 'Heading test');
     $actual = wiki_parser_proxy::parse($input, 'html');
     $this->assertEquals($output, $actual['parsed_text']);
     $this->assertEquals($toc, $actual['toc']);
     $this->assertNotEquals(false, $section);
 }