Skip to main content
Commonmark migration
Source Link

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</span><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</span><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</span><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Update hidden MathJax sample for Davide Cervone.
Source Link
lauir
  • 185
  • 17

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</span><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</span><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</span><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Change sub to span with styling
Source Link

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<sub>Paste<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</sub><brspan><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<sub>Paste MathJax code to be counted:</sub><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Count MathJax code tokens for Puzzling site MathJax problems. (No code snippets there, unfortunately.)

function Count() {
  var mathjax = document.getElementById("mathjax").value;
  var count = document.getElementById("count");
  tokens = mathjax.split(/(\\(?:[a-z]+|.)|##?\d|.)/i);
  var n = 0;
  for (var i = 0, m = tokens.length; i < m; i++) {
    if (!tokens[i].match(/^$|\}|\s|\n/)) n++;
  }
  count.innerHTML = "Tokens: <b>"+n+"</b>";
}
<input type="button" value="Count Tokens" onclick="Count()" />
<span id="count" style="padding-left:2em"></span><br/>
<span style="vertical-align:-.1em; font-size:80%">Paste MathJax code to be counted:</span><br/>
<textarea cols="80" rows="5" id="mathjax"></textarea>

Add case-insensitivity switch. Adjust height of textarea. Hide a temporary MathJax sample for Davide Cervone.
Source Link
lauir
  • 185
  • 17
Loading
Add uppercase to word match
Source Link
lauir
  • 185
  • 17
Loading
Move button to easier position
Source Link
Loading
Move "count tokens" button
Source Link
Loading
Source Link
Loading
Post Made Community Wiki by Davide Cervone