diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index fa6fd2561..549daa6a0 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -11,7 +11,7 @@ - + diff --git a/js/mathjax-config.js b/js/mathjax-config.js new file mode 100644 index 000000000..b367292a0 --- /dev/null +++ b/js/mathjax-config.js @@ -0,0 +1,25 @@ +MathJax = { + /* Bug fix for 3.0.1 version. + Test and delete if a new version works. + https://www.bountysource.com/issues/88419745-processescapes-set-to-true-doesn-t-work */ + startup: { + pageReady() { + const options = MathJax.startup.document.options; + const BaseMathItem = options.MathItem; + options.MathItem = class FixedMathItem extends BaseMathItem { + assistiveMml(document) { + if (this.display !== null) super.assistiveMml(document); + } + }; + return MathJax.startup.defaultPageReady(); + } + }, + /* end of bug fix */ + tex: { + /* inlineMath: [['$', '$'], ['\\(', '\\)']] // Uncomment to use $...$ for inline math */ + inlineMath: [['\\(', '\\)']] + }, + svg: { + fontCache: 'global' + } +}; diff --git a/swad_changelog.h b/swad_changelog.h index 6b9ddb0d3..fed61f228 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -497,7 +497,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.146 (2020-03-12)" +#define Log_PLATFORM_VERSION "SWAD 19.147 (2020-03-14)" #define CSS_FILE "swad19.146.css" #define JS_FILE "swad19.91.1.js" /* @@ -523,7 +523,10 @@ Param // TODO: Miguel Damas: al principio de los exámenes tendría que poner cuánto resta cada pregunta // TODO: Si el alumno ha marcado "Permitir que los profesores...", entonces pedir confirmación al pulsar el botón azul, para evitar que se envíe por error antes de tiempo // TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores -// TODO: Instalar la última versión de MathJax de https://www.jsdelivr.com/package/npm/mathjax y comprobar que funciona bien con pandoc + + Version 19.147: Mar 14, 2020 Change MathJax to version 3.0.1. (282550 lines) + Copy the following JavaScript file to public directory: +sudo cp js/mathjax-config.js /var/www/html/swad/ Version 19.146: Mar 12, 2020 Background and changes in layout of matches. (282484 lines) Copy the following background image to icon public directory: diff --git a/swad_info.c b/swad_info.c index 64d75fe8d..3f6a78498 100644 --- a/swad_info.c +++ b/swad_info.c @@ -1791,6 +1791,7 @@ static bool Inf_CheckAndShowRichTxt (void) fclose (FileMD); /***** Convert from Markdown to HTML *****/ + /* MathJax 2.5.1 #ifdef Cfg_MATHJAX_LOCAL // Use the local copy of MathJax snprintf (MathJaxURL,sizeof (MathJaxURL), @@ -1799,6 +1800,17 @@ static bool Inf_CheckAndShowRichTxt (void) #else // Use the MathJax Content Delivery Network (CDN) MathJaxURL[0] = '\0'; +#endif + */ + /* MathJax 3.0.1 */ +#ifdef Cfg_MATHJAX_LOCAL + // Use the local copy of MathJax + snprintf (MathJaxURL,sizeof (MathJaxURL), + "=%s/mathjax/tex-chtml.js", + Cfg_URL_SWAD_PUBLIC); +#else + // Use the MathJax Content Delivery Network (CDN) + MathJaxURL[0] = '\0'; #endif // --ascii uses only ascii characters in output // (uses numerical entities instead of UTF-8) @@ -1806,7 +1818,7 @@ static bool Inf_CheckAndShowRichTxt (void) snprintf (Command,sizeof (Command), "iconv -f WINDOWS-1252 -t UTF-8 %s" " | " - "pandoc --ascii --mathjax%s -f markdown -t html5" + "pandoc --ascii --mathjax%s -f markdown_github+tex_math_dollars -t html5" " | " "iconv -f UTF-8 -t WINDOWS-1252 -o %s", PathFileMD, diff --git a/swad_layout.c b/swad_layout.c index 0744724c7..70b142a5c 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -646,17 +646,8 @@ static void Lay_WriteScripts (void) static void Lay_WriteScriptMathJax (void) { - // MathJax configuration + /* MathJax 2.5.1 (obsolete) */ /* - HTM_SCRIPT_Begin (NULL,NULL); - fprintf (Gbl.F.Out," window.MathJax = {" - " tex2jax: {" - " inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ]," - " processEscapes: true" - " }" - " };"); - HTM_SCRIPT_End (); - */ #ifdef Cfg_MATHJAX_LOCAL // Use the local copy of MathJax HTM_SCRIPT_Begin (Cfg_URL_SWAD_PUBLIC "/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML",NULL); @@ -665,6 +656,78 @@ static void Lay_WriteScriptMathJax (void) HTM_SCRIPT_Begin ("//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",NULL); #endif HTM_SCRIPT_End (); + */ + + /* MathJax 3.0.1 (march 2020) + Source: + http://docs.mathjax.org/en/latest/web/configuration.html + */ + + /* Configuration Using an In-Line Script */ + /* + HTM_Txt (""); + */ + + /* Using a Local File for Configuration + + Using a Local File for Configuration + + If you are using the same MathJax configuration over multiple pages, + you may find it convenient to store your configuration + in a separate JavaScript file that you load into the page. + For example, you could create a file called mathjax-config.js that contains + + window.MathJax = { + tex: { + inlineMath: [['$', '$'], ['\\(', '\\)']], + }, + svg: { + fontCache: 'global' + } + }; + + and then use + + + + + to first load your configuration file, + and then load the tex-svg component from the jsdelivr CDN. + + Note that here we use the defer attribute on both scripts + so that they will execute in order, + but still not block the rest of the page + while the files are being downloaded to the browser. + If the async attribute were used, + there is no guarantee that the configuration would run first, + and so you could get instances + where MathJax doesn't get properly configured, + and they would seem to occur randomly. + */ + HTM_TxtF ("\n", + Cfg_URL_SWAD_PUBLIC); + +#ifdef Cfg_MATHJAX_LOCAL + // Use the local copy of MathJax + HTM_TxtF ("\n", + Cfg_URL_SWAD_PUBLIC); +#else + // Use the MathJax Content Delivery Network (CDN) + HTM_TxtF ("\n"); +#endif } /*****************************************************************************/ diff --git a/swad_test.c b/swad_test.c index 7de65745e..b293878d1 100644 --- a/swad_test.c +++ b/swad_test.c @@ -1041,6 +1041,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible) Lay_NotEnoughMemoryExit (); Str_Copy (StemRigorousHTML,Stem, StemLength); + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, StemRigorousHTML,StemLength,false);