<!DOCTYPE html> 
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>tinytable</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
.table td.tinytable, .table th.tinytable {    border-bottom: solid 0.1em #d3d8dc; }
.table td.tinytable, .table th.tinytable {    color: orange; background-color: black; }
.table td.tinytable, .table th.tinytable {    color: green; background-color: black; }
    </style>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
    <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
    <script>
    MathJax = {
      tex: {
        inlineMath: [['$', '$'], ['\\(', '\\)']]
      },
      svg: {
        fontCache: 'global'
      }
    };
    </script>
  </head>

  <body>
    <div class="container">
      <table class="table table-borderless" id="tinytable" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing='true'>
        <thead>
        
              <tr>
                <th scope="col">mpg</th>
                <th scope="col">cyl</th>
                <th scope="col">disp</th>
                <th scope="col">hp</th>
                <th scope="col">drat</th>
              </tr>
        </thead>
        
        <tbody>
                <tr>
                  <td>21.0</td>
                  <td>6</td>
                  <td>160</td>
                  <td>110</td>
                  <td>3.90</td>
                </tr>
                <tr>
                  <td>21.0</td>
                  <td>6</td>
                  <td>160</td>
                  <td>110</td>
                  <td>3.90</td>
                </tr>
                <tr>
                  <td>22.8</td>
                  <td>4</td>
                  <td>108</td>
                  <td> 93</td>
                  <td>3.85</td>
                </tr>
                <tr>
                  <td>21.4</td>
                  <td>6</td>
                  <td>258</td>
                  <td>110</td>
                  <td>3.08</td>
                </tr>
        </tbody>
      </table>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <script>
      function tinytable(i, j, css_id) {
        var table = document.getElementById("tinytable");
        table.rows[i].cells[j].classList.add(css_id);
      }
      function insertSpanRow(i, colspan, content) {
        var table = document.getElementById('tinytable');
        var newRow = table.insertRow(i);
        var newCell = newRow.insertCell(0);
        newCell.setAttribute("colspan", colspan);
        // newCell.innerText = content;
        // this may be unsafe, but innerText does not interpret <br>
        newCell.innerHTML = content;
      }
      function spanCell_tinytable(i, j, rowspan, colspan) {
        var table = document.getElementById("tinytable");
        const targetRow = table.rows[i];
        const targetCell = targetRow.cells[j];
        for (let r = 0; r < rowspan; r++) {
          // Only start deleting cells to the right for the first row (r == 0)
          if (r === 0) {
            // Delete cells to the right of the target cell in the first row
            for (let c = colspan - 1; c > 0; c--) {
              if (table.rows[i + r].cells[j + c]) {
                table.rows[i + r].deleteCell(j + c);
              }
            }
          }
          // For rows below the first, delete starting from the target column
          if (r > 0) {
            for (let c = colspan - 1; c >= 0; c--) {
              if (table.rows[i + r] && table.rows[i + r].cells[j]) {
                table.rows[i + r].deleteCell(j);
              }
            }
          }
        }
        // Set rowspan and colspan of the target cell
        targetCell.rowSpan = rowspan;
        targetCell.colSpan = colspan;
      }

window.addEventListener('load', function () { tinytable(0, 0, 'tinytable') })
window.addEventListener('load', function () { tinytable(0, 1, 'tinytable') })
window.addEventListener('load', function () { tinytable(0, 2, 'tinytable') })
window.addEventListener('load', function () { tinytable(0, 3, 'tinytable') })
window.addEventListener('load', function () { tinytable(0, 4, 'tinytable') })
window.addEventListener('load', function () { tinytable(0, 1, 'tinytable') })
window.addEventListener('load', function () { tinytable(0, 2, 'tinytable') })
window.addEventListener('load', function () { tinytable(1, 1, 'tinytable') })
window.addEventListener('load', function () { tinytable(1, 2, 'tinytable') })
window.addEventListener('load', function () { tinytable(2, 1, 'tinytable') })
window.addEventListener('load', function () { tinytable(2, 2, 'tinytable') })
window.addEventListener('load', function () { tinytable(3, 1, 'tinytable') })
window.addEventListener('load', function () { tinytable(3, 2, 'tinytable') })
window.addEventListener('load', function () { tinytable(4, 1, 'tinytable') })
window.addEventListener('load', function () { tinytable(4, 2, 'tinytable') })
    </script>

  </body>

</html>
