diff --git a/static/main.js b/static/main.js index 7df2b327..e108b730 100644 --- a/static/main.js +++ b/static/main.js @@ -30,6 +30,30 @@ function init() { macroString += "&" + match[0].substr(1); } + // The `before` search parameter puts normal text before the math. + // The `after` search parameter puts normal text after the math. + // Example use: testing baseline alignment. + if (/(?:^\?|&)(?:before|after)=/.test(window.location.search)) { + var mathContainer = math; + mathContainer.id = "math-container"; + + if ((match = /(?:^\?|&)before=([^&]*)/.exec(window.location.search))) { + var child = document.createTextNode(decodeURIComponent(match[1])); + mathContainer.appendChild(child); + macroString += "&" + match[0].substr(1); + } + + math = document.createElement("span"); + math.id = "math"; + mathContainer.appendChild(math); + + if ((match = /(?:^\?|&)after=([^&]*)/.exec(window.location.search))) { + var child = document.createTextNode(decodeURIComponent(match[1])); + mathContainer.appendChild(child); + macroString += "&" + match[0].substr(1); + } + } + reprocess(); function setSearch() {