MDL-5507 filter_mathjaxloader: Add commeents for regexes
authorDaniel Thies <dthies@ccal.edu>
Mon, 11 Jul 2016 18:20:41 +0000 (13:20 -0500)
committerDaniel Thies <dthies@ccal.edu>
Mon, 11 Jul 2016 18:20:41 +0000 (13:20 -0500)
filter/mathjaxloader/filter.php

index 88f22bf..c5428c8 100644 (file)
@@ -164,13 +164,16 @@ class filter_mathjaxloader extends moodle_text_filter {
         if ($hasinline || $hasdisplay || $hasextra) {
             $PAGE->requires->yui_module('moodle-filter_mathjaxloader-loader', 'M.filter_mathjaxloader.typeset');
             if ($hasextra) {
         if ($hasinline || $hasdisplay || $hasextra) {
             $PAGE->requires->yui_module('moodle-filter_mathjaxloader-loader', 'M.filter_mathjaxloader.typeset');
             if ($hasextra) {
+                // If custom dilimeters are used, wrap whole text to prevent autolinking.
                 $text = '<span class="nolink">' + $text + '</span>';
             } else {
                 if ($hasinline) {
                 $text = '<span class="nolink">' + $text + '</span>';
             } else {
                 if ($hasinline) {
+                    // If the default inline TeX delimiters \( \) are present, wrap each pair in nolink.
                     $text = preg_replace('/\\\\\\([\S\s]*?\\\\\\)/u',
                         '<span class="nolink">\0</span>', $text);
                 }
                 if ($hasdisplay) {
                     $text = preg_replace('/\\\\\\([\S\s]*?\\\\\\)/u',
                         '<span class="nolink">\0</span>', $text);
                 }
                 if ($hasdisplay) {
+                    // If default display TeX is used, wrap $$ $$ or \[ \] individually.
                     $text = preg_replace('/\$\$[\S\s]*?\$\$|\\\\\\[[\S\s]*?\\\\\\]/u',
                         '<span class="nolink">\0</span>', $text);
                 }
                     $text = preg_replace('/\$\$[\S\s]*?\$\$|\\\\\\[[\S\s]*?\\\\\\]/u',
                         '<span class="nolink">\0</span>', $text);
                 }