diff --git a/mod/wiki/parser/markups/html.php b/mod/wiki/parser/markups/html.php
index 0817a0285b9..486aeac8f46 100644
--- a/mod/wiki/parser/markups/html.php
+++ b/mod/wiki/parser/markups/html.php
@@ -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;