mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-28616 wiki: html format toc rendering should match nwiki and creole
This commit is contained in:
parent
935c3d5ed2
commit
2264828fd0
@ -19,9 +19,8 @@ class html_parser extends nwiki_parser {
|
||||
parent::__construct();
|
||||
$this->tagrules = array('link' => $this->tagrules['link'], 'url' => $this->tagrules['url']);
|
||||
|
||||
//headers are considered tags here...
|
||||
$h1 = array("<\s*h1\s*>", "<\/h1>");
|
||||
$this->tagrules['header1'] = array('expression' => "/{$h1[0]}(.+?){$h1[1]}/is"
|
||||
// Headers are considered tags here.
|
||||
$this->tagrules['header'] = array('expression' => "/<\s*h([1-6])\s*>(.+?)<\/h[1-6]>/is"
|
||||
);
|
||||
}
|
||||
|
||||
@ -32,10 +31,12 @@ class html_parser extends nwiki_parser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Header 1 tag rule
|
||||
* Header tag rule
|
||||
* @param array $match Header regex match
|
||||
* @return string
|
||||
*/
|
||||
protected function header1_tag_rule($match) {
|
||||
return $this->generate_header($match[1], 1);
|
||||
protected function header_tag_rule($match) {
|
||||
return $this->generate_header($match[2], $match[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,11 +63,11 @@ class html_parser extends nwiki_parser {
|
||||
|
||||
protected function get_repeated_sections(&$text, $repeated = array()) {
|
||||
$this->repeated_sections = $repeated;
|
||||
return preg_replace_callback($this->tagrules['header1'], array($this, 'get_repeated_sections_callback'), $text);
|
||||
return preg_replace_callback($this->tagrules['header'], array($this, 'get_repeated_sections_callback'), $text);
|
||||
}
|
||||
|
||||
protected function get_repeated_sections_callback($match) {
|
||||
$text = trim($match[1]);
|
||||
$text = trim($match[2]);
|
||||
|
||||
if (in_array($text, $this->repeated_sections)) {
|
||||
$this->returnvalues['repeated_sections'][] = $text;
|
||||
|
Loading…
x
Reference in New Issue
Block a user