diff --git a/CMakeLists.txt b/CMakeLists.txt index bd01eb3a2c..933aed91d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -572,6 +572,10 @@ if(OPENCV_DISABLE_FILESYSTEM_SUPPORT) add_definitions(-DOPENCV_HAVE_FILESYSTEM_SUPPORT=0) endif() +# MathJax is used for math rendering by both Doxygen HTML and JavaDoc, so +# this var have to be defined before "modules" AND "doc" are processed +set(OPENCV_MATHJAX_RELPATH "https://cdn.jsdelivr.net/npm/mathjax@3.0.1" CACHE STRING "URI to a MathJax installation") + # ---------------------------------------------------------------------------- # Get actual OpenCV version number from sources # ---------------------------------------------------------------------------- diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index ad7b39da99..411b77808a 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -195,9 +195,6 @@ if(DOXYGEN_FOUND) list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/tutorial-utils.js") string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_HTML_FILES "${CMAKE_DOXYGEN_HTML_FILES}") - set(OPENCV_MATHJAX_RELPATH "https://cdn.jsdelivr.net/npm/mathjax@3.0.1" CACHE STRING "URI to a MathJax installation") - - if (DOXYGEN_DOT_EXECUTABLE) message(STATUS "Found DOT executable: ${DOXYGEN_DOT_EXECUTABLE}") set(init_dot_path "${DOXYGEN_DOT_EXECUTABLE}") diff --git a/doc/mymath.js b/doc/mymath.js index 1ab480b5a4..028fa41cd2 100644 --- a/doc/mymath.js +++ b/doc/mymath.js @@ -1,6 +1,8 @@ // diff --git a/modules/java/jar/build.xml.in b/modules/java/jar/build.xml.in index eefaa343b6..41ef1d55ba 100644 --- a/modules/java/jar/build.xml.in +++ b/modules/java/jar/build.xml.in @@ -45,18 +45,23 @@ @CMAKE_CONFIG_OPENCV_JAVADOC_LINK@ additionalparam="--allow-script-in-comments" > -
+ var url = window.location.href; var pos = url.lastIndexOf('/javadoc/'); url = pos >= 0 ? (url.substring(0, pos) + '/javadoc/mymath.js') : (window.location.origin + '/mymath.js'); var script = document.createElement('script'); - script.src = '@OPENCV_MATHJAX_RELPATH@/es5/tex-chtml.js,' + url; - document.getElementsByTagName('head')[0].appendChild(script); + script.setAttribute("src", url); + script.setAttribute("defer", "") + document.head.appendChild(script); + script = document.createElement('script'); + script.setAttribute("src", '@OPENCV_MATHJAX_RELPATH@/es5/tex-chtml.js'); + script.setAttribute("defer", "") + document.head.appendChild(script); ]]> -
+