mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Merge branch 'MDL-28616-master' of https://github.com/mackensen/moodle
This commit is contained in:
commit
03a1ef0cbc
@ -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-$this->maxheaderdepth])\s*>(.+?)<\/h[1-$this->maxheaderdepth]>/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;
|
||||
|
@ -24,6 +24,7 @@ abstract class wiki_markup_parser extends generic_parser {
|
||||
|
||||
//header & ToC
|
||||
protected $toc = array();
|
||||
protected $maxheaderdepth = 3;
|
||||
|
||||
/**
|
||||
* function wiki_parser_link_callback($link = "")
|
||||
@ -183,7 +184,7 @@ abstract class wiki_markup_parser extends generic_parser {
|
||||
$text .= parser_utils::h('a', '['.get_string('editsection', 'wiki').']', array('href' => "edit.php?pageid={$this->wiki_page_id}§ion=" . urlencode($text), 'class' => 'wiki_edit_section'));
|
||||
}
|
||||
|
||||
if ($level < 4) {
|
||||
if ($level <= $this->maxheaderdepth) {
|
||||
$this->toc[] = array($level, $text);
|
||||
$num = count($this->toc);
|
||||
$text = parser_utils::h('a', "", array('name' => "toc-$num")) . $text;
|
||||
|
Loading…
x
Reference in New Issue
Block a user