diff --git a/progs/convert/html/tmhtml.scm b/progs/convert/html/tmhtml.scm index d291a92..c992552 100644 --- a/progs/convert/html/tmhtml.scm +++ b/progs/convert/html/tmhtml.scm @@ -209,12 +209,9 @@ (title (tmhtml-find-title doc)) (css `(h:style (@ (type "text/css")) ,(tmhtml-css-header))) (xhead '()) - ;; Use a single string for the JavaScript code block - (js-inline `((h:script (@ (type "text/javascript")) - "(function () {\"use strict\"; window.addEventListener(\"load\", function () { var box, div, link, namespaceURI; namespaceURI = 'http://www.w3.org/1998/Math/MathML'; if (document.body.getElementsByTagNameNS(namespaceURI, 'math')[0]) { document.body.insertAdjacentHTML('afterbegin', '
'); div = document.body.firstChild; box = div.firstChild.firstChild.getBoundingClientRect(); document.body.removeChild(div); if (Math.abs(box.height - 23) > 1 || Math.abs(box.width - 77) > 1) { link = document.createElement('link'); link.href = 'https://fred-wang.github.io/mathml.css/mathml.css'; link.rel = 'stylesheet'; document.head.appendChild(link); } } }); })();"))) - (scripts `((h:script (@ (type "text/javascript"))) - (h:script "document.querySelectorAll('style').forEach(style => style.remove());"))) - (body (append scripts (tmhtml doc)))) + (body (tmhtml doc))) + (set! tmhtml-site-version + (with-extract doc "html-site-version")) (set! title (cond ((with-extract doc "html-title") @@ -234,17 +231,57 @@ (href ,(with-extract doc "html-css")) (type "text/css")))) (else css))) - - ;; Add your JS inline to the section - (set! xhead (append xhead js-inline)) - + (if (with-extract doc "html-head-javascript-src") + (let* ((src (with-extract doc "html-head-javascript-src")) + (script `(h:script (@ (language "javascript") + (src ,src))))) + (set! xhead (append xhead (list script))))) + (if (with-extract doc "html-head-javascript") + (let* ((code (with-extract doc "html-head-javascript")) + (script `(h:script (@ (language "javascript")) ,code))) + (set! xhead (append xhead (list script))))) + (if (with-extract doc "html-head-favicon") + (let* ((code (with-extract doc "html-head-favicon")) + (icon `(h:link (@ (rel "icon") (href ,code))))) + (set! xhead (append xhead (list icon))))) + (if (and (not (func? css 'h:link)) + (string-ends? (get-preference "texmacs->html:css-stylesheet") + ".css")) + (with src (get-preference "texmacs->html:css-stylesheet") + (with link-css `(h:link (@ (rel "stylesheet") + (href ,src) + (type "text/css"))) + (set! xhead (append xhead (list link-css)))))) + (if (tm-func? (with-extract* doc "html-extra-css") 'tuple) + (for (src (cdr (with-extract* doc "html-extra-css"))) + (with link-css `(h:link (@ (rel "stylesheet") + (href ,src) + (type "text/css"))) + (set! xhead (append xhead (list link-css)))))) + (if (tm-func? (with-extract* doc "html-extra-javascript-src") 'tuple) + (for (src (cdr (with-extract* doc "html-extra-javascript-src"))) + (with script `(h:script (@ (language "javascript") + (src ,src) + (defer "