mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-78432 mod_label: Process markdown in label name
* Process markdown and other allowed formats (see FORMAT_XXX) in get_label_name so it does not display it as a litteral string in the course index menu.
This commit is contained in:
parent
3cd84747cb
commit
901fb4f2d0
@ -34,7 +34,9 @@ define("LABEL_MAX_NAME_LENGTH", 50);
|
||||
* @return string
|
||||
*/
|
||||
function get_label_name($label) {
|
||||
$name = html_to_text(format_string($label->intro, true));
|
||||
$context = context_module::instance($label->coursemodule);
|
||||
$intro = format_text($label->intro, $label->introformat, ['filter' => false, 'context' => $context]);
|
||||
$name = html_to_text(format_string($intro, true, ['context' => $context]));
|
||||
$name = preg_replace('/@@PLUGINFILE@@\/[[:^space:]]+/i', '', $name);
|
||||
// Remove double space and also nbsp; characters.
|
||||
$name = preg_replace('/\s+/u', ' ', $name);
|
||||
|
@ -289,7 +289,32 @@ class lib_test extends \advanced_testcase {
|
||||
'content' => '<audio controls="controls"><source src=""></audio>',
|
||||
'format' => FORMAT_HTML,
|
||||
'expected' => 'Text and media area'
|
||||
]
|
||||
],
|
||||
'markdown' => [
|
||||
'content' => "##Simple Title\n simple markdown format",
|
||||
'format' => FORMAT_MARKDOWN,
|
||||
'expected' => 'Simple Title simple markdown format'
|
||||
],
|
||||
'markdown with pluginfile' => [
|
||||
'content' => "##Simple Title\n simple markdown format @@PLUGINFILE@@/moodle-hit-song.mp3",
|
||||
'format' => FORMAT_MARKDOWN,
|
||||
'expected' => 'Simple Title simple markdown format'
|
||||
],
|
||||
'plain text' => [
|
||||
'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
|
||||
'format' => FORMAT_PLAIN,
|
||||
'expected' => 'Simple plain text'
|
||||
],
|
||||
'moodle format text' => [
|
||||
'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
|
||||
'format' => FORMAT_MOODLE,
|
||||
'expected' => 'Simple plain text'
|
||||
],
|
||||
'html format text' => [
|
||||
'content' => "<h1>Simple plain title</h1><p> with plain text</p> @@PLUGINFILE@@/moodle-hit-song.mp3",
|
||||
'format' => FORMAT_HTML,
|
||||
'expected' => 'Simple plain title with plain text'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user