lib/main.js
function GetHTML(result) {
  if (data.css) result.css = CHTMLSTYLES;
  if (!data.html && !data.htmlNode) return;
  var jax = MathJax.Hub.getAllJax()[0]; if (!jax) return;
  var script = jax.SourceElement(), html = script.previousSibling;

  // add speech text if there isn't one
  if (data.speakText){
    var labelTarget = html.querySelector('.mjx-math');
    for (child of labelTarget.childNodes) child.setAttribute("aria-hidden",true);
    if (!labelTarget.getAttribute("aria-label")){
    labelTarget.setAttribute("aria-label",result.speakText);
    }
  }
  // remove automatically generated IDs
  var ids = html.querySelectorAll('[id^="MJXc-Node-"]');
  for (var i = 0; i < ids.length; i++){
    ids[i].removeAttribute("id");
  }
  // remove extreneous frame element
  var frame = html.querySelector('[id^="MathJax-Element-"]');
  if (frame){
    // in display-mode, the frame is inside the display-style wrapper
    html.insertBefore(frame.firstChild, frame);
    html.removeChild(frame);
  }
  else{
    // otherwise (inline-mode) the frame is the root element
    html.removeAttribute("id");
  }
  if (data.html) result.html = html.outerHTML;
  if (data.htmlNode) result.htmlNode = html;
}
function GetHTML(result) {
  if (data.css) result.css = CHTMLSTYLES;
  if (!data.html && !data.htmlNode) return;
  var jax = MathJax.Hub.getAllJax()[0]; if (!jax) return;
  var script = jax.SourceElement(), html = script.previousSibling;

  // add speech text if there isn't one
  if (data.speakText){
    var labelTarget = html.querySelector('.mjx-math');
    for (child of labelTarget.childNodes) child.setAttribute("aria-hidden",true);
    if (!labelTarget.getAttribute("aria-label")){
    labelTarget.setAttribute("aria-label",result.speakText);
    }
  }
  // remove automatically generated IDs
  var ids = html.querySelectorAll('[id^="MJXc-Node-"]');
  for (var i = 0; i < ids.length; i++){
    ids[i].removeAttribute("id");
  }
  // remove extreneous frame element
  var frame = html.querySelector('[id^="MathJax-Element-"]');
  if (frame){
    // in display-mode, the frame is inside the display-style wrapper
    html.insertBefore(frame.firstChild, frame);
    html.removeChild(frame);
  }
  else{
    // otherwise (inline-mode) the frame is the root element
    html.removeAttribute("id");
  }
  if (data.html) result.html = html.outerHTML;
  if (data.htmlNode) result.htmlNode = html;
}
function GetHTML ( result ) { if ( data . css ) result . css = CHTMLSTYLES ; if ( ! data . html && ! data . htmlNode ) return ; var jax = MathJax . Hub . getAllJax ( ) [ 0 ] ; if ( ! jax ) return ; var script = jax . SourceElement ( ) , html = script . previousSibling ; // add speech text if there isn't one if ( data . speakText ) { var labelTarget = html . querySelector ( '.mjx-math' ) ; for ( child of labelTarget . childNodes ) child . setAttribute ( "aria-hidden" , true ) ; if ( ! labelTarget . getAttribute ( "aria-label" ) ) { labelTarget . setAttribute ( "aria-label" , result . speakText ) ; } } // remove automatically generated IDs var ids = html . querySelectorAll ( '[id^="MJXc-Node-"]' ) ; for ( var i = 0 ; i < ids . length ; i ++ ) { ids [ i ] . removeAttribute ( "id" ) ; } // remove extreneous frame element var frame = html . querySelector ( '[id^="MathJax-Element-"]' ) ; if ( frame ) { // in display-mode, the frame is inside the display-style wrapper html . insertBefore ( frame . firstChild , frame ) ; html . removeChild ( frame ) ; } else { // otherwise (inline-mode) the frame is the root element html . removeAttribute ( "id" ) ; } if ( data . html ) result . html = html . outerHTML ; if ( data . htmlNode ) result . htmlNode = html ; }
Create HTML and CSS output, if requested
Create HTML and CSS output if requested