@@ -341,7 +341,6 @@ static QCString substituteHtmlKeywords(const QCString &file,
341341 bool searchEngine = Config_getBool (SEARCHENGINE);
342342 bool serverBasedSearch = Config_getBool (SERVER_BASED_SEARCH);
343343 bool mathJax = Config_getBool (USE_MATHJAX);
344- QCString mathJaxFormat = Config_getEnumAsString (MATHJAX_FORMAT);
345344 bool disableIndex = Config_getBool (DISABLE_INDEX);
346345 bool hasProjectName = !projectName.isEmpty ();
347346 bool hasProjectNumber = !Config_getString (PROJECT_NUMBER).isEmpty ();
@@ -462,143 +461,107 @@ static QCString substituteHtmlKeywords(const QCString &file,
462461 path.prepend (relPath);
463462 }
464463
465- switch (mathJaxVersion )
464+ auto writeMathJax3Packages = [&mathJaxJs]( const StringVector &mathJaxExtensions )
466465 {
467- case MATHJAX_VERSION_t::MathJax_4:
466+ mathJaxJs += " packages: ['base','configmacros'" ;
467+ if (!g_latex_macro.isEmpty ())
468+ {
469+ mathJaxJs+= " ,'newcommand'" ;
470+ }
471+ for (const auto &s : mathJaxExtensions)
472+ {
473+ mathJaxJs+= " ,'" +QCString (s.c_str ())+" '" ;
474+ }
475+ mathJaxJs += " ]\n " ;
476+ };
477+
478+ auto writeMathJax4Packages = [&mathJaxJs](const StringVector &mathJaxExtensions)
479+ {
480+ mathJaxJs += " packages: {\n " ;
481+ bool first = true ;
482+ for (const auto &s : mathJaxExtensions)
483+ {
484+ if (!first) mathJaxJs+= " ," ;
485+ mathJaxJs+= " \n '[+]': ['" +QCString (s.c_str ())+" ']" ;
486+ first = false ;
487+ }
488+ mathJaxJs += " \n }\n " ;
489+ };
490+
491+ auto writeMathJaxScript = [&path,&mathJaxJs](const QCString &pathPostfix,
492+ std::function<void (const StringVector&)> writePackages)
493+ {
494+ QCString mathJaxFormat = Config_getEnumAsString (MATHJAX_FORMAT);
495+ mathJaxJs += " <script type=\" text/javascript\" >\n "
496+ " window.MathJax = {\n "
497+ " options: {\n "
498+ " ignoreHtmlClass: 'tex2jax_ignore',\n "
499+ " processHtmlClass: 'tex2jax_process'\n "
500+ " }" ;
501+ // MACRO / EXT
502+ const StringVector &mathJaxExtensions = Config_getList (MATHJAX_EXTENSIONS);
503+ if (!mathJaxExtensions.empty () || !g_latex_macro.isEmpty ())
504+ {
505+ mathJaxJs+= " ,\n " ;
506+ if (!mathJaxExtensions.empty ())
507+ {
508+ bool first = true ;
509+ mathJaxJs+= " loader: {\n "
510+ " load: [" ;
511+ for (const auto &s : mathJaxExtensions)
512+ {
513+ if (!first) mathJaxJs+= " ," ;
514+ mathJaxJs+= " '[tex]/" +QCString (s.c_str ())+" '" ;
515+ first = false ;
516+ }
517+ mathJaxJs+= " ]\n "
518+ " },\n " ;
519+ }
520+ mathJaxJs+= " tex: {\n "
521+ " macros: {" ;
522+ if (!g_latex_macro.isEmpty ())
468523 {
469- mathJaxJs += " <script type=\" text/javascript\" >\n "
470- " window.MathJax = {\n "
471- " options: {\n "
472- " ignoreHtmlClass: 'tex2jax_ignore',\n "
473- " processHtmlClass: 'tex2jax_process'\n "
474- " }" ;
475- // MACRO / EXT
476- const StringVector &mathJaxExtensions = Config_getList (MATHJAX_EXTENSIONS);
477- if (!mathJaxExtensions.empty () || !g_latex_macro.isEmpty ())
478- {
479- mathJaxJs+= " ,\n " ;
480- if (!mathJaxExtensions.empty ())
481- {
482- bool first = true ;
483- mathJaxJs+= " loader: {\n "
484- " load: [" ;
485- for (const auto &s : mathJaxExtensions)
486- {
487- if (!first) mathJaxJs+= " ," ;
488- mathJaxJs+= " '[tex]/" +QCString (s.c_str ())+" '" ;
489- first = false ;
490- }
491- mathJaxJs+= " ]\n "
492- " },\n " ;
493- }
494- mathJaxJs+= " tex: {\n "
495- " macros: {" ;
496- if (!g_latex_macro.isEmpty ())
497- {
498- mathJaxJs += g_latex_macro+" " ;
499- }
500- mathJaxJs+=" },\n "
501- " packages: {\n " ;
502- bool first = true ;
503- for (const auto &s : mathJaxExtensions)
504- {
505- if (!first) mathJaxJs+= " ," ;
506- mathJaxJs+= " \n " ;
507- mathJaxJs+= " '[+]': ['" +QCString (s.c_str ())+" ']" ;
508- first = false ;
509- }
510- mathJaxJs += " \n }\n " ;
511- mathJaxJs += " }\n " ;
512- }
513- else
514- {
515- mathJaxJs += " \n " ;
516- }
517- mathJaxJs += " };\n " ;
518- // MATHJAX_CODEFILE
519- if (!g_mathjax_code.isEmpty ())
520- {
521- mathJaxJs += g_mathjax_code;
522- mathJaxJs += " \n " ;
523- }
524- mathJaxJs+=" </script>\n " ;
525- mathJaxJs += " <script type=\" text/javascript\" id=\" MathJax-script\" async=\" async\" src=\" " +
526- path + " tex-" + mathJaxFormat.lower () + " .js\" >" ;
527- mathJaxJs+=" </script>\n " ;
524+ mathJaxJs += g_latex_macro+" " ;
528525 }
526+ mathJaxJs+=" },\n " ;
527+ writePackages (mathJaxExtensions);
528+ mathJaxJs += " }\n " ;
529+ }
530+ else
531+ {
532+ mathJaxJs += " \n " ;
533+ }
534+ mathJaxJs += " };\n " ;
535+ // MATHJAX_CODEFILE
536+ if (!g_mathjax_code.isEmpty ())
537+ {
538+ mathJaxJs += g_mathjax_code;
539+ mathJaxJs += " \n " ;
540+ }
541+ mathJaxJs+=" </script>\n " ;
542+ mathJaxJs += " <script type=\" text/javascript\" id=\" MathJax-script\" async=\" async\" src=\" " +
543+ path + pathPostfix + " tex-" + mathJaxFormat.lower () + " .js\" >" ;
544+ mathJaxJs+=" </script>\n " ;
545+ };
546+
547+ switch (mathJaxVersion)
548+ {
549+ case MATHJAX_VERSION_t::MathJax_4:
550+ writeMathJaxScript (" " ,writeMathJax4Packages);
529551 break ;
530552 case MATHJAX_VERSION_t::MathJax_3:
531- {
532- mathJaxJs += // "<script src=\"https://polyfill.io/v3/polyfill.min.js?features=es6\"></script>\n" // needed for IE11 only, see #10354
533- " <script type=\" text/javascript\" >\n "
534- " window.MathJax = {\n "
535- " options: {\n "
536- " ignoreHtmlClass: 'tex2jax_ignore',\n "
537- " processHtmlClass: 'tex2jax_process'\n "
538- " }" ;
539- const StringVector &mathJaxExtensions = Config_getList (MATHJAX_EXTENSIONS);
540- if (!mathJaxExtensions.empty () || !g_latex_macro.isEmpty ())
541- {
542- mathJaxJs+= " ,\n " ;
543- if (!mathJaxExtensions.empty ())
544- {
545- bool first = true ;
546- mathJaxJs+= " loader: {\n "
547- " load: [" ;
548- for (const auto &s : mathJaxExtensions)
549- {
550- if (!first) mathJaxJs+= " ," ;
551- mathJaxJs+= " '[tex]/" +QCString (s.c_str ())+" '" ;
552- first = false ;
553- }
554- mathJaxJs+= " ]\n "
555- " },\n " ;
556- }
557- mathJaxJs+= " tex: {\n "
558- " macros: {" ;
559- if (!g_latex_macro.isEmpty ())
560- {
561- mathJaxJs += g_latex_macro+" " ;
562- }
563- mathJaxJs+=" },\n "
564- " packages: ['base','configmacros'" ;
565- if (!g_latex_macro.isEmpty ())
566- {
567- mathJaxJs+= " ,'newcommand'" ;
568- }
569- for (const auto &s : mathJaxExtensions)
570- {
571- mathJaxJs+= " ,'" +QCString (s.c_str ())+" '" ;
572- }
573- mathJaxJs += " ]\n "
574- " }\n " ;
575- }
576- else
577- {
578- mathJaxJs += " \n " ;
579- }
580- mathJaxJs += " };\n " ;
581- // MATHJAX_CODEFILE
582- if (!g_mathjax_code.isEmpty ())
583- {
584- mathJaxJs += g_mathjax_code;
585- mathJaxJs += " \n " ;
586- }
587- mathJaxJs += " </script>\n " ;
588- mathJaxJs += " <script type=\" text/javascript\" id=\" MathJax-script\" async=\" async\" src=\" " +
589- path + " es5/tex-" + mathJaxFormat.lower () + " .js\" >" ;
590- mathJaxJs+=" </script>\n " ;
591- }
553+ writeMathJaxScript (" es5/" ,writeMathJax3Packages);
592554 break ;
593555 case MATHJAX_VERSION_t::MathJax_2:
594556 {
557+ QCString mathJaxFormat = Config_getEnumAsString (MATHJAX_FORMAT);
595558 mathJaxJs = " <script type=\" text/x-mathjax-config\" >\n "
596559 " MathJax.Hub.Config({\n "
597560 " extensions: [\" tex2jax.js\" " ;
598561 const StringVector &mathJaxExtensions = Config_getList (MATHJAX_EXTENSIONS);
599562 for (const auto &s : mathJaxExtensions)
600563 {
601- mathJaxJs+= " , \" " +QCString (s. c_str () )+" .js\" " ;
564+ mathJaxJs+= " , \" " +QCString (s)+" .js\" " ;
602565 }
603566 if (mathJaxFormat.isEmpty ())
604567 {
@@ -3354,7 +3317,7 @@ void HtmlGenerator::writeExternalSearchPage()
33543317 const StringVector &extraSearchMappings = Config_getList (EXTRA_SEARCH_MAPPINGS);
33553318 for (const auto &ml : extraSearchMappings)
33563319 {
3357- QCString mapLine = ml. c_str ( );
3320+ QCString mapLine (ml );
33583321 int eqPos = mapLine.find (' =' );
33593322 if (eqPos!=-1 ) // tag command contains a destination
33603323 {
0 commit comments